summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2014-02-09 16:10:02 +0000
committerColin Watson <cjwatson@debian.org>2017-03-29 01:39:47 +0100
commite08f96cf1105a3ee9a23de7102d593443e031e0c (patch)
tree9c93015f3103621c06f793f2b35e040c08355fd4
parent1e06dfb99d3a59ef0b0a804ed1c2a590b3fab71c (diff)
Quieten logs when multiple from= restrictions are used
Bug-Debian: http://bugs.debian.org/630606 Forwarded: no Last-Update: 2013-09-14 Patch-Name: auth-log-verbosity.patch
-rw-r--r--auth-options.c35
-rw-r--r--auth-options.h1
-rw-r--r--auth2-pubkey.c3
3 files changed, 30 insertions, 9 deletions
diff --git a/auth-options.c b/auth-options.c
index 57b49f7fd..7eb87b352 100644
--- a/auth-options.c
+++ b/auth-options.c
@@ -59,9 +59,20 @@ int forced_tun_device = -1;
59/* "principals=" option. */ 59/* "principals=" option. */
60char *authorized_principals = NULL; 60char *authorized_principals = NULL;
61 61
62/* Throttle log messages. */
63int logged_from_hostip = 0;
64int logged_cert_hostip = 0;
65
62extern ServerOptions options; 66extern ServerOptions options;
63 67
64void 68void
69auth_start_parse_options(void)
70{
71 logged_from_hostip = 0;
72 logged_cert_hostip = 0;
73}
74
75void
65auth_clear_options(void) 76auth_clear_options(void)
66{ 77{
67 no_agent_forwarding_flag = 0; 78 no_agent_forwarding_flag = 0;
@@ -316,10 +327,13 @@ auth_parse_options(struct passwd *pw, char *opts, char *file, u_long linenum)
316 /* FALLTHROUGH */ 327 /* FALLTHROUGH */
317 case 0: 328 case 0:
318 free(patterns); 329 free(patterns);
319 logit("Authentication tried for %.100s with " 330 if (!logged_from_hostip) {
320 "correct key but not from a permitted " 331 logit("Authentication tried for %.100s with "
321 "host (host=%.200s, ip=%.200s).", 332 "correct key but not from a permitted "
322 pw->pw_name, remote_host, remote_ip); 333 "host (host=%.200s, ip=%.200s).",
334 pw->pw_name, remote_host, remote_ip);
335 logged_from_hostip = 1;
336 }
323 auth_debug_add("Your host '%.200s' is not " 337 auth_debug_add("Your host '%.200s' is not "
324 "permitted to use this key for login.", 338 "permitted to use this key for login.",
325 remote_host); 339 remote_host);
@@ -543,11 +557,14 @@ parse_option_list(struct sshbuf *oblob, struct passwd *pw,
543 break; 557 break;
544 case 0: 558 case 0:
545 /* no match */ 559 /* no match */
546 logit("Authentication tried for %.100s " 560 if (!logged_cert_hostip) {
547 "with valid certificate but not " 561 logit("Authentication tried for %.100s "
548 "from a permitted host " 562 "with valid certificate but not "
549 "(ip=%.200s).", pw->pw_name, 563 "from a permitted host "
550 remote_ip); 564 "(ip=%.200s).", pw->pw_name,
565 remote_ip);
566 logged_cert_hostip = 1;
567 }
551 auth_debug_add("Your address '%.200s' " 568 auth_debug_add("Your address '%.200s' "
552 "is not permitted to use this " 569 "is not permitted to use this "
553 "certificate for login.", 570 "certificate for login.",
diff --git a/auth-options.h b/auth-options.h
index 52cbb42aa..823552761 100644
--- a/auth-options.h
+++ b/auth-options.h
@@ -33,6 +33,7 @@ extern int forced_tun_device;
33extern int key_is_cert_authority; 33extern int key_is_cert_authority;
34extern char *authorized_principals; 34extern char *authorized_principals;
35 35
36void auth_start_parse_options(void);
36int auth_parse_options(struct passwd *, char *, char *, u_long); 37int auth_parse_options(struct passwd *, char *, char *, u_long);
37void auth_clear_options(void); 38void auth_clear_options(void);
38int auth_cert_options(struct sshkey *, struct passwd *, const char **); 39int auth_cert_options(struct sshkey *, struct passwd *, const char **);
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index 3e5706f4d..6dc5076ef 100644
--- a/auth2-pubkey.c
+++ b/auth2-pubkey.c
@@ -566,6 +566,7 @@ process_principals(FILE *f, char *file, struct passwd *pw,
566 u_long linenum = 0; 566 u_long linenum = 0;
567 u_int i, found_principal = 0; 567 u_int i, found_principal = 0;
568 568
569 auth_start_parse_options();
569 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { 570 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
570 /* Always consume entire input */ 571 /* Always consume entire input */
571 if (found_principal) 572 if (found_principal)
@@ -771,6 +772,7 @@ check_authkeys_file(FILE *f, char *file, Key* key, struct passwd *pw)
771 found_key = 0; 772 found_key = 0;
772 773
773 found = NULL; 774 found = NULL;
775 auth_start_parse_options();
774 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { 776 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
775 char *cp, *key_options = NULL, *fp = NULL; 777 char *cp, *key_options = NULL, *fp = NULL;
776 const char *reason = NULL; 778 const char *reason = NULL;
@@ -921,6 +923,7 @@ user_cert_trusted_ca(struct passwd *pw, Key *key)
921 if (key_cert_check_authority(key, 0, 1, 923 if (key_cert_check_authority(key, 0, 1,
922 use_authorized_principals ? NULL : pw->pw_name, &reason) != 0) 924 use_authorized_principals ? NULL : pw->pw_name, &reason) != 0)
923 goto fail_reason; 925 goto fail_reason;
926 auth_start_parse_options();
924 if (auth_cert_options(key, pw, &reason) != 0) 927 if (auth_cert_options(key, pw, &reason) != 0)
925 goto fail_reason; 928 goto fail_reason;
926 929