diff --git a/crypto/openssh/auth.c b/crypto/openssh/auth.c index a2e1fa10ce45..65183d456490 100644 --- a/crypto/openssh/auth.c +++ b/crypto/openssh/auth.c @@ -39,6 +39,7 @@ __RCSID("$FreeBSD$"); # include #endif #include +#include #ifdef HAVE_LOGIN_H #include #endif @@ -983,6 +984,13 @@ subprocess(const char *tag, struct passwd *pw, const char *command, } 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() */ if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) { error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid,