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

Diff for /src/usr.bin/ssh/ssh-keygen.c between version 1.190 and 1.191

version 1.190, 2010/05/20 23:46:02 version 1.191, 2010/06/22 04:32:06
Line 406 
Line 406 
                 perror(identity_file);                  perror(identity_file);
                 exit(1);                  exit(1);
         }          }
         fp = fopen(identity_file, "r");          if ((fp = fopen(identity_file, "r")) == NULL)
         if (fp == NULL) {                  fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
                 perror(identity_file);  
                 exit(1);  
         }  
         encoded[0] = '\0';          encoded[0] = '\0';
         while ((blen = get_line(fp, line, sizeof(line))) != -1) {          while ((blen = get_line(fp, line, sizeof(line))) != -1) {
                 if (line[blen - 1] == '\\')                  if (line[blen - 1] == '\\')
Line 553 
Line 550 
                 comment = NULL;                  comment = NULL;
         }          }
   
         f = fopen(identity_file, "r");          if ((f = fopen(identity_file, "r")) == NULL)
         if (f != NULL) {                  fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
                 while (fgets(line, sizeof(line), f)) {  
                         if ((cp = strchr(line, '\n')) == NULL) {  
                                 error("line %d too long: %.40s...",  
                                     num + 1, line);  
                                 skip = 1;  
                                 continue;  
                         }  
                         num++;  
                         if (skip) {  
                                 skip = 0;  
                                 continue;  
                         }  
                         *cp = '\0';  
   
                         /* Skip leading whitespace, empty and comment lines. */          while (fgets(line, sizeof(line), f)) {
                         for (cp = line; *cp == ' ' || *cp == '\t'; cp++)                  if ((cp = strchr(line, '\n')) == NULL) {
                                 ;                          error("line %d too long: %.40s...",
                         if (!*cp || *cp == '\n' || *cp == '#')                              num + 1, line);
                                 continue;                          skip = 1;
                         i = strtol(cp, &ep, 10);                          continue;
                         if (i == 0 || ep == NULL || (*ep != ' ' && *ep != '\t')) {                  }
                                 int quoted = 0;                  num++;
                                 comment = cp;                  if (skip) {
                                 for (; *cp && (quoted || (*cp != ' ' &&                          skip = 0;
                                     *cp != '\t')); cp++) {                          continue;
                                         if (*cp == '\\' && cp[1] == '"')                  }
                                                 cp++;   /* Skip both */                  *cp = '\0';
                                         else if (*cp == '"')  
                                                 quoted = !quoted;                  /* Skip leading whitespace, empty and comment lines. */
                                 }                  for (cp = line; *cp == ' ' || *cp == '\t'; cp++)
                                 if (!*cp)                          ;
                                         continue;                  if (!*cp || *cp == '\n' || *cp == '#')
                                 *cp++ = '\0';                          continue;
                   i = strtol(cp, &ep, 10);
                   if (i == 0 || ep == NULL || (*ep != ' ' && *ep != '\t')) {
                           int quoted = 0;
                           comment = cp;
                           for (; *cp && (quoted || (*cp != ' ' &&
                               *cp != '\t')); cp++) {
                                   if (*cp == '\\' && cp[1] == '"')
                                           cp++;   /* Skip both */
                                   else if (*cp == '"')
                                           quoted = !quoted;
                         }                          }
                         ep = cp;                          if (!*cp)
                         public = key_new(KEY_RSA1);                                  continue;
                           *cp++ = '\0';
                   }
                   ep = cp;
                   public = key_new(KEY_RSA1);
                   if (key_read(public, &cp) != 1) {
                           cp = ep;
                           key_free(public);
                           public = key_new(KEY_UNSPEC);
                         if (key_read(public, &cp) != 1) {                          if (key_read(public, &cp) != 1) {
                                 cp = ep;  
                                 key_free(public);                                  key_free(public);
                                 public = key_new(KEY_UNSPEC);                                  continue;
                                 if (key_read(public, &cp) != 1) {  
                                         key_free(public);  
                                         continue;  
                                 }  
                         }                          }
                         comment = *cp ? cp : comment;  
                         fp = key_fingerprint(public, fptype, rep);  
                         ra = key_fingerprint(public, SSH_FP_MD5, SSH_FP_RANDOMART);  
                         printf("%u %s %s (%s)\n", key_size(public), fp,  
                             comment ? comment : "no comment", key_type(public));  
                         if (log_level >= SYSLOG_LEVEL_VERBOSE)  
                                 printf("%s\n", ra);  
                         xfree(ra);  
                         xfree(fp);  
                         key_free(public);  
                         invalid = 0;  
                 }                  }
                 fclose(f);                  comment = *cp ? cp : comment;
                   fp = key_fingerprint(public, fptype, rep);
                   ra = key_fingerprint(public, SSH_FP_MD5, SSH_FP_RANDOMART);
                   printf("%u %s %s (%s)\n", key_size(public), fp,
                       comment ? comment : "no comment", key_type(public));
                   if (log_level >= SYSLOG_LEVEL_VERBOSE)
                           printf("%s\n", ra);
                   xfree(ra);
                   xfree(fp);
                   key_free(public);
                   invalid = 0;
         }          }
           fclose(f);
   
         if (invalid) {          if (invalid) {
                 printf("%s is not a public key file.\n", identity_file);                  printf("%s is not a public key file.\n", identity_file);
                 exit(1);                  exit(1);
Line 668 
Line 666 
                 have_identity = 1;                  have_identity = 1;
         }          }
         if ((in = fopen(identity_file, "r")) == NULL)          if ((in = fopen(identity_file, "r")) == NULL)
                 fatal("fopen: %s", strerror(errno));                  fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
   
         /*          /*
          * Find hosts goes to stdout, hash and deletions happen in-place           * Find hosts goes to stdout, hash and deletions happen in-place
Line 1415 
Line 1413 
   
         if (!have_identity)          if (!have_identity)
                 ask_filename(pw, "Enter file in which the key is");                  ask_filename(pw, "Enter file in which the key is");
         if (stat(identity_file, &st) < 0) {          if (stat(identity_file, &st) < 0)
                 perror(identity_file);                  fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
                 exit(1);  
         }  
         if ((key = key_load_public(identity_file, NULL)) == NULL)          if ((key = key_load_public(identity_file, NULL)) == NULL)
                 fatal("%s is not a public key", identity_file);                  fatal("%s is not a public key", identity_file);
         if (!key_is_cert(key))          if (!key_is_cert(key))

Legend:
Removed from v.1.190  
changed lines
  Added in v.1.191