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-08-19 16:33:32 +0100
commit39b2121148a0aa016a648446823c8f02c5fd95b3 (patch)
tree83af2a05a97d6e3a8a7b566646bc97f7689340d6 /auth.c
parent8b3111d597316954caaf8ddf2e7746491976c248 (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 f9b767301..41e387614 100644
--- a/auth.c
+++ b/auth.c
@@ -423,8 +423,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
423 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); 423 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid);
424 if (options.strict_modes && 424 if (options.strict_modes &&
425 (stat(user_hostfile, &st) == 0) && 425 (stat(user_hostfile, &st) == 0) &&
426 ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || 426 !secure_permissions(&st, pw->pw_uid)) {
427 (st.st_mode & 022) != 0)) {
428 logit("Authentication refused for %.100s: " 427 logit("Authentication refused for %.100s: "
429 "bad owner or modes for %.200s", 428 "bad owner or modes for %.200s",
430 pw->pw_name, user_hostfile); 429 pw->pw_name, user_hostfile);
@@ -486,8 +485,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
486 snprintf(err, errlen, "%s is not a regular file", buf); 485 snprintf(err, errlen, "%s is not a regular file", buf);
487 return -1; 486 return -1;
488 } 487 }
489 if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) || 488 if (!secure_permissions(stp, uid)) {
490 (stp->st_mode & 022) != 0) {
491 snprintf(err, errlen, "bad ownership or modes for file %s", 489 snprintf(err, errlen, "bad ownership or modes for file %s",
492 buf); 490 buf);
493 return -1; 491 return -1;
@@ -502,8 +500,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
502 strlcpy(buf, cp, sizeof(buf)); 500 strlcpy(buf, cp, sizeof(buf));
503 501
504 if (stat(buf, &st) < 0 || 502 if (stat(buf, &st) < 0 ||
505 (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) || 503 !secure_permissions(&st, uid)) {
506 (st.st_mode & 022) != 0) {
507 snprintf(err, errlen, 504 snprintf(err, errlen,
508 "bad ownership or modes for directory %s", buf); 505 "bad ownership or modes for directory %s", buf);
509 return -1; 506 return -1;