kentpeacock / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
d7ff6e
diff --git a/auth.c b/auth.c
d7ff6e
index b8d1040d..0134d694 100644
d7ff6e
--- a/auth.c
d7ff6e
+++ b/auth.c
d7ff6e
@@ -56,6 +56,7 @@
d7ff6e
 # include <paths.h>
d7ff6e
 #endif
d7ff6e
 #include <pwd.h>
d7ff6e
+#include <grp.h>
d7ff6e
 #ifdef HAVE_LOGIN_H
d7ff6e
 #include <login.h>
d7ff6e
 #endif
d7ff6e
@@ -2695,6 +2696,12 @@ subprocess(const char *tag, const char *command,
d7ff6e
 		}
d7ff6e
 		closefrom(STDERR_FILENO + 1);
d7ff6e
 
d7ff6e
+		if (geteuid() == 0 &&
d7ff6e
+		    initgroups(pw->pw_name, pw->pw_gid) == -1) {
d7ff6e
+			error("%s: initgroups(%s, %u): %s", tag,
d7ff6e
+			    pw->pw_name, (u_int)pw->pw_gid, strerror(errno));
d7ff6e
+			_exit(1);
d7ff6e
+		}
d7ff6e
		/* Don't use permanently_set_uid() here to avoid fatal() */
d7ff6e
 		if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) != 0) {
d7ff6e
 			error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid,