--- pam_cracklib.c 2002-08-18 18:27:12.000000000 -0400 +++ pam_cracklib.c 2002-08-18 18:27:22.000000000 -0400 @@ -142,19 +142,19 @@ opt->min_length = CO_MIN_LENGTH_BASE; } else if (!strncmp(*argv,"dcredit=",8)) { opt->dig_credit = strtol(*argv+8,&ep,10); - if (!ep || (opt->dig_credit < 0)) + if (!ep) opt->dig_credit = 0; } else if (!strncmp(*argv,"ucredit=",8)) { opt->up_credit = strtol(*argv+8,&ep,10); - if (!ep || (opt->up_credit < 0)) + if (!ep) opt->up_credit = 0; } else if (!strncmp(*argv,"lcredit=",8)) { opt->low_credit = strtol(*argv+8,&ep,10); - if (!ep || (opt->low_credit < 0)) + if (!ep) opt->low_credit = 0; } else if (!strncmp(*argv,"ocredit=",8)) { opt->oth_credit = strtol(*argv+8,&ep,10); - if (!ep || (opt->oth_credit < 0)) + if (!ep) opt->oth_credit = 0; } else if (!strncmp(*argv,"use_authtok",11)) { opt->use_authtok = 1; @@ -294,23 +294,39 @@ * defaults cause the effect to be the same as before the change */ - if (digits > opt->dig_credit) + if (opt->dig_credit >= 0 && digits > opt->dig_credit) digits = opt->dig_credit; - if (uppers > opt->up_credit) + if (opt->up_credit >= 0 && uppers > opt->up_credit) uppers = opt->up_credit; - if (lowers > opt->low_credit) + if (opt->low_credit >= 0 && lowers > opt->low_credit) lowers = opt->low_credit; - if (others > opt->oth_credit) + if (opt->oth_credit >= 0 && others > opt->oth_credit) others = opt->oth_credit; size = opt->min_length; - size -= digits; - size -= uppers; - size -= lowers; - size -= others; + + if (opt->dig_credit >= 0) + size -= digits; + else if (digits < opt->dig_credit * -1) + return 2; + + if (opt->up_credit >= 0) + size -= uppers; + else if (uppers < opt->up_credit * -1) + return 3; + + if (opt->low_credit >= 0) + size -= lowers; + else if (lowers < opt->low_credit * -1) + return 4; + + if (opt->oth_credit >= 0) + size -= others; + else if (others < opt->oth_credit * -1) + return 5; if (size <= i) return 0; @@ -331,6 +347,7 @@ { const char *msg = NULL; char *oldmono, *newmono, *wrapped; + int simpleres; if (strcmp(new, old) == 0) { msg = "is the same as the old one"; @@ -352,8 +369,19 @@ if (!msg && similar(opt, oldmono, newmono)) msg = "is too similar to the old one"; - if (!msg && simple(opt, old, new)) - msg = "is too simple"; + simpleres = simple(opt, old, new); + if (!msg && simpleres) { + if (simpleres == 2) + msg = "needs numeric characters"; + else if (simpleres == 3) + msg = "needs upper case characters"; + else if (simpleres == 4) + msg = "needs lower case characters"; + else if (simpleres == 5) + msg = "needs other characters"; + else + msg = "is too Simple"; + } if (!msg && strstr(wrapped, newmono)) msg = "is rotated";