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