mirror of
https://github.com/slicer69/doas
synced 2024-07-24 03:34:26 +00:00
Merge pull request #6 from t6/patch-login_cap
Use setusercontext on FreeBSD
This commit is contained in:
commit
045f56f088
4
Makefile
4
Makefile
|
@ -9,6 +9,10 @@ UNAME_S := $(shell uname -s)
|
|||
ifeq ($(UNAME_S),Linux)
|
||||
LDFLAGS+=-lpam_misc
|
||||
endif
|
||||
ifeq ($(UNAME_S),FreeBSD)
|
||||
CFLAGS+=-DHAVE_LOGIN_CAP_H
|
||||
LDFLAGS+=-lutil
|
||||
endif
|
||||
|
||||
all: $(OBJECTS)
|
||||
$(CC) -o $(BIN) $(LDFLAGS) $(OBJECTS)
|
||||
|
|
2
doas.c
2
doas.c
|
@ -530,12 +530,14 @@ main(int argc, char **argv)
|
|||
}
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_LOGIN_CAP_H
|
||||
/* If we effectively are root, set the UID to actually be root to avoid
|
||||
permission errors. */
|
||||
if (target != 0)
|
||||
setuid(target);
|
||||
if ( geteuid() == ROOT_UID )
|
||||
setuid(ROOT_UID);
|
||||
#endif
|
||||
|
||||
syslog(LOG_AUTHPRIV | LOG_INFO, "%s ran command %s as %s from %s",
|
||||
myname, cmdline, pw->pw_name, cwd);
|
||||
|
|
Loading…
Reference in a new issue