# Turns on or off the nss-sysinit module db by editing the
# global PKCS #11 congiguration file. Displays the status.
# This script can be invoked by the user as super user.
# It is invoked at nss-sysinit post install time with argument on.
Usage: setup-nsssysinit [on|off]
off - turns off nsssysinit
status - reports whether nsssysinit is turned on or off
# the system-wide configuration file
p11conf="/etc/pki/nssdb/pkcs11.txt"
# must exist, otherwise report it and exit with failure
if [ ! -f $p11conf ]; then
echo "Could not find ${p11conf}"
# check if nsssysinit is currently enabled or disabled
grep -q '^library=libnsssysinit' ${p11conf}
sed -e 's/^library=$/library=libnsssysinit.so/' \
-e '/^NSS/s/\(Flags=internal\)\(,[^m]\)/\1,moduleDBOnly\2/' > \
mv ${p11conf}.on ${p11conf}
if ! sysinit_enabled; then
sed -e 's/^library=libnsssysinit.so/library=/' \
-e '/^NSS/s/Flags=internal,moduleDBOnly/Flags=internal/' > \
mv ${p11conf}.off ${p11conf}
echo -n 'NSS sysinit is '
sysinit_enabled && echo 'enabled' || echo 'disabled'