summaryrefslogtreecommitdiff
path: root/ssh-add.c
diff options
context:
space:
mode:
authornaddy@openbsd.org <naddy@openbsd.org>2017-05-05 10:42:49 +0000
committerDamien Miller <djm@mindrot.org>2017-05-08 09:18:27 +1000
commit3e371bd2124427403971db853fb2e36ce789b6fd (patch)
treed05946a4ef052a51cb1c5f867669961e661bbdb0 /ssh-add.c
parent2e9c324b3a7f15c092d118c2ac9490939f6228fd (diff)
upstream commit
more simplification and removal of SSHv1-related code; ok djm@ Upstream-ID: d2f041aa0b79c0ebd98c68a01e5a0bfab2cf3b55
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 5f62420f9..a1e0d464b 100644
--- a/ssh-add.c
+++ b/ssh-add.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: ssh-add.c,v 1.130 2017/05/04 06:10:57 djm Exp $ */ 1/* $OpenBSD: ssh-add.c,v 1.131 2017/05/05 10:42:49 naddy 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
@@ -362,46 +362,36 @@ static int
362list_identities(int agent_fd, int do_fp) 362list_identities(int agent_fd, int do_fp)
363{ 363{
364 char *fp; 364 char *fp;
365 int r, had_identities = 0; 365 int r;
366 struct ssh_identitylist *idlist; 366 struct ssh_identitylist *idlist;
367 size_t i; 367 size_t i;
368 int version = 2; 368
369 369 if ((r = ssh_fetch_identitylist(agent_fd, &idlist)) != 0) {
370 for (; version <= 2; version++) { 370 if (r != SSH_ERR_AGENT_NO_IDENTITIES)
371 if ((r = ssh_fetch_identitylist(agent_fd, version, 371 fprintf(stderr, "error fetching identities: %s\n",
372 &idlist)) != 0) { 372 ssh_err(r));
373 if (r != SSH_ERR_AGENT_NO_IDENTITIES) 373 else
374 fprintf(stderr, "error fetching identities for " 374 printf("The agent has no identities.\n");
375 "protocol %d: %s\n", version, ssh_err(r)); 375 return -1;
376 continue; 376 }
377 } 377 for (i = 0; i < idlist->nkeys; i++) {
378 for (i = 0; i < idlist->nkeys; i++) { 378 if (do_fp) {
379 had_identities = 1; 379 fp = sshkey_fingerprint(idlist->keys[i],
380 if (do_fp) { 380 fingerprint_hash, SSH_FP_DEFAULT);
381 fp = sshkey_fingerprint(idlist->keys[i], 381 printf("%u %s %s (%s)\n", sshkey_size(idlist->keys[i]),
382 fingerprint_hash, SSH_FP_DEFAULT); 382 fp == NULL ? "(null)" : fp, idlist->comments[i],
383 printf("%u %s %s (%s)\n", 383 sshkey_type(idlist->keys[i]));
384 sshkey_size(idlist->keys[i]), 384 free(fp);
385 fp == NULL ? "(null)" : fp, 385 } else {
386 idlist->comments[i], 386 if ((r = sshkey_write(idlist->keys[i], stdout)) != 0) {
387 sshkey_type(idlist->keys[i])); 387 fprintf(stderr, "sshkey_write: %s\n",
388 free(fp); 388 ssh_err(r));
389 } else { 389 continue;
390 if ((r = sshkey_write(idlist->keys[i],
391 stdout)) != 0) {
392 fprintf(stderr, "sshkey_write: %s\n",
393 ssh_err(r));
394 continue;
395 }
396 fprintf(stdout, " %s\n", idlist->comments[i]);
397 } 390 }
391 fprintf(stdout, " %s\n", idlist->comments[i]);
398 } 392 }
399 ssh_free_identitylist(idlist);
400 }
401 if (!had_identities) {
402 printf("The agent has no identities.\n");
403 return -1;
404 } 393 }
394 ssh_free_identitylist(idlist);
405 return 0; 395 return 0;
406} 396}
407 397