rcolebaugh / rpms / openssh

Forked from rpms/openssh 2 years ago
Clone
Blob Blame History Raw
diff -up openssh-5.8p1/authfile.c.keyperm openssh-5.8p1/authfile.c
--- openssh-5.8p1/authfile.c.keyperm	2010-12-01 02:03:39.000000000 +0100
+++ openssh-5.8p1/authfile.c	2011-04-21 16:43:36.859648916 +0200
@@ -57,6 +57,7 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <grp.h>
 
 #include "xmalloc.h"
 #include "cipher.h"
@@ -600,6 +612,13 @@ key_perm_ok(int fd, const char *filename
 #ifdef HAVE_CYGWIN
 	if (check_ntsec(filename))
 #endif
+	if (st.st_mode & 040) {
+		struct group *gr;
+
+		if ((gr = getgrnam("ssh_keys")) && (st.st_gid == gr->gr_gid))
+			st.st_mode &= ~040;
+	}
+
 	if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
 		error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
 		error("@         WARNING: UNPROTECTED PRIVATE KEY FILE!          @");