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-03-10 13:00:40 +0000
commit4176718757a83a831028f468ff66cedd291c24b9 (patch)
tree801c8e239d27f1a0c1321ab48958aeb74ee99c42 /auth.c
parent6165757b14648f66150a0b5b45790b117f562790 (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 bd6a026a1..782b7f8fe 100644
--- a/auth.c
+++ b/auth.c
@@ -425,8 +425,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
425 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); 425 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid);
426 if (options.strict_modes && 426 if (options.strict_modes &&
427 (stat(user_hostfile, &st) == 0) && 427 (stat(user_hostfile, &st) == 0) &&
428 ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || 428 !secure_permissions(&st, pw->pw_uid)) {
429 (st.st_mode & 022) != 0)) {
430 logit("Authentication refused for %.100s: " 429 logit("Authentication refused for %.100s: "
431 "bad owner or modes for %.200s", 430 "bad owner or modes for %.200s",
432 pw->pw_name, user_hostfile); 431 pw->pw_name, user_hostfile);
@@ -488,8 +487,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
488 snprintf(err, errlen, "%s is not a regular file", buf); 487 snprintf(err, errlen, "%s is not a regular file", buf);
489 return -1; 488 return -1;
490 } 489 }
491 if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) || 490 if (!secure_permissions(stp, uid)) {
492 (stp->st_mode & 022) != 0) {
493 snprintf(err, errlen, "bad ownership or modes for file %s", 491 snprintf(err, errlen, "bad ownership or modes for file %s",
494 buf); 492 buf);
495 return -1; 493 return -1;
@@ -504,8 +502,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
504 strlcpy(buf, cp, sizeof(buf)); 502 strlcpy(buf, cp, sizeof(buf));
505 503
506 if (stat(buf, &st) < 0 || 504 if (stat(buf, &st) < 0 ||
507 (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) || 505 !secure_permissions(&st, uid)) {
508 (st.st_mode & 022) != 0) {
509 snprintf(err, errlen, 506 snprintf(err, errlen,
510 "bad ownership or modes for directory %s", buf); 507 "bad ownership or modes for directory %s", buf);
511 return -1; 508 return -1;