diff options
Diffstat (limited to 'auth.c')
-rw-r--r-- | auth.c | 36 |
1 files changed, 29 insertions, 7 deletions
@@ -59,6 +59,7 @@ | |||
59 | #include "servconf.h" | 59 | #include "servconf.h" |
60 | #include "key.h" | 60 | #include "key.h" |
61 | #include "hostfile.h" | 61 | #include "hostfile.h" |
62 | #include "authfile.h" | ||
62 | #include "auth.h" | 63 | #include "auth.h" |
63 | #include "auth-options.h" | 64 | #include "auth-options.h" |
64 | #include "canohost.h" | 65 | #include "canohost.h" |
@@ -379,8 +380,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host, | |||
379 | user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); | 380 | user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); |
380 | if (options.strict_modes && | 381 | if (options.strict_modes && |
381 | (stat(user_hostfile, &st) == 0) && | 382 | (stat(user_hostfile, &st) == 0) && |
382 | ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | 383 | !secure_permissions(&st, pw->pw_uid)) { |
383 | (st.st_mode & 022) != 0)) { | ||
384 | logit("Authentication refused for %.100s: " | 384 | logit("Authentication refused for %.100s: " |
385 | "bad owner or modes for %.200s", | 385 | "bad owner or modes for %.200s", |
386 | pw->pw_name, user_hostfile); | 386 | pw->pw_name, user_hostfile); |
@@ -441,8 +441,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, | |||
441 | 441 | ||
442 | /* check the open file to avoid races */ | 442 | /* check the open file to avoid races */ |
443 | if (fstat(fileno(f), &st) < 0 || | 443 | if (fstat(fileno(f), &st) < 0 || |
444 | (st.st_uid != 0 && st.st_uid != uid) || | 444 | !secure_permissions(&st, uid)) { |
445 | (st.st_mode & 022) != 0) { | ||
446 | snprintf(err, errlen, "bad ownership or modes for file %s", | 445 | snprintf(err, errlen, "bad ownership or modes for file %s", |
447 | buf); | 446 | buf); |
448 | return -1; | 447 | return -1; |
@@ -457,8 +456,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, | |||
457 | strlcpy(buf, cp, sizeof(buf)); | 456 | strlcpy(buf, cp, sizeof(buf)); |
458 | 457 | ||
459 | if (stat(buf, &st) < 0 || | 458 | if (stat(buf, &st) < 0 || |
460 | (st.st_uid != 0 && st.st_uid != uid) || | 459 | !secure_permissions(&st, uid)) { |
461 | (st.st_mode & 022) != 0) { | ||
462 | snprintf(err, errlen, | 460 | snprintf(err, errlen, |
463 | "bad ownership or modes for directory %s", buf); | 461 | "bad ownership or modes for directory %s", buf); |
464 | return -1; | 462 | return -1; |
@@ -606,10 +604,34 @@ getpwnamallow(const char *user) | |||
606 | 604 | ||
607 | /* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */ | 605 | /* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */ |
608 | int | 606 | int |
609 | auth_key_is_revoked(Key *key) | 607 | auth_key_is_revoked(Key *key, int hostkey) |
610 | { | 608 | { |
611 | char *key_fp; | 609 | char *key_fp; |
612 | 610 | ||
611 | if (blacklisted_key(key, &key_fp) == 1) { | ||
612 | if (options.permit_blacklisted_keys) { | ||
613 | if (hostkey) | ||
614 | error("Host key %s blacklisted (see " | ||
615 | "ssh-vulnkey(1)); continuing anyway", | ||
616 | key_fp); | ||
617 | else | ||
618 | logit("Public key %s from %s blacklisted (see " | ||
619 | "ssh-vulnkey(1)); continuing anyway", | ||
620 | key_fp, get_remote_ipaddr()); | ||
621 | xfree(key_fp); | ||
622 | } else { | ||
623 | if (hostkey) | ||
624 | error("Host key %s blacklisted (see " | ||
625 | "ssh-vulnkey(1))", key_fp); | ||
626 | else | ||
627 | logit("Public key %s from %s blacklisted (see " | ||
628 | "ssh-vulnkey(1))", | ||
629 | key_fp, get_remote_ipaddr()); | ||
630 | xfree(key_fp); | ||
631 | return 1; | ||
632 | } | ||
633 | } | ||
634 | |||
613 | if (options.revoked_keys_file == NULL) | 635 | if (options.revoked_keys_file == NULL) |
614 | return 0; | 636 | return 0; |
615 | 637 | ||