changeset 842f68d0e021 in /srv/hg/libpwquality
details:
http://hg.fedorahosted.org/hg/srv/hg/libpwquality?cmd=changeset;node=842f...
summary: Make the user check optional.
diffstat:
doc/man/pam_pwquality.8.pod | 7 +++++++
doc/man/pwquality.conf.5.pod | 6 ++++++
src/check.c | 3 ++-
src/pwqprivate.h | 2 ++
src/pwquality.conf | 8 ++++++++
src/pwquality.h | 1 +
src/settings.c | 8 ++++++++
7 files changed, 34 insertions(+), 1 deletions(-)
diffs (132 lines):
diff -r d637572f3d34 -r 842f68d0e021 doc/man/pam_pwquality.8.pod
--- a/doc/man/pam_pwquality.8.pod Mon Oct 31 10:03:35 2016 +0100
+++ b/doc/man/pam_pwquality.8.pod Mon Oct 31 10:36:07 2016 +0100
@@ -195,6 +195,13 @@
using the I<cracklib> library. The default is 1 which means that this check
is enabled.
+=item B<usercheck=>I<N>
+
+If nonzero, check whether the password (with possible modifications)
+contains the user name in some form. The default is 1 which means that
+this check is enabled. It is not performed for user names shorter
+than 3 characters.
+
=item B<badwords=>I<< <list of words> >>
The words more than 3 characters long from this space separated list are
diff -r d637572f3d34 -r 842f68d0e021 doc/man/pwquality.conf.5.pod
--- a/doc/man/pwquality.conf.5.pod Mon Oct 31 10:03:35 2016 +0100
+++ b/doc/man/pwquality.conf.5.pod Mon Oct 31 10:36:07 2016 +0100
@@ -101,6 +101,12 @@
matches a word in a dictionary. Currently the dictionary check is performed
using the cracklib library. (default 1)
+=item B<usercheck=>I<N>
+
+If nonzero, check whether the password (with possible modifications)
+contains the user name in some form. It is not performed for user names shorter
+than 3 characters. (default 1)
+
=item B<badwords>
Space separated list of words that must not be contained in the password. These
diff -r d637572f3d34 -r 842f68d0e021 src/check.c
--- a/src/check.c Mon Oct 31 10:03:35 2016 +0100
+++ b/src/check.c Mon Oct 31 10:36:07 2016 +0100
@@ -560,7 +560,8 @@
if (!rv && sequence(pwq, new, auxerror))
rv = PWQ_ERROR_MAX_SEQUENCE;
- if (!rv && usermono && usercheck(pwq, newmono, usermono))
+ if (!rv && usermono && pwq->user_check &&
+ usercheck(pwq, newmono, usermono))
rv = PWQ_ERROR_USER_CHECK;
if (!rv && user && pwq->gecos_check)
diff -r d637572f3d34 -r 842f68d0e021 src/pwqprivate.h
--- a/src/pwqprivate.h Mon Oct 31 10:03:35 2016 +0100
+++ b/src/pwqprivate.h Mon Oct 31 10:36:07 2016 +0100
@@ -25,6 +25,7 @@
int max_sequence;
int gecos_check;
int dict_check;
+ int user_check;
char *bad_words;
char *dict_path;
};
@@ -42,6 +43,7 @@
#define PWQ_DEFAULT_LOW_CREDIT 0
#define PWQ_DEFAULT_OTH_CREDIT 0
#define PWQ_DEFAULT_DICT_CHECK 1
+#define PWQ_DEFAULT_USER_CHECK 1
#define PWQ_TYPE_INT 1
#define PWQ_TYPE_STR 2
diff -r d637572f3d34 -r 842f68d0e021 src/pwquality.conf
--- a/src/pwquality.conf Mon Oct 31 10:03:35 2016 +0100
+++ b/src/pwquality.conf Mon Oct 31 10:36:07 2016 +0100
@@ -46,5 +46,13 @@
# The check is enabled if the value is not 0.
# gecoscheck = 0
#
+# Whether to check for the words from the cracklib dictionary.
+# The check is enabled if the value is not 0.
+# dictcheck = 1
+#
+# Whether to check if it contains the user name in some form.
+# The check is enabled if the value is not 0.
+# usercheck = 1
+#
# Path to the cracklib dictionaries. Default is to use the cracklib default.
# dictpath =
diff -r d637572f3d34 -r 842f68d0e021 src/pwquality.h
--- a/src/pwquality.h Mon Oct 31 10:03:35 2016 +0100
+++ b/src/pwquality.h Mon Oct 31 10:36:07 2016 +0100
@@ -28,6 +28,7 @@
#define PWQ_SETTING_BAD_WORDS 13
#define PWQ_SETTING_MAX_SEQUENCE 14
#define PWQ_SETTING_DICT_CHECK 15
+#define PWQ_SETTING_USER_CHECK 16
#define PWQ_MAX_ENTROPY_BITS 256
#define PWQ_MIN_ENTROPY_BITS 56
diff -r d637572f3d34 -r 842f68d0e021 src/settings.c
--- a/src/settings.c Mon Oct 31 10:03:35 2016 +0100
+++ b/src/settings.c Mon Oct 31 10:36:07 2016 +0100
@@ -34,6 +34,7 @@
pwq->low_credit = PWQ_DEFAULT_LOW_CREDIT;
pwq->oth_credit = PWQ_DEFAULT_OTH_CREDIT;
pwq->dict_check = PWQ_DEFAULT_DICT_CHECK;
+ pwq->user_check = PWQ_DEFAULT_USER_CHECK;
return pwq;
}
@@ -62,6 +63,7 @@
{ "maxsequence", PWQ_SETTING_MAX_SEQUENCE, PWQ_TYPE_INT},
{ "gecoscheck", PWQ_SETTING_GECOS_CHECK, PWQ_TYPE_INT},
{ "dictcheck", PWQ_SETTING_DICT_CHECK, PWQ_TYPE_INT},
+ { "usercheck", PWQ_SETTING_USER_CHECK, PWQ_TYPE_INT},
{ "badwords", PWQ_SETTING_BAD_WORDS, PWQ_TYPE_STR},
{ "dictpath", PWQ_SETTING_DICT_PATH, PWQ_TYPE_STR}
};
@@ -333,6 +335,9 @@
case PWQ_SETTING_DICT_CHECK:
pwq->dict_check = value;
break;
+ case PWQ_SETTING_USER_CHECK:
+ pwq->user_check = value;
+ break;
default:
return PWQ_ERROR_NON_INT_SETTING;
}
@@ -413,6 +418,9 @@
case PWQ_SETTING_DICT_CHECK:
*value = pwq->dict_check;
break;
+ case PWQ_SETTING_USER_CHECK:
+ *value = pwq->user_check;
+ break;
default:
return PWQ_ERROR_NON_INT_SETTING;
}