summaryrefslogtreecommitdiff
path: root/ssh-vulnkey.c
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2008-05-25 23:48:15 +0000
committerColin Watson <cjwatson@debian.org>2008-05-25 23:48:15 +0000
commit4df1cc4fe79d27706bdc628944ff2e80b8f91599 (patch)
tree1c86bb0665e6a801e79e924d2e73067d78243a3d /ssh-vulnkey.c
parentd61c655626e74e65dba34e4e9d5aa6616cc72f93 (diff)
Add -v (verbose) option to ssh-vulnkey, and don't print output for keys
that have a blacklist file but that are not listed unless in verbose mode (thanks, Hugh Daniel).
Diffstat (limited to 'ssh-vulnkey.c')
-rw-r--r--ssh-vulnkey.c19
1 files changed, 11 insertions, 8 deletions
diff --git a/ssh-vulnkey.c b/ssh-vulnkey.c
index f78615478..39c984db2 100644
--- a/ssh-vulnkey.c
+++ b/ssh-vulnkey.c
@@ -60,7 +60,7 @@ static char *default_files[] = {
60 NULL 60 NULL
61}; 61};
62 62
63static int quiet = 0; 63static int verbosity = 0;
64 64
65static void 65static void
66usage(void) 66usage(void)
@@ -74,12 +74,12 @@ usage(void)
74 74
75void 75void
76describe_key(const char *filename, u_long linenum, const char *msg, 76describe_key(const char *filename, u_long linenum, const char *msg,
77 const Key *key, const char *comment) 77 const Key *key, const char *comment, int min_verbosity)
78{ 78{
79 char *fp; 79 char *fp;
80 80
81 fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX); 81 fp = key_fingerprint(key, SSH_FP_MD5, SSH_FP_HEX);
82 if (!quiet) 82 if (verbosity >= min_verbosity)
83 printf("%s:%lu: %s: %u %s %s\n", filename, linenum, msg, 83 printf("%s:%lu: %s: %u %s %s\n", filename, linenum, msg,
84 key_size(key), fp, comment); 84 key_size(key), fp, comment);
85 xfree(fp); 85 xfree(fp);
@@ -101,14 +101,14 @@ do_key(const char *filename, u_long linenum,
101 blacklist_status = blacklisted_key(public); 101 blacklist_status = blacklisted_key(public);
102 if (blacklist_status == -1) 102 if (blacklist_status == -1)
103 describe_key(filename, linenum, 103 describe_key(filename, linenum,
104 "Unknown (no blacklist information)", key, comment); 104 "Unknown (no blacklist information)", key, comment, 0);
105 else if (blacklist_status == 1) { 105 else if (blacklist_status == 1) {
106 describe_key(filename, linenum, 106 describe_key(filename, linenum,
107 "COMPROMISED", key, comment); 107 "COMPROMISED", key, comment, 0);
108 ret = 0; 108 ret = 0;
109 } else 109 } else
110 describe_key(filename, linenum, 110 describe_key(filename, linenum,
111 "Not blacklisted", key, comment); 111 "Not blacklisted", key, comment, 1);
112 112
113 key_free(public); 113 key_free(public);
114 114
@@ -289,13 +289,16 @@ main(int argc, char **argv)
289 init_rng(); 289 init_rng();
290 seed_rng(); 290 seed_rng();
291 291
292 while ((opt = getopt(argc, argv, "ahq")) != -1) { 292 while ((opt = getopt(argc, argv, "ahqv")) != -1) {
293 switch (opt) { 293 switch (opt) {
294 case 'a': 294 case 'a':
295 all_users = 1; 295 all_users = 1;
296 break; 296 break;
297 case 'q': 297 case 'q':
298 quiet = 1; 298 verbosity--;
299 break;
300 case 'v':
301 verbosity++;
299 break; 302 break;
300 case 'h': 303 case 'h':
301 default: 304 default: