summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2002-03-21 10:21:21 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2002-03-21 10:21:21 +0000
commit7423d27adc2289a3e3a495f3cfd1ad9cf4ef0144 (patch)
treeecb5ff2423856f7a069f064be17bb156cce932e2
parent0c94daf3293c97f449f4efd9decd12cb08a7e62a (diff)
ignore errors for nonexisting default keys in ssh-add,
fixes http://bugzilla.mindrot.org/show_bug.cgi?id=158
-rw-r--r--usr.bin/ssh/ssh-add.c10
1 files changed, 9 insertions, 1 deletions
diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c
index d483d135c7c..ce14e2e7a61 100644
--- a/usr.bin/ssh/ssh-add.c
+++ b/usr.bin/ssh/ssh-add.c
@@ -35,7 +35,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: ssh-add.c,v 1.51 2002/03/19 10:49:35 markus Exp $");
+RCSID("$OpenBSD: ssh-add.c,v 1.52 2002/03/21 10:21:20 markus Exp $");
#include <openssl/evp.h>
@@ -300,6 +300,8 @@ 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) {
fprintf(stderr, "No user found with uid %u\n",
@@ -311,9 +313,15 @@ 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)
+ continue;
if (do_file(ac, deleting, buf) == -1)
ret = 1;
+ else
+ count++;
}
+ if (count == 0)
+ ret = 1;
} else {
for(i = 0; i < argc; i++) {
if (do_file(ac, deleting, argv[i]) == -1)