changeset c59d98529349 in /srv/hg/libpwquality
details:
http://hg.fedorahosted.org/hg/srv/hg/libpwquality?cmd=changeset;node=c59d...
summary: Make the cracklib check optional - on by default.
diffstat:
doc/man/pam_pwquality.8 | 10 ++++++++++
doc/man/pwquality.conf.5 | 7 +++++++
python/pwquality.c | 5 +++++
src/check.c | 16 +++++++++-------
src/pwqprivate.h | 2 ++
src/pwquality.h | 1 +
src/settings.c | 12 ++++++++++--
7 files changed, 44 insertions(+), 9 deletions(-)
diffs (165 lines):
diff -r d67ce0d210a4 -r c59d98529349 doc/man/pam_pwquality.8
--- a/doc/man/pam_pwquality.8 Thu Jul 16 13:36:04 2015 +0200
+++ b/doc/man/pam_pwquality.8 Thu Jul 16 13:57:57 2015 +0200
@@ -250,6 +250,16 @@
The default is 0 which means that this check is disabled\&.
.RE
.PP
+\fBdictcheck=\fR\fB\fIN\fR\fR
+.RS 4
+If nonzero, check whether the password (with possible modifications)
+matches a word in a dictionary\&. Currently the dictionary check is performed
+using the
+\fBcracklib\fR
+library\&.
+The default is 1 which means that this check is enabled\&.
+.RE
+.PP
\fBbadwords=\fR\fB\fI<list of words>\fR\fR
.RS 4
The words more than 3 characters long from this space separated list are
diff -r d67ce0d210a4 -r c59d98529349 doc/man/pwquality.conf.5
--- a/doc/man/pwquality.conf.5 Thu Jul 16 13:36:04 2015 +0200
+++ b/doc/man/pwquality.conf.5 Thu Jul 16 13:57:57 2015 +0200
@@ -99,6 +99,13 @@
The check is disabled if the value is 0. (default 0)
.RE
.PP
+\fBdictcheck\fR
+.RS 4
+If nonzero, check whether the password (with possible modifications)
+matches a word in a dictionary. Currently the dictionary check is performed
+using the cracklib library. (default 1)
+.RE
+.PP
\fBbadwords\fR
.RS 4
Space separated list of words that must not be contained in the password. These
diff -r d67ce0d210a4 -r c59d98529349 python/pwquality.c
--- a/python/pwquality.c Thu Jul 16 13:36:04 2015 +0200
+++ b/python/pwquality.c Thu Jul 16 13:57:57 2015 +0200
@@ -126,6 +126,11 @@
"Match words from the passwd GECOS field if available",
(void *)PWQ_SETTING_GECOS_CHECK
},
+ { "dictcheck",
+ (getter)pwqsettings_getint, (setter)pwqsettings_setint,
+ "Perform the dictionary check",
+ (void *)PWQ_SETTING_DICT_CHECK
+ },
{ "badwords",
(getter)pwqsettings_getstr, (setter)pwqsettings_setstr,
"List of words more than 3 characters long that are
forbidden",
diff -r d67ce0d210a4 -r c59d98529349 src/check.c
--- a/src/check.c Thu Jul 16 13:36:04 2015 +0200
+++ b/src/check.c Thu Jul 16 13:57:57 2015 +0200
@@ -669,11 +669,13 @@
if (score != 0)
return score;
- msg = FascistCheck(password, pwq->dict_path);
- if (msg) {
- if (auxerror)
- *auxerror = (void *)msg;
- return PWQ_ERROR_CRACKLIB_CHECK;
+ if (pwq->dict_check) {
+ msg = FascistCheck(password, pwq->dict_path);
+ if (msg) {
+ if (auxerror)
+ *auxerror = (void *)msg;
+ return PWQ_ERROR_CRACKLIB_CHECK;
+ }
}
score = password_score(pwq, password);
@@ -684,8 +686,8 @@
/*
* Copyright (c) Cristian Gafton <gafton(a)redhat.com>, 1996.
* All rights reserved
- * Copyright (c) Red Hat, Inc, 2011
- * Copyright (c) Tomas Mraz <tm(a)t8m.info>, 2011
+ * Copyright (c) Red Hat, Inc, 2011, 2015
+ * Copyright (c) Tomas Mraz <tm(a)t8m.info>, 2011, 2015
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
diff -r d67ce0d210a4 -r c59d98529349 src/pwqprivate.h
--- a/src/pwqprivate.h Thu Jul 16 13:36:04 2015 +0200
+++ b/src/pwqprivate.h Thu Jul 16 13:57:57 2015 +0200
@@ -24,6 +24,7 @@
int max_class_repeat;
int max_sequence;
int gecos_check;
+ int dict_check;
char *bad_words;
char *dict_path;
};
@@ -40,6 +41,7 @@
#define PWQ_DEFAULT_UP_CREDIT 0
#define PWQ_DEFAULT_LOW_CREDIT 0
#define PWQ_DEFAULT_OTH_CREDIT 0
+#define PWQ_DEFAULT_DICT_CHECK 1
#define PWQ_TYPE_INT 1
#define PWQ_TYPE_STR 2
diff -r d67ce0d210a4 -r c59d98529349 src/pwquality.h
--- a/src/pwquality.h Thu Jul 16 13:36:04 2015 +0200
+++ b/src/pwquality.h Thu Jul 16 13:57:57 2015 +0200
@@ -27,6 +27,7 @@
#define PWQ_SETTING_GECOS_CHECK 12
#define PWQ_SETTING_BAD_WORDS 13
#define PWQ_SETTING_MAX_SEQUENCE 14
+#define PWQ_SETTING_DICT_CHECK 15
#define PWQ_MAX_ENTROPY_BITS 256
#define PWQ_MIN_ENTROPY_BITS 56
diff -r d67ce0d210a4 -r c59d98529349 src/settings.c
--- a/src/settings.c Thu Jul 16 13:36:04 2015 +0200
+++ b/src/settings.c Thu Jul 16 13:57:57 2015 +0200
@@ -32,6 +32,7 @@
pwq->up_credit = PWQ_DEFAULT_UP_CREDIT;
pwq->low_credit = PWQ_DEFAULT_LOW_CREDIT;
pwq->oth_credit = PWQ_DEFAULT_OTH_CREDIT;
+ pwq->dict_check = PWQ_DEFAULT_DICT_CHECK;
return pwq;
}
@@ -59,6 +60,7 @@
{ "maxclassrepeat", PWQ_SETTING_MAX_CLASS_REPEAT, PWQ_TYPE_INT},
{ "maxsequence", PWQ_SETTING_MAX_SEQUENCE, PWQ_TYPE_INT},
{ "gecoscheck", PWQ_SETTING_GECOS_CHECK, PWQ_TYPE_INT},
+ { "dictcheck", PWQ_SETTING_DICT_CHECK, PWQ_TYPE_INT},
{ "badwords", PWQ_SETTING_BAD_WORDS, PWQ_TYPE_STR},
{ "dictpath", PWQ_SETTING_DICT_PATH, PWQ_TYPE_STR}
};
@@ -252,6 +254,9 @@
case PWQ_SETTING_GECOS_CHECK:
pwq->gecos_check = value;
break;
+ case PWQ_SETTING_DICT_CHECK:
+ pwq->dict_check = value;
+ break;
default:
return PWQ_ERROR_NON_INT_SETTING;
}
@@ -326,6 +331,9 @@
case PWQ_SETTING_GECOS_CHECK:
*value = pwq->gecos_check;
break;
+ case PWQ_SETTING_DICT_CHECK:
+ *value = pwq->dict_check;
+ break;
default:
return PWQ_ERROR_NON_INT_SETTING;
}
@@ -350,8 +358,8 @@
}
/*
- * Copyright (c) Red Hat, Inc, 2011
- * Copyright (c) Tomas Mraz <tm(a)t8m.info>, 2011
+ * Copyright (c) Red Hat, Inc, 2011, 2015
+ * Copyright (c) Tomas Mraz <tm(a)t8m.info>, 2011, 2015
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions