Merge pull request #6 from t6/patch-login_cap

Use setusercontext on FreeBSD
This commit is contained in:
Jesse Smith 2016-09-24 16:31:25 -03:00 committed by GitHub
commit 045f56f088
2 changed files with 6 additions and 0 deletions

View file

@ -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
View file

@ -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);