bmh10 / rpms / openssh

Forked from rpms/openssh 10 days ago
Clone

Blame SOURCES/openssh-8.7p1-upstream-cve-2021-41617.patch

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