Changeset View
Changeset View
Standalone View
Standalone View
crypto/openssh/auth.c
Show All 33 Lines | |||||
#include <netinet/in.h> | #include <netinet/in.h> | ||||
#include <errno.h> | #include <errno.h> | ||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#ifdef HAVE_PATHS_H | #ifdef HAVE_PATHS_H | ||||
# include <paths.h> | # include <paths.h> | ||||
#endif | #endif | ||||
#include <pwd.h> | #include <pwd.h> | ||||
#include <grp.h> | |||||
#ifdef HAVE_LOGIN_H | #ifdef HAVE_LOGIN_H | ||||
#include <login.h> | #include <login.h> | ||||
#endif | #endif | ||||
#ifdef USE_SHADOW | #ifdef USE_SHADOW | ||||
#include <shadow.h> | #include <shadow.h> | ||||
#endif | #endif | ||||
#include <stdarg.h> | #include <stdarg.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
▲ Show 20 Lines • Show All 927 Lines • ▼ Show 20 Lines | if ((flags & SSH_SUBPROCESS_STDOUT_CAPTURE) != 0) | ||||
fd = p[1]; | fd = p[1]; | ||||
else if ((flags & SSH_SUBPROCESS_STDOUT_DISCARD) != 0) | else if ((flags & SSH_SUBPROCESS_STDOUT_DISCARD) != 0) | ||||
fd = devnull; | fd = devnull; | ||||
if (fd != -1 && dup2(fd, STDOUT_FILENO) == -1) { | if (fd != -1 && dup2(fd, STDOUT_FILENO) == -1) { | ||||
error("%s: dup2: %s", tag, strerror(errno)); | error("%s: dup2: %s", tag, strerror(errno)); | ||||
_exit(1); | _exit(1); | ||||
} | } | ||||
closefrom(STDERR_FILENO + 1); | closefrom(STDERR_FILENO + 1); | ||||
if (geteuid() == 0 && | |||||
initgroups(pw->pw_name, pw->pw_gid) == -1) { | |||||
error("%s: initgroups(%s, %u): %s", tag, | |||||
pw->pw_name, (u_int)pw->pw_gid, strerror(errno)); | |||||
_exit(1); | |||||
} | |||||
/* Don't use permanently_set_uid() here to avoid fatal() */ | /* Don't use permanently_set_uid() here to avoid fatal() */ | ||||
if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) { | if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) { | ||||
error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid, | error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid, | ||||
strerror(errno)); | strerror(errno)); | ||||
_exit(1); | _exit(1); | ||||
} | } | ||||
if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0) { | if (setresuid(pw->pw_uid, pw->pw_uid, pw->pw_uid) != 0) { | ||||
▲ Show 20 Lines • Show All 234 Lines • Show Last 20 Lines |