From a19a5c023dc8470b49a6b7728b34e8801fe5a671 Mon Sep 17 00:00:00 2001 From: Brian Somers Date: Thu, 30 Dec 1999 03:36:11 +0000 Subject: [PATCH] Correct usages of getuid() and geteuid() Pointed out by: billf --- usr.sbin/ppp/bundle.c | 2 +- usr.sbin/ppp/chap.c | 2 +- usr.sbin/ppp/chat.c | 2 +- usr.sbin/ppp/command.c | 2 +- usr.sbin/ppp/exec.c | 2 +- usr.sbin/ppp/systems.c | 4 ++-- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/usr.sbin/ppp/bundle.c b/usr.sbin/ppp/bundle.c index ebacb5ab8932..9ee00e2e3081 100644 --- a/usr.sbin/ppp/bundle.c +++ b/usr.sbin/ppp/bundle.c @@ -1782,7 +1782,7 @@ bundle_setsid(struct bundle *bundle, int holdsession) waitpid(pid, &status, 0); /* Tweak our process arguments.... */ ID0setproctitle("session owner"); - setuid(geteuid()); + setuid(ID0realuid()); /* * Hang around for a HUP. This should happen as soon as the * ppp that we passed our ctty descriptor to closes it. diff --git a/usr.sbin/ppp/chap.c b/usr.sbin/ppp/chap.c index b0d874218311..36be4c50ffd6 100644 --- a/usr.sbin/ppp/chap.c +++ b/usr.sbin/ppp/chap.c @@ -253,7 +253,7 @@ chap_StartChild(struct chap *chap, char *prog, const char *name) } for (fd = getdtablesize(); fd > STDERR_FILENO; fd--) fcntl(fd, F_SETFD, 1); - setuid(geteuid()); + setuid(ID0realuid()); command_Expand(nargv, argc, (char const *const *)argv, chap->auth.physical->dl->bundle, 0, pid); execvp(nargv[0], nargv); diff --git a/usr.sbin/ppp/chat.c b/usr.sbin/ppp/chat.c index c6acdb1df38b..44849365b50e 100644 --- a/usr.sbin/ppp/chat.c +++ b/usr.sbin/ppp/chat.c @@ -731,7 +731,7 @@ ExecStr(struct physical *physical, char *command, char *out, int olen) open(_PATH_DEVNULL, O_RDWR); /* Leave it closed if it fails... */ for (i = getdtablesize(); i > 3; i--) fcntl(i, F_SETFD, 1); - setuid(geteuid()); + setuid(ID0realuid()); execvp(argv[0], argv); fprintf(stderr, "execvp: %s: %s\n", argv[0], strerror(errno)); _exit(127); diff --git a/usr.sbin/ppp/command.c b/usr.sbin/ppp/command.c index 98ad92b53691..120d1a25a415 100644 --- a/usr.sbin/ppp/command.c +++ b/usr.sbin/ppp/command.c @@ -491,7 +491,7 @@ ShellCommand(struct cmdargs const *arg, int bg) for (i = getdtablesize(); i > STDERR_FILENO; i--) fcntl(i, F_SETFD, 1); - setuid(geteuid()); + setuid(ID0realuid()); if (arg->argc > arg->argn) { /* substitute pseudo args */ char *argv[MAXARGS]; diff --git a/usr.sbin/ppp/exec.c b/usr.sbin/ppp/exec.c index e9bf01a1db5d..01027042c62c 100644 --- a/usr.sbin/ppp/exec.c +++ b/usr.sbin/ppp/exec.c @@ -126,7 +126,7 @@ exec_Create(struct physical *p) case 0: close(fids[0]); timer_TermService(); - setuid(geteuid()); + setuid(ID0realuid()); switch (fork()) { case 0: diff --git a/usr.sbin/ppp/systems.c b/usr.sbin/ppp/systems.c index a570ceb6253c..18a9df07ee34 100644 --- a/usr.sbin/ppp/systems.c +++ b/usr.sbin/ppp/systems.c @@ -78,7 +78,7 @@ InterpretArg(const char *from, char *to) ptr = strchr(++from, '/'); len = ptr ? ptr - from : strlen(from); if (len == 0) { - pwd = getpwuid(getuid()); + pwd = getpwuid(ID0realuid()); } else { strncpy(to, from, len); to[len] = '\0'; @@ -184,7 +184,7 @@ AllowUsers(struct cmdargs const *arg) struct passwd *pwd; userok = 0; - pwd = getpwuid(getuid()); + pwd = getpwuid(ID0realuid()); if (pwd != NULL) for (f = arg->argn; f < arg->argc; f++) if (!strcmp("*", arg->argv[f]) || !strcmp(pwd->pw_name, arg->argv[f])) {