mirror of
https://github.com/slicer69/doas
synced 2024-10-15 12:13:08 +00:00
Added optimization to Makefile (can be set/overruled using OPT).
Added flag to display all warnings during compiling. Added status checks when parsing user/group IDs for Linux. Make sure Linux drops original user's groups when running as another user.
This commit is contained in:
parent
79c6c61a73
commit
2f83222829
3
Makefile
3
Makefile
|
@ -5,9 +5,10 @@ PREFIX?=/usr/local
|
|||
MANDIR?=$(DESTDIR)$(PREFIX)/man
|
||||
SYSCONFDIR?=$(DESTDIR)$(PREFIX)/etc
|
||||
OBJECTS=doas.o env.o execvpe.o reallocarray.o y.tab.o
|
||||
OPT?=-O2
|
||||
# Can set GLOBAL_PATH here to set PATH for target user.
|
||||
# TARGETPATH=-DGLOBAL_PATH=\"/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:\"
|
||||
CFLAGS+=-DUSE_PAM -DDOAS_CONF=\"${SYSCONFDIR}/doas.conf\" $(TARGETPATH)
|
||||
CFLAGS+=-Wall $(OPT) -DUSE_PAM -DDOAS_CONF=\"${SYSCONFDIR}/doas.conf\" $(TARGETPATH)
|
||||
LDFLAGS+=-lpam
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
|
|
28
doas.c
28
doas.c
|
@ -85,7 +85,11 @@ static int
|
|||
parseuid(const char *s, uid_t *uid)
|
||||
{
|
||||
struct passwd *pw;
|
||||
const char *errstr;
|
||||
#if !defined(__linux__) && !defined(__NetBSD__)
|
||||
const char *errstr = NULL;
|
||||
#else
|
||||
int status;
|
||||
#endif
|
||||
|
||||
if ((pw = getpwnam(s)) != NULL) {
|
||||
*uid = pw->pw_uid;
|
||||
|
@ -93,11 +97,13 @@ parseuid(const char *s, uid_t *uid)
|
|||
}
|
||||
#if !defined(__linux__) && !defined(__NetBSD__)
|
||||
*uid = strtonum(s, 0, UID_MAX, &errstr);
|
||||
#else
|
||||
sscanf(s, "%d", uid);
|
||||
#endif
|
||||
if (errstr)
|
||||
return -1;
|
||||
#else
|
||||
status = sscanf(s, "%d", uid);
|
||||
if (status != 1)
|
||||
return -1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
@ -117,7 +123,11 @@ static int
|
|||
parsegid(const char *s, gid_t *gid)
|
||||
{
|
||||
struct group *gr;
|
||||
const char *errstr;
|
||||
#if !defined(__linux__) && !defined(__NetBSD__)
|
||||
const char *errstr = NULL;
|
||||
#else
|
||||
int status;
|
||||
#endif
|
||||
|
||||
if ((gr = getgrnam(s)) != NULL) {
|
||||
*gid = gr->gr_gid;
|
||||
|
@ -125,11 +135,13 @@ parsegid(const char *s, gid_t *gid)
|
|||
}
|
||||
#if !defined(__linux__) && !defined(__NetBSD__)
|
||||
*gid = strtonum(s, 0, GID_MAX, &errstr);
|
||||
#else
|
||||
sscanf(s, "%d", gid);
|
||||
#endif
|
||||
if (errstr)
|
||||
return -1;
|
||||
#else
|
||||
status = sscanf(s, "%d", gid);
|
||||
if (status != 1)
|
||||
return -1;
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue