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

Diff for /src/usr.bin/chpass/Attic/pw_yp.c between version 1.21 and 1.22

version 1.21, 2006/03/31 00:29:13 version 1.22, 2009/02/15 21:43:40
Line 181 
Line 181 
 }  }
   
 static struct passwd *  static struct passwd *
 interpret(struct passwd *pwent, char *line)  interpret(struct passwd *pwent, char *line, const int secure)
 {  {
         char    *p = line;          char    *p = line;
   
Line 196 
Line 196 
         pwent->pw_class = "";          pwent->pw_class = "";
   
         /* line without colon separators is no good, so ignore it */          /* line without colon separators is no good, so ignore it */
         if(!strchr(p,':'))          if (!strchr(p,':'))
                 return(NULL);                  return(NULL);
   
         pwent->pw_name = p;          pwent->pw_name = p;
Line 207 
Line 207 
         p = pwskip(p);          p = pwskip(p);
         pwent->pw_gid = (gid_t)strtoul(p, NULL, 10);          pwent->pw_gid = (gid_t)strtoul(p, NULL, 10);
         p = pwskip(p);          p = pwskip(p);
           if (secure == 1) {
                   pwent->pw_class = p;
                   p = pwskip(p);
                   pwent->pw_change = (time_t)strtoul(p, NULL, 10);
                   p = pwskip(p);
                   pwent->pw_expire = (time_t)strtoul(p, NULL, 10);
                   p = pwskip(p);
           }
         pwent->pw_gecos = p;          pwent->pw_gecos = p;
         p = pwskip(p);          p = pwskip(p);
         pwent->pw_dir = p;          pwent->pw_dir = p;
Line 224 
Line 232 
 ypgetpwnam(char *nam)  ypgetpwnam(char *nam)
 {  {
         static struct passwd pwent;          static struct passwd pwent;
         int reason, vallen;          int reason, vallen, secure = 0;
         char *val;          char *val;
   
         /*          /*
Line 236 
Line 244 
                 exit(1);                  exit(1);
         }          }
   
         reason = yp_match(domain, "passwd.byname", nam, strlen(nam),          if (!yp_match(domain, "master.passwd.byname", nam, strlen(nam),
             &val, &vallen);              &val, &vallen))
         switch(reason) {                  secure = 1;
         case 0:          else if (yp_match(domain, "passwd.byname", nam, strlen(nam),
                 break;              &val, &vallen))
         default:  
                 return (NULL);                  return (NULL);
         }  
         val[vallen] = '\0';          val[vallen] = '\0';
         if (__yplin)          if (__yplin)
                 free(__yplin);                  free(__yplin);
Line 252 
Line 259 
         strlcpy(__yplin, val, vallen + 1);          strlcpy(__yplin, val, vallen + 1);
         free(val);          free(val);
   
         return(interpret(&pwent, __yplin));          return(interpret(&pwent, __yplin, secure));
 }  }
   
 struct passwd *  struct passwd *
 ypgetpwuid(uid_t uid)  ypgetpwuid(uid_t uid)
 {  {
         static struct passwd pwent;          static struct passwd pwent;
         int reason, vallen;          int reason, vallen, secure = 0;
         char namebuf[16], *val;          char namebuf[16], *val;
   
         if (!domain && (reason = yp_get_default_domain(&domain))) {          if (!domain && (reason = yp_get_default_domain(&domain))) {
Line 269 
Line 276 
         }          }
   
         snprintf(namebuf, sizeof namebuf, "%u", (u_int)uid);          snprintf(namebuf, sizeof namebuf, "%u", (u_int)uid);
         reason = yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf),          if (!yp_match(domain, "master.passwd.byuid", namebuf, strlen(namebuf),
             &val, &vallen);              &val, &vallen))
         switch(reason) {                  secure = 1;
         case 0:          else if (yp_match(domain, "passwd.byuid", namebuf, strlen(namebuf),
                 break;              &val, &vallen))
         default:  
                 return (NULL);                  return (NULL);
         }  
         val[vallen] = '\0';          val[vallen] = '\0';
         if (__yplin)          if (__yplin)
                 free(__yplin);                  free(__yplin);
Line 285 
Line 291 
         strlcpy(__yplin, val, vallen + 1);          strlcpy(__yplin, val, vallen + 1);
         free(val);          free(val);
   
         return(interpret(&pwent, __yplin));          return(interpret(&pwent, __yplin, secure));
 }  }
   
 #endif  /* YP */  #endif  /* YP */

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.22