jonathancammack / rpms / openssh

Forked from rpms/openssh 8 months ago
Clone
aedd00
diff --git a/authfile.c b/authfile.c
aedd00
index e93d867..4fc5b3d 100644
aedd00
--- a/authfile.c
aedd00
+++ b/authfile.c
aedd00
@@ -32,6 +32,7 @@
aedd00
 
aedd00
 #include <errno.h>
aedd00
 #include <fcntl.h>
aedd00
+#include <grp.h>
aedd00
 #include <stdio.h>
aedd00
 #include <stdarg.h>
aedd00
 #include <stdlib.h>
aedd00
@@ -207,6 +208,13 @@ sshkey_perm_ok(int fd, const char *filename)
aedd00
 #ifdef HAVE_CYGWIN
aedd00
 	if (check_ntsec(filename))
aedd00
 #endif
aedd00
+	if (st.st_mode & 040) {
aedd00
+		struct group *gr;
aedd00
+
aedd00
+		if ((gr = getgrnam("ssh_keys")) && (st.st_gid == gr->gr_gid))
aedd00
+			st.st_mode &= ~040;
aedd00
+	}
aedd00
+
aedd00
 	if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
aedd00
 		error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
aedd00
 		error("@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @");