diff options
author | 2015-02-21 21:46:57 +0000 | |
---|---|---|
committer | 2015-02-21 21:46:57 +0000 | |
commit | cc8d041475ab8bf56652274ae84886d4939fa73a (patch) | |
tree | da79ad9ad2a5e22901421b4bc363d5c044e57290 /usr.bin/ssh/ssh-add.c | |
parent | explain how tls_accept_socket works. (diff) | |
download | wireguard-openbsd-cc8d041475ab8bf56652274ae84886d4939fa73a.tar.xz wireguard-openbsd-cc8d041475ab8bf56652274ae84886d4939fa73a.zip |
make "ssh-add -d" properly remove a corresponding certificate, and also
not whine and fail if there is none
ok djm@
Diffstat (limited to 'usr.bin/ssh/ssh-add.c')
-rw-r--r-- | usr.bin/ssh/ssh-add.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/usr.bin/ssh/ssh-add.c b/usr.bin/ssh/ssh-add.c index 0e76c39975b..291b0e257b7 100644 --- a/usr.bin/ssh/ssh-add.c +++ b/usr.bin/ssh/ssh-add.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ssh-add.c,v 1.119 2015/02/03 00:34:14 halex Exp $ */ +/* $OpenBSD: ssh-add.c,v 1.120 2015/02/21 21:46:57 halex Exp $ */ /* * Author: Tatu Ylonen <ylo@cs.hut.fi> * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland @@ -120,18 +120,24 @@ delete_file(int agent_fd, const char *filename, int key_only) free(comment); comment = NULL; xasprintf(&certpath, "%s-cert.pub", filename); - if ((r = sshkey_load_public(certpath, &cert, &comment)) == 0) + if ((r = sshkey_load_public(certpath, &cert, &comment)) != 0) { + if (r != SSH_ERR_SYSTEM_ERROR || errno != ENOENT) + error("Failed to load certificate \"%s\": %s", + certpath, ssh_err(r)); goto out; + } + if (!sshkey_equal_public(cert, public)) fatal("Certificate %s does not match private key %s", certpath, filename); - if (ssh_remove_identity(agent_fd, cert)) { + if ((r = ssh_remove_identity(agent_fd, cert)) == 0) { fprintf(stderr, "Identity removed: %s (%s)\n", certpath, comment); ret = 0; } else - fprintf(stderr, "Could not remove identity: %s\n", certpath); + fprintf(stderr, "Could not remove identity \"%s\": %s\n", + certpath, ssh_err(r)); out: if (cert != NULL) |