rcolebaugh / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
9070b3
diff -up openssh-8.2p1/authfile.c.keyperm openssh-8.2p1/authfile.c
9070b3
--- openssh-8.2p1/authfile.c.keyperm	2020-02-14 01:40:54.000000000 +0100
9070b3
+++ openssh-8.2p1/authfile.c	2020-02-17 11:55:12.841729758 +0100
9070b3
@@ -31,6 +31,7 @@
9070b3
 
9070b3
 #include <errno.h>
9070b3
 #include <fcntl.h>
9070b3
+#include <grp.h>
9070b3
 #include <stdio.h>
9070b3
 #include <stdarg.h>
9070b3
 #include <stdlib.h>
9070b3
@@ -101,7 +102,19 @@ sshkey_perm_ok(int fd, const char *filen
9070b3
 #ifdef HAVE_CYGWIN
9070b3
 	if (check_ntsec(filename))
9070b3
 #endif
9070b3
+
9070b3
 	if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
9070b3
+		if (st.st_mode & 040) {
9070b3
+			struct group *gr;
9070b3
+
9070b3
+			if ((gr = getgrnam("ssh_keys")) && (st.st_gid == gr->gr_gid)) {
9070b3
+				/* The only additional bit is read
9070b3
+				 * for ssh_keys group, which is fine */
9070b3
+				if ((st.st_mode & 077) == 040 ) {
9070b3
+					return 0;
9070b3
+				}
9070b3
+			}
9070b3
+		}
9070b3
 		error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
9070b3
 		error("@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @");
9070b3
 		error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");