[BACK]Return to ssh-add.c CVS log [TXT][DIR] Up to [local] / src / usr.bin / ssh

Diff for /src/usr.bin/ssh/ssh-add.c between version 1.130 and 1.131

version 1.130, 2017/05/04 06:10:57 version 1.131, 2017/05/05 10:42:49
Line 354 
Line 354 
 list_identities(int agent_fd, int do_fp)  list_identities(int agent_fd, int do_fp)
 {  {
         char *fp;          char *fp;
         int r, had_identities = 0;          int r;
         struct ssh_identitylist *idlist;          struct ssh_identitylist *idlist;
         size_t i;          size_t i;
         int version = 2;  
   
         for (; version <= 2; version++) {          if ((r = ssh_fetch_identitylist(agent_fd, &idlist)) != 0) {
                 if ((r = ssh_fetch_identitylist(agent_fd, version,                  if (r != SSH_ERR_AGENT_NO_IDENTITIES)
                     &idlist)) != 0) {                          fprintf(stderr, "error fetching identities: %s\n",
                         if (r != SSH_ERR_AGENT_NO_IDENTITIES)                              ssh_err(r));
                                 fprintf(stderr, "error fetching identities for "                  else
                                     "protocol %d: %s\n", version, ssh_err(r));                          printf("The agent has no identities.\n");
                         continue;                  return -1;
                 }          }
                 for (i = 0; i < idlist->nkeys; i++) {          for (i = 0; i < idlist->nkeys; i++) {
                         had_identities = 1;                  if (do_fp) {
                         if (do_fp) {                          fp = sshkey_fingerprint(idlist->keys[i],
                                 fp = sshkey_fingerprint(idlist->keys[i],                              fingerprint_hash, SSH_FP_DEFAULT);
                                     fingerprint_hash, SSH_FP_DEFAULT);                          printf("%u %s %s (%s)\n", sshkey_size(idlist->keys[i]),
                                 printf("%u %s %s (%s)\n",                              fp == NULL ? "(null)" : fp, idlist->comments[i],
                                     sshkey_size(idlist->keys[i]),                              sshkey_type(idlist->keys[i]));
                                     fp == NULL ? "(null)" : fp,                          free(fp);
                                     idlist->comments[i],                  } else {
                                     sshkey_type(idlist->keys[i]));                          if ((r = sshkey_write(idlist->keys[i], stdout)) != 0) {
                                 free(fp);                                  fprintf(stderr, "sshkey_write: %s\n",
                         } else {                                      ssh_err(r));
                                 if ((r = sshkey_write(idlist->keys[i],                                  continue;
                                     stdout)) != 0) {  
                                         fprintf(stderr, "sshkey_write: %s\n",  
                                             ssh_err(r));  
                                         continue;  
                                 }  
                                 fprintf(stdout, " %s\n", idlist->comments[i]);  
                         }                          }
                           fprintf(stdout, " %s\n", idlist->comments[i]);
                 }                  }
                 ssh_free_identitylist(idlist);  
         }          }
         if (!had_identities) {          ssh_free_identitylist(idlist);
                 printf("The agent has no identities.\n");  
                 return -1;  
         }  
         return 0;          return 0;
 }  }
   

Legend:
Removed from v.1.130  
changed lines
  Added in v.1.131