openssh/openssh-6.6p1-keyperm.patch

27 lines
714 B
Diff
Raw Permalink Normal View History

2015-01-20 12:18:45 +00:00
diff --git a/authfile.c b/authfile.c
index e93d867..4fc5b3d 100644
--- a/authfile.c
+++ b/authfile.c
@@ -32,6 +32,7 @@
2014-06-03 14:51:07 +00:00
#include <errno.h>
#include <fcntl.h>
+#include <grp.h>
#include <stdio.h>
2015-01-20 12:18:45 +00:00
#include <stdarg.h>
2014-06-03 14:51:07 +00:00
#include <stdlib.h>
2015-01-20 12:18:45 +00:00
@@ -207,6 +208,13 @@ sshkey_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))
2011-04-23 14:15:56 +00:00
+ st.st_mode &= ~040;
+ }
+
if ((st.st_uid == getuid()) && (st.st_mode & 077) != 0) {
error("@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@");
error("@ WARNING: UNPROTECTED PRIVATE KEY FILE! @");