diff -uprk.orig openssh-3.6.1p1.orig/ssh-add.c openssh-3.6.1p1/ssh-add.c --- openssh-3.6.1p1.orig/ssh-add.c 2003-03-10 03:21:18 +0300 +++ openssh-3.6.1p1/ssh-add.c 2003-04-11 18:53:41 +0400 @@ -131,16 +131,11 @@ delete_all(AuthenticationConnection *ac) static int add_file(AuthenticationConnection *ac, const char *filename) { - struct stat st; Key *private; char *comment = NULL; char msg[1024]; int ret = -1; - if (stat(filename, &st) < 0) { - perror(filename); - return -1; - } /* At first, try empty passphrase */ private = key_load_private(filename, "", &comment); if (comment == NULL) @@ -278,8 +273,20 @@ lock_agent(AuthenticationConnection *ac, } static int +file_not_found(const char *fname) +{ + struct stat st; + return stat(fname, &st); +} + +static int do_file(AuthenticationConnection *ac, int deleting, char *file) { + if (file_not_found(file)) { + perror(file); + return -1; + } + if (deleting) { if (delete_file(ac, file) == -1) return -1; @@ -385,7 +392,6 @@ main(int argc, char **argv) if (argc == 0) { char buf[MAXPATHLEN]; struct passwd *pw; - struct stat st; int count = 0; if ((pw = getpwuid(getuid())) == NULL) { @@ -398,7 +404,7 @@ main(int argc, char **argv) for(i = 0; default_files[i]; i++) { snprintf(buf, sizeof(buf), "%s/%s", pw->pw_dir, default_files[i]); - if (stat(buf, &st) < 0) + if (file_not_found(buf)) continue; if (do_file(ac, deleting, buf) == -1) ret = 1;