diff options
author | halex@openbsd.org <halex@openbsd.org> | 2015-02-21 21:46:57 +0000 |
---|---|---|
committer | Damien Miller <djm@mindrot.org> | 2015-02-22 09:04:58 +1100 |
commit | 1797f49b1ba31e8700231cd6b1d512d80bb50d2c (patch) | |
tree | b1f21c886e527e1fc81ff251cd30ea0d3b016157 | |
parent | 7faaa32da83a609059d95dbfcb0649fdb04caaf6 (diff) |
upstream commit
make "ssh-add -d" properly remove a corresponding
certificate, and also not whine and fail if there is none
ok djm@
-rw-r--r-- | ssh-add.c | 14 |
1 files changed, 10 insertions, 4 deletions
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: ssh-add.c,v 1.119 2015/02/03 00:34:14 halex Exp $ */ | 1 | /* $OpenBSD: ssh-add.c,v 1.120 2015/02/21 21:46:57 halex Exp $ */ |
2 | /* | 2 | /* |
3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> | 3 | * Author: Tatu Ylonen <ylo@cs.hut.fi> |
4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland | 4 | * Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland |
@@ -128,18 +128,24 @@ delete_file(int agent_fd, const char *filename, int key_only) | |||
128 | free(comment); | 128 | free(comment); |
129 | comment = NULL; | 129 | comment = NULL; |
130 | xasprintf(&certpath, "%s-cert.pub", filename); | 130 | xasprintf(&certpath, "%s-cert.pub", filename); |
131 | if ((r = sshkey_load_public(certpath, &cert, &comment)) == 0) | 131 | if ((r = sshkey_load_public(certpath, &cert, &comment)) != 0) { |
132 | if (r != SSH_ERR_SYSTEM_ERROR || errno != ENOENT) | ||
133 | error("Failed to load certificate \"%s\": %s", | ||
134 | certpath, ssh_err(r)); | ||
132 | goto out; | 135 | goto out; |
136 | } | ||
137 | |||
133 | if (!sshkey_equal_public(cert, public)) | 138 | if (!sshkey_equal_public(cert, public)) |
134 | fatal("Certificate %s does not match private key %s", | 139 | fatal("Certificate %s does not match private key %s", |
135 | certpath, filename); | 140 | certpath, filename); |
136 | 141 | ||
137 | if (ssh_remove_identity(agent_fd, cert)) { | 142 | if ((r = ssh_remove_identity(agent_fd, cert)) == 0) { |
138 | fprintf(stderr, "Identity removed: %s (%s)\n", certpath, | 143 | fprintf(stderr, "Identity removed: %s (%s)\n", certpath, |
139 | comment); | 144 | comment); |
140 | ret = 0; | 145 | ret = 0; |
141 | } else | 146 | } else |
142 | fprintf(stderr, "Could not remove identity: %s\n", certpath); | 147 | fprintf(stderr, "Could not remove identity \"%s\": %s\n", |
148 | certpath, ssh_err(r)); | ||
143 | 149 | ||
144 | out: | 150 | out: |
145 | if (cert != NULL) | 151 | if (cert != NULL) |