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" |
@@ -391,8 +392,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host, | |||
391 | user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); | 392 | user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); |
392 | if (options.strict_modes && | 393 | if (options.strict_modes && |
393 | (stat(user_hostfile, &st) == 0) && | 394 | (stat(user_hostfile, &st) == 0) && |
394 | ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || | 395 | !secure_permissions(&st, pw->pw_uid)) { |
395 | (st.st_mode & 022) != 0)) { | ||
396 | logit("Authentication refused for %.100s: " | 396 | logit("Authentication refused for %.100s: " |
397 | "bad owner or modes for %.200s", | 397 | "bad owner or modes for %.200s", |
398 | pw->pw_name, user_hostfile); | 398 | pw->pw_name, user_hostfile); |
@@ -453,8 +453,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, | |||
453 | 453 | ||
454 | /* check the open file to avoid races */ | 454 | /* check the open file to avoid races */ |
455 | if (fstat(fileno(f), &st) < 0 || | 455 | if (fstat(fileno(f), &st) < 0 || |
456 | (st.st_uid != 0 && st.st_uid != uid) || | 456 | !secure_permissions(&st, uid)) { |
457 | (st.st_mode & 022) != 0) { | ||
458 | snprintf(err, errlen, "bad ownership or modes for file %s", | 457 | snprintf(err, errlen, "bad ownership or modes for file %s", |
459 | buf); | 458 | buf); |
460 | return -1; | 459 | return -1; |
@@ -470,8 +469,7 @@ secure_filename(FILE *f, const char *file, struct passwd *pw, | |||
470 | 469 | ||
471 | debug3("secure_filename: checking '%s'", buf); | 470 | debug3("secure_filename: checking '%s'", buf); |
472 | if (stat(buf, &st) < 0 || | 471 | if (stat(buf, &st) < 0 || |
473 | (st.st_uid != 0 && st.st_uid != uid) || | 472 | !secure_permissions(&st, uid)) { |
474 | (st.st_mode & 022) != 0) { | ||
475 | snprintf(err, errlen, | 473 | snprintf(err, errlen, |
476 | "bad ownership or modes for directory %s", buf); | 474 | "bad ownership or modes for directory %s", buf); |
477 | return -1; | 475 | return -1; |
@@ -621,10 +619,34 @@ getpwnamallow(const char *user) | |||
621 | 619 | ||
622 | /* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */ | 620 | /* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */ |
623 | int | 621 | int |
624 | auth_key_is_revoked(Key *key) | 622 | auth_key_is_revoked(Key *key, int hostkey) |
625 | { | 623 | { |
626 | char *key_fp; | 624 | char *key_fp; |
627 | 625 | ||
626 | if (blacklisted_key(key, &key_fp) == 1) { | ||
627 | if (options.permit_blacklisted_keys) { | ||
628 | if (hostkey) | ||
629 | error("Host key %s blacklisted (see " | ||
630 | "ssh-vulnkey(1)); continuing anyway", | ||
631 | key_fp); | ||
632 | else | ||
633 | logit("Public key %s from %s blacklisted (see " | ||
634 | "ssh-vulnkey(1)); continuing anyway", | ||
635 | key_fp, get_remote_ipaddr()); | ||
636 | xfree(key_fp); | ||
637 | } else { | ||
638 | if (hostkey) | ||
639 | error("Host key %s blacklisted (see " | ||
640 | "ssh-vulnkey(1))", key_fp); | ||
641 | else | ||
642 | logit("Public key %s from %s blacklisted (see " | ||
643 | "ssh-vulnkey(1))", | ||
644 | key_fp, get_remote_ipaddr()); | ||
645 | xfree(key_fp); | ||
646 | return 1; | ||
647 | } | ||
648 | } | ||
649 | |||
628 | if (options.revoked_keys_file == NULL) | 650 | if (options.revoked_keys_file == NULL) |
629 | return 0; | 651 | return 0; |
630 | 652 | ||