summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorYour Name <you@example.com>2021-03-12 23:32:12 +0000
committerYour Name <you@example.com>2021-03-12 23:32:12 +0000
commit745a14152ea9d347c6b697a63f8e718aae96d6ad (patch)
tree90b86580780ffc2b0b705b375598da3e1b8617b6 /src
parentc289083ad82333df5cec93786f2e3ccabe84f530 (diff)
downloadcracklib-745a14152ea9d347c6b697a63f8e718aae96d6ad.tar.gz
Add cracklib-update script from Debian
In Debian tat script is used under update-cracklib name but I think tht better is use name cracklib-update to bi consistent with other cracklib-* commands. Rename man page update-cracklib.8 to cracklib-update.8 acordingly.
Diffstat (limited to 'src')
-rw-r--r--src/doc/Makefile.am4
-rw-r--r--src/doc/cracklib-update.8 (renamed from src/doc/update-cracklib.8)0
-rw-r--r--src/util/Makefile.am1
-rw-r--r--src/util/cracklib-update46
4 files changed, 49 insertions, 2 deletions
diff --git a/src/doc/Makefile.am b/src/doc/Makefile.am
index a4d7b31..e54cd88 100644
--- a/src/doc/Makefile.am
+++ b/src/doc/Makefile.am
@@ -1,7 +1,7 @@
dist_pkgdata_DATA = cracklib.magic
man_MANS = \
- update-cracklib.8 \
- cracklib-format.8 \
cracklib-check.8 \
+ cracklib-format.8 \
+ cracklib-update.8 \
FascistCheck.3 \ No newline at end of file
diff --git a/src/doc/update-cracklib.8 b/src/doc/cracklib-update.8
index bad3c86..bad3c86 100644
--- a/src/doc/update-cracklib.8
+++ b/src/doc/cracklib-update.8
diff --git a/src/util/Makefile.am b/src/util/Makefile.am
index 4649416..e3d1a89 100644
--- a/src/util/Makefile.am
+++ b/src/util/Makefile.am
@@ -1,4 +1,5 @@
sbin_PROGRAMS = cracklib-packer cracklib-unpacker cracklib-check
+sbin_SCRIPTS = cracklib-update
check_PROGRAMS = testlib testnum teststr
diff --git a/src/util/cracklib-update b/src/util/cracklib-update
new file mode 100644
index 0000000..cce7189
--- /dev/null
+++ b/src/util/cracklib-update
@@ -0,0 +1,46 @@
+#!/bin/sh
+# update-cracklib - Regenerate cracklib word lists
+#
+# This script is based on the original cron job written by Jean Pierre
+# LeJacq <jplejacq@quoininc.com>.
+
+set -e
+
+umask 0022
+
+if [ -r "/etc/cracklib/cracklib.conf" ]
+then
+ . /etc/cracklib/cracklib.conf
+else
+ echo Error: cannot read configuration file /etc/cracklib/cracklib.conf
+ exit 1
+fi
+
+if [ ! -d /var/cache/cracklib/ ]; then
+ install -d -m 755 /var/cache/cracklib/
+fi
+
+if [ -n "${cracklib_dictpath_src}" -a -n "${cracklib_dictpath}" ]
+then
+ export LC_COLLATE=C
+ processed=0
+ for i in ${cracklib_dictpath_src}
+ do
+ if ! [ -e /var/cache/cracklib/src-dicts ] \
+ || ! grep -q "$i" /var/cache/cracklib/src-dicts \
+ || ! [ -e "${cracklib_dictpath}.pwd" ] \
+ || [ "$i" -nt "${cracklib_dictpath}.pwd" ]
+ then
+ if [ $processed = 0 ]
+ then
+ /usr/sbin/cracklib-format ${cracklib_dictpath_src} | \
+ /usr/sbin/cracklib-packer
+ processed=1
+ echo "${cracklib_dictpath_src}" > \
+ /var/cache/cracklib/src-dicts
+ fi
+ fi
+ done
+fi
+
+exit 0