summaryrefslogtreecommitdiff
path: root/auth.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2014-02-09 16:09:58 +0000
committerColin Watson <cjwatson@debian.org>2015-12-03 17:05:05 +0000
commitaae427a0c7d5702bf294191533ab1f33437a8a56 (patch)
tree1d5f030d9165fa02b0713f6123a072e69dda342b /auth.c
parent0fe621a2c5a90e37e9a1afa8b56fd04fb1c53eef (diff)
Allow harmless group-writability
Allow secure files (~/.ssh/config, ~/.ssh/authorized_keys, etc.) to be group-writable, provided that the group in question contains only the file's owner. Rejected upstream for IMO incorrect reasons (e.g. a misunderstanding about the contents of gr->gr_mem). Given that per-user groups and umask 002 are the default setup in Debian (for good reasons - this makes operating in setgid directories with other groups much easier), we need to permit this by default. Bug: https://bugzilla.mindrot.org/show_bug.cgi?id=1060 Bug-Debian: http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=314347 Last-Update: 2013-09-14 Patch-Name: user-group-modes.patch
Diffstat (limited to 'auth.c')
-rw-r--r--auth.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/auth.c b/auth.c
index 214c2c708..25be63277 100644
--- a/auth.c
+++ b/auth.c
@@ -424,8 +424,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
424 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); 424 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid);
425 if (options.strict_modes && 425 if (options.strict_modes &&
426 (stat(user_hostfile, &st) == 0) && 426 (stat(user_hostfile, &st) == 0) &&
427 ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || 427 !secure_permissions(&st, pw->pw_uid)) {
428 (st.st_mode & 022) != 0)) {
429 logit("Authentication refused for %.100s: " 428 logit("Authentication refused for %.100s: "
430 "bad owner or modes for %.200s", 429 "bad owner or modes for %.200s",
431 pw->pw_name, user_hostfile); 430 pw->pw_name, user_hostfile);
@@ -487,8 +486,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
487 snprintf(err, errlen, "%s is not a regular file", buf); 486 snprintf(err, errlen, "%s is not a regular file", buf);
488 return -1; 487 return -1;
489 } 488 }
490 if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) || 489 if (!secure_permissions(stp, uid)) {
491 (stp->st_mode & 022) != 0) {
492 snprintf(err, errlen, "bad ownership or modes for file %s", 490 snprintf(err, errlen, "bad ownership or modes for file %s",
493 buf); 491 buf);
494 return -1; 492 return -1;
@@ -503,8 +501,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
503 strlcpy(buf, cp, sizeof(buf)); 501 strlcpy(buf, cp, sizeof(buf));
504 502
505 if (stat(buf, &st) < 0 || 503 if (stat(buf, &st) < 0 ||
506 (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) || 504 !secure_permissions(&st, uid)) {
507 (st.st_mode & 022) != 0) {
508 snprintf(err, errlen, 505 snprintf(err, errlen,
509 "bad ownership or modes for directory %s", buf); 506 "bad ownership or modes for directory %s", buf);
510 return -1; 507 return -1;