version 1.13, 2000/06/30 16:00:20 |
version 1.14, 2000/08/01 22:27:51 |
|
|
#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_check __P((struct passwd *, char *)); |
|
extern int pwd_gettries __P((struct passwd *)); |
|
|
static char *getnewpasswd(); |
static char *getnewpasswd(); |
static struct passwd *ypgetpwnam(); |
static struct passwd *ypgetpwnam(); |
|
|
|
|
{ |
{ |
static char buf[_PASSWORD_LEN+1]; |
static char buf[_PASSWORD_LEN+1]; |
register char *p, *t; |
register char *p, *t; |
int tries; |
int tries, pwd_tries; |
char salt[_PASSWORD_LEN], *crypt(), *getpass(); |
char salt[_PASSWORD_LEN], *crypt(), *getpass(); |
int pwd_gensalt __P(( char *, int, struct passwd *, char)); |
|
|
|
printf("Changing YP password for %s.\n", pw->pw_name); |
printf("Changing YP password for %s.\n", pw->pw_name); |
|
|
|
|
*old_pass = strdup(p); |
*old_pass = strdup(p); |
} |
} |
|
|
|
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:"); |
if (!*p) { |
if (!*p) { |
|
|
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) { |
if ((tries++ < pwd_tries || pwd_tries == 0) |
printf("Please enter a longer password.\n"); |
&& pwd_check(pw, p) == 0) |
continue; |
continue; |
} |
|
for (t = p; *t && islower(*t); ++t) |
|
; |
|
if (!*t && ++tries < 2) { |
|
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:"))) |