changeset 5ddae9e5552f in /srv/hg/libpwquality
details:
http://hg.fedorahosted.org/hg/srv/hg/libpwquality?cmd=changeset;node=5dda...
summary: Fix configuration file parsing.
diffstat:
doc/man/pwquality.conf.5 | 3 ++-
src/settings.c | 11 +++++++++--
2 files changed, 11 insertions(+), 3 deletions(-)
diffs (42 lines):
diff -r d84f87223ebb -r 5ddae9e5552f doc/man/pwquality.conf.5
--- a/doc/man/pwquality.conf.5 Tue Dec 06 21:07:55 2011 +0100
+++ b/doc/man/pwquality.conf.5 Tue Dec 06 21:58:08 2011 +0100
@@ -13,7 +13,8 @@
and generating passwords.
The file has a very simple \fIname = value\fR format with possible comments
-starting with \fB#\fR character.
+starting with \fB#\fR character. The whitespace at the beginning of line, end
+of line, and around the \fB=\fR sign is ignored.
.PD
.SH OPTIONS
diff -r d84f87223ebb -r 5ddae9e5552f src/settings.c
--- a/src/settings.c Tue Dec 06 21:07:55 2011 +0100
+++ b/src/settings.c Tue Dec 06 21:58:08 2011 +0100
@@ -122,6 +122,7 @@
size_t len;
char *ptr;
char *name;
+ int eq;
len = strlen(linebuf);
if (linebuf[len - 1] != '\n' && !feof(f)) {
@@ -158,9 +159,15 @@
}
++ptr;
}
+
+ eq = 0;
while (*ptr != '\0') {
- if (!isspace(*ptr)) {
- break;
+ if (*ptr != '=' || eq) {
+ if (!isspace(*ptr)) {
+ break;
+ }
+ } else {
+ eq = 1;
}
++ptr;
}