Teach passwd about a new "mixpasswordcase" login.conf parameter. If this

parameter is missing, or specified as above, then passwd behaves as normal
when the user enters an all lower case password -- i.e., it prompts them
to use mixed case, and will only grudgingly accept an all lower case
password.

If you negate this entry in login.conf, with "mixpasswordcase@", then
passwd will allow all lower case passwords without complaining.

Approved by:  jkh
This commit is contained in:
nik 2000-02-11 14:08:44 +00:00
parent ffb46263e0
commit ba43d28ef0

View File

@ -95,6 +95,7 @@ getnewpasswd(pw, nis)
int nis;
{
int tries, min_length = 6;
int force_mix_case = 1;
char *p, *t;
#ifdef LOGIN_CAP
login_cap_t * lc;
@ -114,7 +115,8 @@ getnewpasswd(pw, nis)
#ifdef LOGIN_CAP
/*
* Determine minimum password length and next password change date.
* Determine minimum password length, next password change date,
* and whether or not to force mixed case passwords.
* Note that even for NIS passwords, login_cap is still used.
*/
if ((lc = login_getpwclass(pw)) != NULL) {
@ -128,6 +130,8 @@ getnewpasswd(pw, nis)
if (period > (time_t)0) {
pw->pw_change = time(NULL) + period;
}
/* mixpasswordcase capability */
force_mix_case = login_getcapbool(lc, "mixpasswordcase", 1);
login_close(lc);
}
#endif
@ -142,10 +146,13 @@ getnewpasswd(pw, nis)
(void)printf("Please enter a password at least %d characters in length.\n", min_length);
continue;
}
for (t = p; *t && islower(*t); ++t);
if (!*t && (uid != 0 || ++tries < 2)) {
(void)printf("Please don't use an all-lower case password.\nUnusual capitalization, control characters or digits are suggested.\n");
continue;
if (force_mix_case) {
for (t = p; *t && islower(*t); ++t);
if (!*t && (uid != 0 || ++tries < 2)) {
(void)printf("Please don't use an all-lower case password.\nUnusual capitalization, control characters or digits are suggested.\n");
continue;
}
}
(void)strcpy(buf, p);
if (!strcmp(buf, getpass("Retype new password:")))