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

Diff for /src/usr.bin/ssh/sshconnect2.c between version 1.228 and 1.229

version 1.228, 2015/10/13 16:15:21 version 1.229, 2015/11/15 22:26:49
Line 305 
Line 305 
 static int sign_and_send_pubkey(Authctxt *, Identity *);  static int sign_and_send_pubkey(Authctxt *, Identity *);
 static void pubkey_prepare(Authctxt *);  static void pubkey_prepare(Authctxt *);
 static void pubkey_cleanup(Authctxt *);  static void pubkey_cleanup(Authctxt *);
 static Key *load_identity_file(char *, int);  static Key *load_identity_file(Identity *);
   
 static Authmethod *authmethod_get(char *authlist);  static Authmethod *authmethod_get(char *authlist);
 static Authmethod *authmethod_lookup(const char *name);  static Authmethod *authmethod_lookup(const char *name);
Line 982 
Line 982 
                 return (sshkey_sign(id->key, sigp, lenp, data, datalen,                  return (sshkey_sign(id->key, sigp, lenp, data, datalen,
                     compat));                      compat));
         /* load the private key from the file */          /* load the private key from the file */
         if ((prv = load_identity_file(id->filename, id->userprovided)) == NULL)          if ((prv = load_identity_file(id)) == NULL)
                 return (-1); /* XXX return decent error code */                  return (-1); /* XXX return decent error code */
         ret = sshkey_sign(prv, sigp, lenp, data, datalen, compat);          ret = sshkey_sign(prv, sigp, lenp, data, datalen, compat);
         sshkey_free(prv);          sshkey_free(prv);
Line 1139 
Line 1139 
 }  }
   
 static Key *  static Key *
 load_identity_file(char *filename, int userprovided)  load_identity_file(Identity *id)
 {  {
         Key *private;          Key *private;
         char prompt[300], *passphrase;          char prompt[300], *passphrase, *comment;
         int r, perm_ok = 0, quit = 0, i;          int r, perm_ok = 0, quit = 0, i;
         struct stat st;          struct stat st;
   
         if (stat(filename, &st) < 0) {          if (stat(id->filename, &st) < 0) {
                 (userprovided ? logit : debug3)("no such identity: %s: %s",                  (id->userprovided ? logit : debug3)("no such identity: %s: %s",
                     filename, strerror(errno));                      id->filename, strerror(errno));
                 return NULL;                  return NULL;
         }          }
         snprintf(prompt, sizeof prompt,          snprintf(prompt, sizeof prompt,
             "Enter passphrase for key '%.100s': ", filename);              "Enter passphrase for key '%.100s': ", id->filename);
         for (i = 0; i <= options.number_of_password_prompts; i++) {          for (i = 0; i <= options.number_of_password_prompts; i++) {
                 if (i == 0)                  if (i == 0)
                         passphrase = "";                          passphrase = "";
Line 1164 
Line 1164 
                                 break;                                  break;
                         }                          }
                 }                  }
                 switch ((r = sshkey_load_private_type(KEY_UNSPEC, filename,                  switch ((r = sshkey_load_private_type(KEY_UNSPEC, id->filename,
                     passphrase, &private, NULL, &perm_ok))) {                      passphrase, &private, &comment, &perm_ok))) {
                 case 0:                  case 0:
                         break;                          break;
                 case SSH_ERR_KEY_WRONG_PASSPHRASE:                  case SSH_ERR_KEY_WRONG_PASSPHRASE:
Line 1179 
Line 1179 
                 case SSH_ERR_SYSTEM_ERROR:                  case SSH_ERR_SYSTEM_ERROR:
                         if (errno == ENOENT) {                          if (errno == ENOENT) {
                                 debug2("Load key \"%s\": %s",                                  debug2("Load key \"%s\": %s",
                                     filename, ssh_err(r));                                      id->filename, ssh_err(r));
                                 quit = 1;                                  quit = 1;
                                 break;                                  break;
                         }                          }
                         /* FALLTHROUGH */                          /* FALLTHROUGH */
                 default:                  default:
                         error("Load key \"%s\": %s", filename, ssh_err(r));                          error("Load key \"%s\": %s", id->filename, ssh_err(r));
                         quit = 1;                          quit = 1;
                         break;                          break;
                 }                  }
                   if (!quit && private != NULL && !id->agent_fd &&
                       !(id->key && id->isprivate))
                           maybe_add_key_to_agent(id->filename, private, comment,
                               passphrase);
                 if (i > 0) {                  if (i > 0) {
                         explicit_bzero(passphrase, strlen(passphrase));                          explicit_bzero(passphrase, strlen(passphrase));
                         free(passphrase);                          free(passphrase);
                 }                  }
                   if (comment)
                           free(comment);
                 if (private != NULL || quit)                  if (private != NULL || quit)
                         break;                          break;
         }          }
Line 1395 
Line 1401 
                         }                          }
                 } else {                  } else {
                         debug("Trying private key: %s", id->filename);                          debug("Trying private key: %s", id->filename);
                         id->key = load_identity_file(id->filename,                          id->key = load_identity_file(id);
                             id->userprovided);  
                         if (id->key != NULL) {                          if (id->key != NULL) {
                                 if (try_identity(id)) {                                  if (try_identity(id)) {
                                         id->isprivate = 1;                                          id->isprivate = 1;

Legend:
Removed from v.1.228  
changed lines
  Added in v.1.229