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

Diff for /src/usr.bin/skeyinit/skeyinit.c between version 1.68 and 1.69

version 1.68, 2015/11/29 19:10:44 version 1.69, 2016/02/21 22:53:40
Line 55 
Line 55 
         struct skey skey;          struct skey skey;
         struct passwd *pp;          struct passwd *pp;
   
         if (pledge("stdio rpath wpath cpath fattr flock tty proc exec getpw",  
             NULL) == -1)  
                 err(1, "pledge");  
   
         n = rmkey = hexmode = enable = 0;          n = rmkey = hexmode = enable = 0;
         defaultsetup = 1;          defaultsetup = 1;
         ht = auth_type = NULL;          ht = auth_type = NULL;
   
         /* Build up a default seed based on the hostname and some randomness */  
         if (gethostname(hostname, sizeof(hostname)) < 0)  
                 err(1, "gethostname");  
         for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) {  
                 if (isalnum((unsigned char)hostname[i]))  
                         *p++ = tolower((unsigned char)hostname[i]);  
         }  
         for (i = 0; i < 5; i++)  
                 *p++ = arc4random_uniform(10) + '0';  
         *p = '\0';  
   
         if ((pp = getpwuid(getuid())) == NULL)  
                 err(1, "no user with uid %u", getuid());  
         (void)strlcpy(me, pp->pw_name, sizeof me);  
   
         for (i = 1; i < argc && argv[i][0] == '-' && strcmp(argv[i], "--");) {          for (i = 1; i < argc && argv[i][0] == '-' && strcmp(argv[i], "--");) {
                 if (argv[i][2] == '\0') {                  if (argv[i][2] == '\0') {
                         /* Single character switch */                          /* Single character switch */
Line 135 
Line 116 
                 enable_db(enable);                  enable_db(enable);
                 exit(0);                  exit(0);
         }          }
   
           if (pledge("stdio rpath wpath cpath fattr flock tty proc exec getpw",
               NULL) == -1)
                   err(1, "pledge");
   
           /* Build up a default seed based on the hostname and some randomness */
           if (gethostname(hostname, sizeof(hostname)) < 0)
                   err(1, "gethostname");
           for (i = 0, p = seed; hostname[i] && i < SKEY_NAMELEN; i++) {
                   if (isalnum((unsigned char)hostname[i]))
                           *p++ = tolower((unsigned char)hostname[i]);
           }
           for (i = 0; i < 5; i++)
                   *p++ = arc4random_uniform(10) + '0';
           *p = '\0';
   
           if ((pp = getpwuid(getuid())) == NULL)
                   err(1, "no user with uid %u", getuid());
           (void)strlcpy(me, pp->pw_name, sizeof me);
   
         /* Check for optional user string. */          /* Check for optional user string. */
         if (argc == 1) {          if (argc == 1) {

Legend:
Removed from v.1.68  
changed lines
  Added in v.1.69