jonathancammack / rpms / openssh

Forked from rpms/openssh 8 months ago
Clone

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

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