2009-09-26 17:19:43 +00:00
|
|
|
#!/bin/sh
|
|
|
|
#
|
|
|
|
# Turns on or off the nss-sysinit module db by editing the
|
2010-09-29 22:15:00 +00:00
|
|
|
# global PKCS #11 congiguration file. Displays the status.
|
2009-09-26 17:19:43 +00:00
|
|
|
#
|
|
|
|
# This script can be invoked by the user as super user.
|
2010-09-29 22:15:00 +00:00
|
|
|
# It is invoked at nss-sysinit post install time with argument on.
|
2009-09-26 17:19:43 +00:00
|
|
|
#
|
|
|
|
usage()
|
|
|
|
{
|
|
|
|
cat <<EOF
|
|
|
|
Usage: setup-nsssysinit [on|off]
|
2010-09-29 22:15:00 +00:00
|
|
|
on - turns on nsssysinit
|
|
|
|
off - turns off nsssysinit
|
|
|
|
status - reports whether nsssysinit is turned on or off
|
2009-09-26 17:19:43 +00:00
|
|
|
EOF
|
|
|
|
exit $1
|
|
|
|
}
|
|
|
|
|
|
|
|
# validate
|
2010-09-29 22:15:00 +00:00
|
|
|
if [ $# -eq 0 ]; then
|
2009-09-26 17:19:43 +00:00
|
|
|
usage 1 1>&2
|
|
|
|
fi
|
|
|
|
|
|
|
|
# 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}"
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2010-09-29 22:15:00 +00:00
|
|
|
# check if nsssysinit is currently enabled or disabled
|
|
|
|
sysinit_enabled()
|
|
|
|
{
|
|
|
|
grep -q '^library=libnsssysinit' ${p11conf}
|
|
|
|
}
|
|
|
|
|
|
|
|
umask 022
|
2009-10-06 00:09:59 +00:00
|
|
|
case "$1" in
|
|
|
|
on | ON )
|
2010-09-29 22:15:00 +00:00
|
|
|
if sysinit_enabled; then
|
|
|
|
exit 0
|
|
|
|
fi
|
2009-10-06 00:09:59 +00:00
|
|
|
cat ${p11conf} | \
|
2010-09-29 22:15:00 +00:00
|
|
|
sed -e 's/^library=$/library=libnsssysinit.so/' \
|
|
|
|
-e '/^NSS/s/\(Flags=internal\)\(,[^m]\)/\1,moduleDBOnly\2/' > \
|
|
|
|
${p11conf}.on
|
2009-10-06 00:09:59 +00:00
|
|
|
mv ${p11conf}.on ${p11conf}
|
|
|
|
;;
|
|
|
|
off | OFF )
|
2010-09-29 22:15:00 +00:00
|
|
|
if ! sysinit_enabled; then
|
2009-10-06 00:09:59 +00:00
|
|
|
exit 0
|
|
|
|
fi
|
|
|
|
cat ${p11conf} | \
|
|
|
|
sed -e 's/^library=libnsssysinit.so/library=/' \
|
2009-10-20 14:13:53 +00:00
|
|
|
-e '/^NSS/s/Flags=internal,moduleDBOnly/Flags=internal/' > \
|
2009-10-06 00:09:59 +00:00
|
|
|
${p11conf}.off
|
|
|
|
mv ${p11conf}.off ${p11conf}
|
|
|
|
;;
|
2010-09-29 22:15:00 +00:00
|
|
|
status )
|
|
|
|
echo -n 'NSS sysinit is '
|
|
|
|
sysinit_enabled && echo 'enabled' || echo 'disabled'
|
|
|
|
;;
|
2009-10-06 00:09:59 +00:00
|
|
|
* )
|
|
|
|
usage 1 1>&2
|
|
|
|
;;
|
|
|
|
esac
|