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

Diff for /src/usr.bin/passwd/Attic/yp_passwd.c between version 1.16 and 1.17

version 1.16, 2001/01/10 20:11:30 version 1.17, 2001/06/18 21:09:24
Line 49 
Line 49 
 #include <err.h>  #include <err.h>
 #include <errno.h>  #include <errno.h>
 #include <ctype.h>  #include <ctype.h>
   #include <login_cap.h>
 #include <rpc/rpc.h>  #include <rpc/rpc.h>
 #include <rpcsvc/yp_prot.h>  #include <rpcsvc/yp_prot.h>
 #include <rpcsvc/ypclnt.h>  #include <rpcsvc/ypclnt.h>
Line 60 
Line 61 
 #define _PASSWORD_LEN PASS_MAX  #define _PASSWORD_LEN PASS_MAX
 #endif  #endif
   
 extern  int pwd_gensalt __P(( char *, int, struct passwd *, char));  extern int pwd_gensalt __P((char *, int, struct passwd *, login_cap_t *, char));
 extern  int pwd_check __P((struct passwd *, char *));  extern int pwd_check __P((struct passwd *, login_cap_t *, char *));
 extern  int pwd_gettries __P((struct passwd *));  extern int pwd_gettries __P((struct passwd *, login_cap_t *));
   
 char *ypgetnewpasswd __P((struct passwd *, char **));  char *ypgetnewpasswd __P((struct passwd *, login_cap_t *, char **));
 struct passwd *ypgetpwnam __P((char *));  struct passwd *ypgetpwnam __P((char *));
   
 char *domain;  char *domain;
Line 92 
Line 93 
         struct passwd *pw;          struct passwd *pw;
         struct timeval tv;          struct timeval tv;
         CLIENT *client;          CLIENT *client;
           login_cap_t *lc;
   
         /*          /*
          * Get local domain           * Get local domain
Line 134 
Line 136 
                 warnx("unknown user %s.", username);                  warnx("unknown user %s.", username);
                 return(1);                  return(1);
         }          }
           if ((lc = login_getclass(pw->pw_class)) == NULL) {
                   warnx("unable to get login class for user %s.", username);
                   return(1);
           }
   
         uid = getuid();          uid = getuid();
         if (uid && uid != pw->pw_uid) {          if (uid && uid != pw->pw_uid) {
Line 142 
Line 148 
         }          }
   
         /* prompt for new password */          /* prompt for new password */
         yppasswd.newpw.pw_passwd = ypgetnewpasswd(pw, &yppasswd.oldpass);          yppasswd.newpw.pw_passwd = ypgetnewpasswd(pw, lc, &yppasswd.oldpass);
   
         /* tell rpc.yppasswdd */          /* tell rpc.yppasswdd */
         yppasswd.newpw.pw_name  = pw->pw_name;          yppasswd.newpw.pw_name  = pw->pw_name;
Line 178 
Line 184 
 }  }
   
 char *  char *
 ypgetnewpasswd(pw, old_pass)  ypgetnewpasswd(pw, lc, old_pass)
         struct passwd *pw;          struct passwd *pw;
           login_cap_t *lc;
         char **old_pass;          char **old_pass;
 {  {
         static char buf[_PASSWORD_LEN+1];          static char buf[_PASSWORD_LEN+1];
Line 204 
Line 211 
                         pw_error(NULL, 1, 1);                          pw_error(NULL, 1, 1);
         }          }
   
         pwd_tries = pwd_gettries(pw);          pwd_tries = pwd_gettries(pw, lc);
   
         for (buf[0] = '\0', tries = 0;;) {          for (buf[0] = '\0', tries = 0;;) {
                 p = getpass("New password:");                  p = getpass("New password:");
Line 217 
Line 224 
                         continue;                          continue;
                 }                  }
                 if ((tries++ < pwd_tries || pwd_tries == 0)                  if ((tries++ < pwd_tries || pwd_tries == 0)
                     && pwd_check(pw, p) == 0)                      && pwd_check(pw, lc, p) == 0)
                         continue;                          continue;
                 strncpy(buf, p, sizeof buf-1);                  strncpy(buf, p, sizeof buf-1);
                 buf[sizeof buf-1] = '\0';                  buf[sizeof buf-1] = '\0';
Line 225 
Line 232 
                         break;                          break;
                 (void)printf("Mismatch; try again, EOF to quit.\n");                  (void)printf("Mismatch; try again, EOF to quit.\n");
         }          }
         if( !pwd_gensalt( salt, _PASSWORD_LEN, pw, 'y' )) {          if( !pwd_gensalt( salt, _PASSWORD_LEN, pw, lc, 'y' )) {
                 (void)printf("Couldn't generate salt.\n");                  (void)printf("Couldn't generate salt.\n");
                 pw_error(NULL, 0, 0);                  pw_error(NULL, 0, 0);
         }          }

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