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

Diff for /src/usr.bin/passwd/local_passwd.c between version 1.10 and 1.11

version 1.10, 1998/07/13 02:15:00 version 1.11, 2000/08/01 22:27:51
Line 51 
Line 51 
 #include <util.h>  #include <util.h>
   
 static uid_t uid;  static uid_t uid;
   extern int pwd_gensalt __P(( char *, int, struct passwd *, char));
   extern int pwd_check __P((struct passwd *, char *));
   extern int pwd_gettries __P((struct passwd *));
   
   
 int  int
 local_passwd(uname)  local_passwd(uname)
         char *uname;          char *uname;
Line 85 
Line 87 
                         err(1, "can't open passwd temp file");                          err(1, "can't open passwd temp file");
         }          }
         pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0);          pfd = open(_PATH_MASTERPASSWD, O_RDONLY, 0);
         if (pfd < 0)          if (pfd < 0 || fcntl(pfd, F_SETFD, 1) == -1)
                 pw_error(_PATH_MASTERPASSWD, 1, 1);                  pw_error(_PATH_MASTERPASSWD, 1, 1);
   
         /*          /*
Line 107 
Line 109 
         register struct passwd *pw;          register struct passwd *pw;
 {  {
         register char *p, *t;          register char *p, *t;
         int tries;          int tries, pwd_tries;
         char buf[_PASSWORD_LEN+1], salt[_PASSWORD_LEN], *crypt(), *getpass();          char buf[_PASSWORD_LEN+1], salt[_PASSWORD_LEN], *crypt(), *getpass();
         int pwd_gensalt __P(( char *, int, struct passwd *, char));  
   
         (void)printf("Changing local password for %s.\n", pw->pw_name);          (void)printf("Changing local password for %s.\n", pw->pw_name);
   
Line 119 
Line 120 
                 errno = EACCES;                  errno = EACCES;
                 pw_error(NULL, 1, 1);                  pw_error(NULL, 1, 1);
         }          }
   
           pwd_tries = pwd_gettries(pw);
   
         for (buf[0] = '\0', tries = 0;;) {          for (buf[0] = '\0', tries = 0;;) {
                 p = getpass("New password:");                  p = getpass("New password:");
Line 130 
Line 133 
                         printf("That password collides with a system feature. Choose another.\n");                          printf("That password collides with a system feature. Choose another.\n");
                         continue;                          continue;
                 }                  }
                 if (strlen(p) <= 5 && ++tries < 2) {  
                         (void)printf("Please enter a longer password.\n");                  if ((tries++ < pwd_tries || pwd_tries == 0)
                       && pwd_check(pw, p) == 0)
                         continue;                          continue;
                 }  
                 for (t = p; *t && islower(*t); ++t);  
                 if (!*t && ++tries < 2) {  
                         (void)printf("Please don't use an all-lower case password.\nUnusual capitalization, control characters or digits are suggested.\n");  
                         continue;  
                 }  
                 strncpy(buf, p, sizeof buf-1);                  strncpy(buf, p, sizeof buf-1);
                 buf[sizeof buf-1] = '\0';                  buf[sizeof buf-1] = '\0';
                 if (!strcmp(buf, getpass("Retype new password:")))                  if (!strcmp(buf, getpass("Retype new password:")))

Legend:
Removed from v.1.10  
changed lines
  Added in v.1.11