[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.2 and 1.5

version 1.2, 1999/09/28 04:45:37 version 1.5, 1999/09/29 21:14:16
Line 16 
Line 16 
 #include "includes.h"  #include "includes.h"
 RCSID("$Id$");  RCSID("$Id$");
   
 #ifndef HAVE_GETHOSTNAME  
 #include <sys/utsname.h>  
 #endif  
 #include "rsa.h"  #include "rsa.h"
 #include "ssh.h"  #include "ssh.h"
 #include "xmalloc.h"  #include "xmalloc.h"
Line 78 
Line 75 
     if (strchr(buf, '\n'))      if (strchr(buf, '\n'))
       *strchr(buf, '\n') = 0;        *strchr(buf, '\n') = 0;
     if (strcmp(buf, "") == 0)      if (strcmp(buf, "") == 0)
       sprintf(buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY);        snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY);
   }    }
   
   /* Check if the file exists. */    /* Check if the file exists. */
Line 197 
Line 194 
       if (strchr(buf, '\n'))        if (strchr(buf, '\n'))
         *strchr(buf, '\n') = 0;          *strchr(buf, '\n') = 0;
       if (strcmp(buf, "") == 0)        if (strcmp(buf, "") == 0)
         sprintf(buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY);          snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY);
     }      }
   
   /* Check if the file exists. */    /* Check if the file exists. */
Line 314 
Line 311 
   int opt;    int opt;
   struct stat st;    struct stat st;
   FILE *f;    FILE *f;
 #ifdef HAVE_GETHOSTNAME    char hostname[MAXHOSTNAMELEN];
   char hostname[257];  
 #else  
   struct utsname uts;  
 #endif  
   extern int optind;    extern int optind;
   extern char *optarg;    extern char *optarg;
   
     /* check if RSA support exists */
     if (rsa_alive() == 0) {
       extern char *__progname;
   
       fprintf(stderr,
         "%s: no RSA support in libssl and libcrypto.  See ssl(8).\n",
         __progname);
       exit(1);
     }
   
   /* Get user\'s passwd structure.  We need this for the home directory. */    /* Get user\'s passwd structure.  We need this for the home directory. */
   pw = getpwuid(getuid());    pw = getpwuid(getuid());
   if (!pw)    if (!pw)
Line 331 
Line 334 
     }      }
   
   /* Create ~/.ssh directory if it doesn\'t already exist. */    /* Create ~/.ssh directory if it doesn\'t already exist. */
   sprintf(buf, "%s/%s", pw->pw_dir, SSH_USER_DIR);    snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, SSH_USER_DIR);
   if (stat(buf, &st) < 0)    if (stat(buf, &st) < 0)
     if (mkdir(buf, 0755) < 0)      if (mkdir(buf, 0755) < 0)
       error("Could not create directory '%s'.", buf);        error("Could not create directory '%s'.", buf);
   
   /* Parse command line arguments. */    /* Parse command line arguments. */
   while ((opt = getopt(ac, av, "pcb:f:P:N:C:")) != EOF)    while ((opt = getopt(ac, av, "qpcb:f:P:N:C:")) != EOF)
     {      {
       switch (opt)        switch (opt)
         {          {
Line 438 
Line 441 
       if (strchr(buf, '\n'))        if (strchr(buf, '\n'))
         *strchr(buf, '\n') = 0;          *strchr(buf, '\n') = 0;
       if (strcmp(buf, "") == 0)        if (strcmp(buf, "") == 0)
         sprintf(buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY);          snprintf(buf, sizeof buf, "%s/%s", pw->pw_dir, SSH_CLIENT_IDENTITY);
     }      }
   
   /* If the file aready exists, ask the user to confirm. */    /* If the file aready exists, ask the user to confirm. */
Line 484 
Line 487 
      edit this field. */       edit this field. */
   if (identity_comment)    if (identity_comment)
     {      {
       strncpy(buf2, identity_comment, sizeof(buf2));        strlcpy(buf2, identity_comment, sizeof(buf2));
       buf2[sizeof(buf2) - 1] = '\0';  
     }      }
   else    else
     {      {
 #ifdef HAVE_GETHOSTNAME  
       if (gethostname(hostname, sizeof(hostname)) < 0)        if (gethostname(hostname, sizeof(hostname)) < 0)
         {          {
           perror("gethostname");            perror("gethostname");
           exit(1);            exit(1);
         }          }
       sprintf(buf2, "%s@%s", pw->pw_name, hostname);        snprintf(buf2, sizeof buf2, "%s@%s", pw->pw_name, hostname);
 #else  
       if (uname(&uts) < 0)  
         {  
           perror("uname");  
           exit(1);  
         }  
       sprintf(buf2, "%s@%s", pw->pw_name, uts.nodename);  
 #endif  
     }      }
   
   /* Save the key with the given passphrase and comment. */    /* Save the key with the given passphrase and comment. */

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.5