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

version 1.4, 1999/09/29 06:15:00 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;
   
Line 341 
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);
Line 448 
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 494 
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.4  
changed lines
  Added in v.1.5