From b72566fab48ed4402abdd2f5e9aa4dd8d4ea58fb Mon Sep 17 00:00:00 2001 From: Florian Weimer Date: Wed, 14 May 2008 10:09:17 +0200 Subject: [PATCH] Print summary statistics at the end This way it's easier to spot if something went wrong. --- dowkd.in | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/dowkd.in b/dowkd.in index 6dcc84d..c94fff9 100644 --- a/dowkd.in +++ b/dowkd.in @@ -96,9 +96,18 @@ sub safe_backtick (@) { } } +my $keys_found = 0; +my $keys_vulnerable = 0; + +sub print_stats () { + print STDERR "summary: keys found: $keys_found, weak keys: $keys_vulnerable\n"; +} + sub check_hash ($$) { my ($name, $hash) = @_; + ++$keys_found; if (exists $db{$hash}) { + ++$keys_vulnerable; print "$name: weak key\n"; } } @@ -217,6 +226,8 @@ sub from_user ($) { $quota,$comment,$gcos,$dir,$shell,$expire) = getpwnam($user); my $file = "$dir/.ssh/authorized_keys"; from_ssh_auth_file $file if -r $file; + $file = "$dir/.ssh/authorized_keys2"; + from_ssh_auth_file $file if -r $file; $file = "$dir/.ssh/id_rsa.pub"; from_ssh_key_file $file if -r $file; $file = "$dir/.ssh/id_dsa.pub"; @@ -253,9 +264,11 @@ if (@ARGV) { } } elsif ($cmd eq 'help') { help; + exit 0; } else { die "error: invalid command, use \"help\" to get help\n"; } + print_stats; } else { help; exit 1; -- 2.11.4.GIT