summaryrefslogtreecommitdiffstats
path: root/ssh-add.c
diff options
context:
space:
mode:
Diffstat (limited to 'ssh-add.c')
-rw-r--r--ssh-add.c62
1 files changed, 26 insertions, 36 deletions
diff --git a/ssh-add.c b/ssh-add.c
index 5f62420f..a1e0d464 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ssh-add.c,v 1.130 2017/05/04 06:10:57 djm Exp $ */
+/* $OpenBSD: ssh-add.c,v 1.131 2017/05/05 10:42:49 naddy Exp $ */
/*
* Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@@ -362,46 +362,36 @@ static int
list_identities(int agent_fd, int do_fp)
{
char *fp;
- int r, had_identities = 0;
+ int r;
struct ssh_identitylist *idlist;
size_t i;
- int version = 2;
-
- for (; version <= 2; version++) {
- if ((r = ssh_fetch_identitylist(agent_fd, version,
- &idlist)) != 0) {
- if (r != SSH_ERR_AGENT_NO_IDENTITIES)
- fprintf(stderr, "error fetching identities for "
- "protocol %d: %s\n", version, ssh_err(r));
- continue;
- }
- for (i = 0; i < idlist->nkeys; i++) {
- had_identities = 1;
- if (do_fp) {
- fp = sshkey_fingerprint(idlist->keys[i],
- fingerprint_hash, SSH_FP_DEFAULT);
- printf("%u %s %s (%s)\n",
- sshkey_size(idlist->keys[i]),
- fp == NULL ? "(null)" : fp,
- idlist->comments[i],
- sshkey_type(idlist->keys[i]));
- free(fp);
- } else {
- if ((r = sshkey_write(idlist->keys[i],
- stdout)) != 0) {
- fprintf(stderr, "sshkey_write: %s\n",
- ssh_err(r));
- continue;
- }
- fprintf(stdout, " %s\n", idlist->comments[i]);
+
+ if ((r = ssh_fetch_identitylist(agent_fd, &idlist)) != 0) {
+ if (r != SSH_ERR_AGENT_NO_IDENTITIES)
+ fprintf(stderr, "error fetching identities: %s\n",
+ ssh_err(r));
+ else
+ printf("The agent has no identities.\n");
+ return -1;
+ }
+ for (i = 0; i < idlist->nkeys; i++) {
+ if (do_fp) {
+ fp = sshkey_fingerprint(idlist->keys[i],
+ fingerprint_hash, SSH_FP_DEFAULT);
+ printf("%u %s %s (%s)\n", sshkey_size(idlist->keys[i]),
+ fp == NULL ? "(null)" : fp, idlist->comments[i],
+ sshkey_type(idlist->keys[i]));
+ free(fp);
+ } else {
+ if ((r = sshkey_write(idlist->keys[i], stdout)) != 0) {
+ fprintf(stderr, "sshkey_write: %s\n",
+ ssh_err(r));
+ continue;
}
+ fprintf(stdout, " %s\n", idlist->comments[i]);
}
- ssh_free_identitylist(idlist);
- }
- if (!had_identities) {
- printf("The agent has no identities.\n");
- return -1;
}
+ ssh_free_identitylist(idlist);
return 0;
}