From 58b391b1bdaaea1dc7d8e65e1d3549d16bc323f4 Mon Sep 17 00:00:00 2001 From: Ben Lindstrom Date: Fri, 22 Mar 2002 03:21:16 +0000 Subject: [PATCH] - markus@cvs.openbsd.org 2002/03/21 10:21:20 [ssh-add.c] ignore errors for nonexisting default keys in ssh-add, fixes http://bugzilla.mindrot.org/show_bug.cgi?id=158 Last patch was SUPPOSE to be: - stevesk@cvs.openbsd.org 2002/03/20 21:08:08 [sshd.c] strerror() on chdir() fail; ok provos@ But it got co-mingled. Flog me at will. --- ChangeLog | 5 ++++- ssh-add.c | 10 +++++++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index 030ef5a61..307e20e14 100644 --- a/ChangeLog +++ b/ChangeLog @@ -104,6 +104,9 @@ [servconf.c servconf.h ssh.h sshd.c] for unprivileged user, group do: pw=getpwnam(SSH_PRIVSEP_USER); do_setusercontext(pw). ok provos@ + - stevesk@cvs.openbsd.org 2002/03/20 21:08:08 + [sshd.c] + strerror() on chdir() fail; ok provos@ - markus@cvs.openbsd.org 2002/03/21 10:21:20 [ssh-add.c] ignore errors for nonexisting default keys in ssh-add, @@ -7954,4 +7957,4 @@ - Wrote replacements for strlcpy and mkdtemp - Released 1.0pre1 -$Id: ChangeLog,v 1.1955 2002/03/22 03:14:45 mouring Exp $ +$Id: ChangeLog,v 1.1956 2002/03/22 03:21:16 mouring Exp $ diff --git a/ssh-add.c b/ssh-add.c index 8ef9702f6..baf2b3de7 100644 --- a/ssh-add.c +++ b/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 @@ -310,6 +310,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", @@ -321,9 +323,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)