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>2016-12-26 00:55:59 +0000
commit47c946434c6e99ff9da531cfcafb051e38e79ff8 (patch)
tree08e8df7c7e84f3fa65f1d4e3a82809cde0a3e731 /auth.c
parent68d399525871ecd1a2837f04045581a2774ba4bb (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 c63906873..90390724d 100644
--- a/auth.c
+++ b/auth.c
@@ -444,8 +444,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
444 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); 444 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid);
445 if (options.strict_modes && 445 if (options.strict_modes &&
446 (stat(user_hostfile, &st) == 0) && 446 (stat(user_hostfile, &st) == 0) &&
447 ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || 447 !secure_permissions(&st, pw->pw_uid)) {
448 (st.st_mode & 022) != 0)) {
449 logit("Authentication refused for %.100s: " 448 logit("Authentication refused for %.100s: "
450 "bad owner or modes for %.200s", 449 "bad owner or modes for %.200s",
451 pw->pw_name, user_hostfile); 450 pw->pw_name, user_hostfile);
@@ -507,8 +506,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
507 snprintf(err, errlen, "%s is not a regular file", buf); 506 snprintf(err, errlen, "%s is not a regular file", buf);
508 return -1; 507 return -1;
509 } 508 }
510 if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) || 509 if (!secure_permissions(stp, uid)) {
511 (stp->st_mode & 022) != 0) {
512 snprintf(err, errlen, "bad ownership or modes for file %s", 510 snprintf(err, errlen, "bad ownership or modes for file %s",
513 buf); 511 buf);
514 return -1; 512 return -1;
@@ -523,8 +521,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
523 strlcpy(buf, cp, sizeof(buf)); 521 strlcpy(buf, cp, sizeof(buf));
524 522
525 if (stat(buf, &st) < 0 || 523 if (stat(buf, &st) < 0 ||
526 (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) || 524 !secure_permissions(&st, uid)) {
527 (st.st_mode & 022) != 0) {
528 snprintf(err, errlen, 525 snprintf(err, errlen,
529 "bad ownership or modes for directory %s", buf); 526 "bad ownership or modes for directory %s", buf);
530 return -1; 527 return -1;