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

Diff for /src/usr.bin/passwd/Attic/pwd_gensalt.c between version 1.17 and 1.18

version 1.17, 2003/07/02 21:04:10 version 1.18, 2004/07/13 21:09:48
Line 38 
Line 38 
 #include <err.h>  #include <err.h>
 #include <grp.h>  #include <grp.h>
 #include <pwd.h>  #include <pwd.h>
 #include <util.h>  
 #include <time.h>  #include <time.h>
 #include <login_cap.h>  #include <login_cap.h>
   
 void    to64(char *, int32_t, int n);  void    to64(char *, int32_t, int n);
 char    *bcrypt_gensalt(u_int8_t);  char    *bcrypt_gensalt(u_int8_t);
 int     pwd_gensalt(char *, int, struct passwd *, login_cap_t *, char);  int     pwd_gensalt(char *, int, login_cap_t *, char);
   
 int  int
 pwd_gensalt(char *salt, int saltlen, struct passwd *pwd, login_cap_t *lc, char type)  pwd_gensalt(char *salt, int saltlen, login_cap_t *lc, char type)
 {  {
         char    option[LINE_MAX], *next, *now, *cipher;          char    option[LINE_MAX], *next, *now, *cipher;
   
           option[0] = '\0';
         *salt = '\0';          *salt = '\0';
   
         switch (type) {          switch (type) {
Line 64 
Line 64 
         }          }
   
         /*          /*
          * Check login.conf, falling back onto the deprecated passwd.conf           * Check login.conf
          */           */
         /* XXX - when passwd.conf goes away completely, add a default value */  
         if ((next = login_getcapstr(lc, cipher, NULL, NULL)) != NULL) {          if ((next = login_getcapstr(lc, cipher, NULL, NULL)) != NULL) {
                 strlcpy(option, next, sizeof(option));                  strlcpy(option, next, sizeof(option));
                 free(next);                  free(next);
         } else {          }
                 pw_getconf(option, LINE_MAX, pwd->pw_name, cipher);  
   
                 /* Try to find an entry for the group */          if (*option == 0) {
                 if (*option == 0) {                  if (type == 'l')
                         struct group *grp;                          strlcpy(option, "old", sizeof(option));
                         char grpkey[LINE_MAX];                  else
                           strlcpy(option, "blowfish,6", sizeof(option));
                         grp = getgrgid(pwd->pw_gid);  
                         if (grp != NULL) {  
                                 snprintf(grpkey, LINE_MAX, ":%s",  
                                     grp->gr_name);  
                                 pw_getconf(option, LINE_MAX, grpkey, cipher);  
                         }  
                         if (grp != NULL && *option == 0 &&  
                             strchr(pwd->pw_name, '.') == NULL) {  
                                 snprintf(grpkey, LINE_MAX, ".%s",  
                                     grp->gr_name);  
                                 pw_getconf(option, LINE_MAX, grpkey, cipher);  
                         }  
                         if (*option == 0)  
                                 pw_getconf(option, LINE_MAX, "default", cipher);  
                 }  
         }          }
   
         next = option;          next = option;

Legend:
Removed from v.1.17  
changed lines
  Added in v.1.18