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 9a36f1dac..7f6c6c8ad 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"
@@ -407,8 +408,7 @@ check_key_in_hostfiles(struct passwd *pw, Key *key, const char *host,
407 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid); 408 user_hostfile = tilde_expand_filename(userfile, pw->pw_uid);
408 if (options.strict_modes && 409 if (options.strict_modes &&
409 (stat(user_hostfile, &st) == 0) && 410 (stat(user_hostfile, &st) == 0) &&
410 ((st.st_uid != 0 && st.st_uid != pw->pw_uid) || 411 !secure_permissions(&st, pw->pw_uid)) {
411 (st.st_mode & 022) != 0)) {
412 logit("Authentication refused for %.100s: " 412 logit("Authentication refused for %.100s: "
413 "bad owner or modes for %.200s", 413 "bad owner or modes for %.200s",
414 pw->pw_name, user_hostfile); 414 pw->pw_name, user_hostfile);
@@ -470,8 +470,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
470 snprintf(err, errlen, "%s is not a regular file", buf); 470 snprintf(err, errlen, "%s is not a regular file", buf);
471 return -1; 471 return -1;
472 } 472 }
473 if ((!platform_sys_dir_uid(stp->st_uid) && stp->st_uid != uid) || 473 if (!secure_permissions(stp, uid)) {
474 (stp->st_mode & 022) != 0) {
475 snprintf(err, errlen, "bad ownership or modes for file %s", 474 snprintf(err, errlen, "bad ownership or modes for file %s",
476 buf); 475 buf);
477 return -1; 476 return -1;
@@ -486,8 +485,7 @@ auth_secure_path(const char *name, struct stat *stp, const char *pw_dir,
486 strlcpy(buf, cp, sizeof(buf)); 485 strlcpy(buf, cp, sizeof(buf));
487 486
488 if (stat(buf, &st) < 0 || 487 if (stat(buf, &st) < 0 ||
489 (!platform_sys_dir_uid(st.st_uid) && st.st_uid != uid) || 488 !secure_permissions(&st, uid)) {
490 (st.st_mode & 022) != 0) {
491 snprintf(err, errlen, 489 snprintf(err, errlen,
492 "bad ownership or modes for directory %s", buf); 490 "bad ownership or modes for directory %s", buf);
493 return -1; 491 return -1;
@@ -657,10 +655,34 @@ getpwnamallow(const char *user)
657 655
658/* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */ 656/* Returns 1 if key is revoked by revoked_keys_file, 0 otherwise */
659int 657int
660auth_key_is_revoked(Key *key) 658auth_key_is_revoked(Key *key, int hostkey)
661{ 659{
662 char *key_fp; 660 char *key_fp;
663 661
662 if (blacklisted_key(key, &key_fp) == 1) {
663 if (options.permit_blacklisted_keys) {
664 if (hostkey)
665 error("Host key %s blacklisted (see "
666 "ssh-vulnkey(1)); continuing anyway",
667 key_fp);
668 else
669 logit("Public key %s from %s blacklisted (see "
670 "ssh-vulnkey(1)); continuing anyway",
671 key_fp, get_remote_ipaddr());
672 free(key_fp);
673 } else {
674 if (hostkey)
675 error("Host key %s blacklisted (see "
676 "ssh-vulnkey(1))", key_fp);
677 else
678 logit("Public key %s from %s blacklisted (see "
679 "ssh-vulnkey(1))",
680 key_fp, get_remote_ipaddr());
681 free(key_fp);
682 return 1;
683 }
684 }
685
664 if (options.revoked_keys_file == NULL) 686 if (options.revoked_keys_file == NULL)
665 return 0; 687 return 0;
666 switch (ssh_krl_file_contains_key(options.revoked_keys_file, key)) { 688 switch (ssh_krl_file_contains_key(options.revoked_keys_file, key)) {