jonathancammack / rpms / openssh

Forked from rpms/openssh 8 months ago
Clone

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

9070b3
diff --git a/misc.c b/misc.c
9070b3
index b8d1040d..0134d694 100644
9070b3
--- a/misc.c
9070b3
+++ b/misc.c
9070b3
@@ -56,6 +56,7 @@
9070b3
 #ifdef HAVE_PATHS_H
9070b3
 # include <paths.h>
9070b3
 #include <pwd.h>
9070b3
+#include <grp.h>
9070b3
 #endif
9070b3
 #ifdef SSH_TUN_OPENBSD
9070b3
 #include <net/if.h>
9070b3
@@ -2695,6 +2696,12 @@ subprocess(const char *tag, const char *command,
9070b3
 		}
9070b3
 		closefrom(STDERR_FILENO + 1);
9070b3
 
9070b3
+		if (geteuid() == 0 &&
9070b3
+		    initgroups(pw->pw_name, pw->pw_gid) == -1) {
9070b3
+			error("%s: initgroups(%s, %u): %s", tag,
9070b3
+			    pw->pw_name, (u_int)pw->pw_gid, strerror(errno));
9070b3
+			_exit(1);
9070b3
+		}
9070b3
 		if (setresgid(pw->pw_gid, pw->pw_gid, pw->pw_gid) == -1) {
9070b3
 			error("%s: setresgid %u: %s", tag, (u_int)pw->pw_gid,
9070b3
 			    strerror(errno));