Correct usages of getuid() and geteuid()

Pointed out by: billf
This commit is contained in:
Brian Somers 1999-12-30 03:36:11 +00:00
parent b6fd7c6188
commit a19a5c023d
6 changed files with 7 additions and 7 deletions

View File

@ -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.

View File

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

View File

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

View File

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

View File

@ -126,7 +126,7 @@ exec_Create(struct physical *p)
case 0:
close(fids[0]);
timer_TermService();
setuid(geteuid());
setuid(ID0realuid());
switch (fork()) {
case 0:

View File

@ -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])) {