summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2014-02-09 16:10:02 +0000
committerColin Watson <cjwatson@debian.org>2016-08-07 12:18:43 +0100
commitb4b79ae5a16f73426b54c6394a29b2b49da4dc16 (patch)
treeb2bf8e0ef9f910938b7c081b345b44680b667508
parent9d9a37bb0c2d7546253ff2b0b67e314d8475bfc7 (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--auth-rsa.c2
-rw-r--r--auth2-pubkey.c3
4 files changed, 32 insertions, 9 deletions
diff --git a/auth-options.c b/auth-options.c
index b399b91e3..a9d9a81cb 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 34852e5c0..1653855ee 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 *); 39int auth_cert_options(struct sshkey *, struct passwd *);
diff --git a/auth-rsa.c b/auth-rsa.c
index cbd971be1..4cf2163c7 100644
--- a/auth-rsa.c
+++ b/auth-rsa.c
@@ -181,6 +181,8 @@ rsa_key_allowed_in_file(struct passwd *pw, char *file,
181 if ((f = auth_openkeyfile(file, pw, options.strict_modes)) == NULL) 181 if ((f = auth_openkeyfile(file, pw, options.strict_modes)) == NULL)
182 return 0; 182 return 0;
183 183
184 auth_start_parse_options();
185
184 /* 186 /*
185 * Go though the accepted keys, looking for the current key. If 187 * Go though the accepted keys, looking for the current key. If
186 * found, perform a challenge-response dialog to verify that the 188 * found, perform a challenge-response dialog to verify that the
diff --git a/auth2-pubkey.c b/auth2-pubkey.c
index 41b34aed2..aace7ca15 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; 567 u_int i;
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 /* Skip leading whitespace. */ 571 /* Skip leading whitespace. */
571 for (cp = line; *cp == ' ' || *cp == '\t'; cp++) 572 for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
@@ -731,6 +732,7 @@ check_authkeys_file(FILE *f, char *file, Key* key, struct passwd *pw)
731 found_key = 0; 732 found_key = 0;
732 733
733 found = NULL; 734 found = NULL;
735 auth_start_parse_options();
734 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) { 736 while (read_keyfile_line(f, file, line, sizeof(line), &linenum) != -1) {
735 char *cp, *key_options = NULL; 737 char *cp, *key_options = NULL;
736 if (found != NULL) 738 if (found != NULL)
@@ -878,6 +880,7 @@ user_cert_trusted_ca(struct passwd *pw, Key *key)
878 if (key_cert_check_authority(key, 0, 1, 880 if (key_cert_check_authority(key, 0, 1,
879 use_authorized_principals ? NULL : pw->pw_name, &reason) != 0) 881 use_authorized_principals ? NULL : pw->pw_name, &reason) != 0)
880 goto fail_reason; 882 goto fail_reason;
883 auth_start_parse_options();
881 if (auth_cert_options(key, pw) != 0) 884 if (auth_cert_options(key, pw) != 0)
882 goto out; 885 goto out;
883 886