Update nss to upstream 3.15.4 for security CVE
[platform/upstream/nss.git] / packaging / setup-nsssysinit.sh
1 #!/bin/sh
2 #
3 # Turns on or off the nss-sysinit module db by editing the
4 # global PKCS #11 congiguration file.
5 #
6 # This script can be invoked by the user as super user.
7 # It is invoked at nss-sysinit post install time with argument on
8 # and at nss-sysinit pre uninstall with argument off.
9 #
10 usage()
11 {
12   cat <<EOF
13 Usage: setup-nsssysinit [on|off]
14   on  - turns on nsssysinit
15   off - turns off nsssysinit
16 EOF
17   exit $1
18 }
19
20 # validate
21 if test $# -eq 0; then
22   usage 1 1>&2
23 fi
24
25 # the system-wide configuration file
26 p11conf="/etc/pki/nssdb/pkcs11.txt"
27 # must exist, otherwise report it and exit with failure
28 if [ ! -f $p11conf ]; then
29   echo "Could not find ${p11conf}"
30   exit 1
31 fi
32
33 on="1"
34 case "$1" in
35   on | ON )
36     cat ${p11conf} | \
37      sed -e 's/^library=$/library=libnsssysinit.so/' \
38          -e '/^NSS/s/\(Flags=internal\)\(,[^m]\)/\1,moduleDBOnly\2/' > \
39     ${p11conf}.on
40     mv ${p11conf}.on ${p11conf}
41     ;;
42   off | OFF )
43     if [ ! `grep "^library=libnsssysinit" ${p11conf}` ]; then
44       exit 0
45     fi
46     cat ${p11conf} | \
47     sed -e 's/^library=libnsssysinit.so/library=/' \
48         -e '/^NSS/s/Flags=internal,moduleDBOnly/Flags=internal/' > \
49         ${p11conf}.off
50     mv ${p11conf}.off ${p11conf}
51     ;;
52   * )
53     usage 1 1>&2
54     ;;
55 esac