summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorColin Watson <cjwatson@debian.org>2008-05-26 00:44:44 +0000
committerColin Watson <cjwatson@debian.org>2008-05-26 00:44:44 +0000
commitb44bd674681c6ea012f9fcab88a72b344ba7962a (patch)
treeefd58d1fa25cd03b690321192149e13f851d2af6
parentf838b015ce4ee71935727c49d5722361e572666f (diff)
Fix error output if ssh-vulnkey fails to read key files, with the
exception of host keys unless -a was given (thanks, Hugh Daniel).
-rw-r--r--debian/changelog2
-rw-r--r--ssh-vulnkey.c16
2 files changed, 12 insertions, 6 deletions
diff --git a/debian/changelog b/debian/changelog
index c094f6f63..1df45586f 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -46,6 +46,8 @@ openssh (1:4.7p1-11) UNRELEASED; urgency=low
46 (thanks, Hugh Daniel). 46 (thanks, Hugh Daniel).
47 * Document ssh-vulnkey key status descriptions (thanks, Hugh Daniel). 47 * Document ssh-vulnkey key status descriptions (thanks, Hugh Daniel).
48 * Add key type to ssh-vulnkey output. 48 * Add key type to ssh-vulnkey output.
49 * Fix error output if ssh-vulnkey fails to read key files, with the
50 exception of host keys unless -a was given (thanks, Hugh Daniel).
49 51
50 -- Colin Watson <cjwatson@debian.org> Sat, 17 May 2008 08:48:45 +0200 52 -- Colin Watson <cjwatson@debian.org> Sat, 17 May 2008 08:48:45 +0200
51 53
diff --git a/ssh-vulnkey.c b/ssh-vulnkey.c
index 9b64953b6..9616ecfe8 100644
--- a/ssh-vulnkey.c
+++ b/ssh-vulnkey.c
@@ -27,6 +27,7 @@
27#include <sys/types.h> 27#include <sys/types.h>
28#include <sys/stat.h> 28#include <sys/stat.h>
29 29
30#include <errno.h>
30#include <string.h> 31#include <string.h>
31#include <stdio.h> 32#include <stdio.h>
32#include <fcntl.h> 33#include <fcntl.h>
@@ -135,7 +136,9 @@ do_filename(const char *filename, int quiet_open)
135 */ 136 */
136 137
137 if (strcmp(filename, "-") != 0) { 138 if (strcmp(filename, "-") != 0) {
139 int save_errno;
138 f = fopen(filename, "r"); 140 f = fopen(filename, "r");
141 save_errno = errno;
139 if (!f) { 142 if (!f) {
140 char pubfile[MAXPATHLEN]; 143 char pubfile[MAXPATHLEN];
141 if (strlcpy(pubfile, filename, sizeof pubfile) < 144 if (strlcpy(pubfile, filename, sizeof pubfile) <
@@ -144,6 +147,7 @@ do_filename(const char *filename, int quiet_open)
144 sizeof(pubfile)) 147 sizeof(pubfile))
145 f = fopen(pubfile, "r"); 148 f = fopen(pubfile, "r");
146 } 149 }
150 errno = save_errno; /* earlier errno is more useful */
147 if (!f) { 151 if (!f) {
148 if (!quiet_open) 152 if (!quiet_open)
149 perror(filename); 153 perror(filename);
@@ -237,16 +241,16 @@ do_filename(const char *filename, int quiet_open)
237} 241}
238 242
239int 243int
240do_host(void) 244do_host(int quiet_open)
241{ 245{
242 int i; 246 int i;
243 struct stat st; 247 struct stat st;
244 int ret = 1; 248 int ret = 1;
245 249
246 for (i = 0; default_host_files[i]; i++) { 250 for (i = 0; default_host_files[i]; i++) {
247 if (stat(default_host_files[i], &st) < 0) 251 if (stat(default_host_files[i], &st) < 0 && errno == ENOENT)
248 continue; 252 continue;
249 if (!do_filename(default_host_files[i], 1)) 253 if (!do_filename(default_host_files[i], quiet_open))
250 ret = 0; 254 ret = 0;
251 } 255 }
252 256
@@ -263,7 +267,7 @@ do_user(const char *dir)
263 267
264 for (i = 0; default_files[i]; i++) { 268 for (i = 0; default_files[i]; i++) {
265 snprintf(buf, sizeof(buf), "%s/%s", dir, default_files[i]); 269 snprintf(buf, sizeof(buf), "%s/%s", dir, default_files[i]);
266 if (stat(buf, &st) < 0) 270 if (stat(buf, &st) < 0 && errno == ENOENT)
267 continue; 271 continue;
268 if (!do_filename(buf, 0)) 272 if (!do_filename(buf, 0))
269 ret = 0; 273 ret = 0;
@@ -313,7 +317,7 @@ main(int argc, char **argv)
313 if (all_users) { 317 if (all_users) {
314 struct passwd *pw; 318 struct passwd *pw;
315 319
316 if (!do_host()) 320 if (!do_host(0))
317 ret = 0; 321 ret = 0;
318 322
319 while ((pw = getpwent()) != NULL) { 323 while ((pw = getpwent()) != NULL) {
@@ -325,7 +329,7 @@ main(int argc, char **argv)
325 } else if (optind == argc) { 329 } else if (optind == argc) {
326 struct passwd *pw; 330 struct passwd *pw;
327 331
328 if (!do_host()) 332 if (!do_host(1))
329 ret = 0; 333 ret = 0;
330 334
331 if ((pw = getpwuid(getuid())) == NULL) 335 if ((pw = getpwuid(getuid())) == NULL)