security/nss/tests/dbupgrade/dbupgrade.sh

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rwxr-xr-x

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 #!/bin/sh
michael@0 2 #
michael@0 3 # This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 # License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 # file, You can obtain one at http://mozilla.org/MPL/2.0/.
michael@0 6
michael@0 7 ########################################################################
michael@0 8 #
michael@0 9 # mozilla/security/nss/tests/dbupgrade/dbupgrade.sh
michael@0 10 #
michael@0 11 # Script to upgrade databases to Shared DB
michael@0 12 #
michael@0 13 # needs to work on all Unix and Windows platforms
michael@0 14 #
michael@0 15 # special strings
michael@0 16 # ---------------
michael@0 17 # FIXME ... known problems, search for this string
michael@0 18 # NOTE .... unexpected behavior
michael@0 19 #
michael@0 20 ########################################################################
michael@0 21
michael@0 22 ############################ dbupgrade_init ############################
michael@0 23 # local shell function to initialize this script
michael@0 24 ########################################################################
michael@0 25 dbupgrade_init()
michael@0 26 {
michael@0 27 if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
michael@0 28 cd ${QADIR}/common
michael@0 29 . ./init.sh
michael@0 30 fi
michael@0 31
michael@0 32 if [ ! -r "${CERT_LOG_FILE}" ]; then # we need certificates here
michael@0 33 cd ${QADIR}/cert
michael@0 34 . ./cert.sh
michael@0 35 fi
michael@0 36
michael@0 37 if [ ! -d ${HOSTDIR}/SDR ]; then # we also need sdr as well
michael@0 38 cd ${QADIR}/sdr
michael@0 39 . ./sdr.sh
michael@0 40 fi
michael@0 41
michael@0 42 SCRIPTNAME=dbupgrade.sh
michael@0 43 if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
michael@0 44 CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
michael@0 45 fi
michael@0 46
michael@0 47 echo "$SCRIPTNAME: DB upgrade tests ==============================="
michael@0 48 }
michael@0 49
michael@0 50 ############################ dbupgrade_main ############################
michael@0 51 # local shell function to upgrade certificate databases
michael@0 52 ########################################################################
michael@0 53 dbupgrade_main()
michael@0 54 {
michael@0 55 # 'reset' the databases to initial values
michael@0 56 echo "Reset databases to their initial values:"
michael@0 57 cd ${HOSTDIR}
michael@0 58 ${BINDIR}/certutil -D -n objsigner -d alicedir 2>&1
michael@0 59 ${BINDIR}/certutil -M -n FIPS_PUB_140_Test_Certificate -t "C,C,C" -d fips -f ${FIPSPWFILE} 2>&1
michael@0 60 ${BINDIR}/certutil -L -d fips 2>&1
michael@0 61 rm -f smime/alicehello.env
michael@0 62
michael@0 63 # test upgrade to the new database
michael@0 64 echo "nss" > ${PWFILE}
michael@0 65 html_head "Legacy to shared Library update"
michael@0 66 dirs="alicedir bobdir CA cert_extensions client clientCA dave eccurves eve ext_client ext_server SDR server serverCA stapling tools/copydir"
michael@0 67 for i in $dirs
michael@0 68 do
michael@0 69 echo $i
michael@0 70 if [ -d $i ]; then
michael@0 71 echo "upgrading db $i"
michael@0 72 ${BINDIR}/certutil -G -g 512 -d sql:$i -f ${PWFILE} -z ${NOISE_FILE} 2>&1
michael@0 73 html_msg $? 0 "Upgrading $i"
michael@0 74 else
michael@0 75 echo "skipping db $i"
michael@0 76 html_msg 0 0 "No directory $i"
michael@0 77 fi
michael@0 78 done
michael@0 79
michael@0 80 if [ -d fips ]; then
michael@0 81 echo "upgrading db fips"
michael@0 82 ${BINDIR}/certutil -S -g 512 -n tmprsa -t "u,u,u" -s "CN=tmprsa, C=US" -x -d sql:fips -f ${FIPSPWFILE} -z ${NOISE_FILE} 2>&1
michael@0 83 html_msg $? 0 "Upgrading fips"
michael@0 84 # remove our temp certificate we created in the fist token
michael@0 85 ${BINDIR}/certutil -F -n tmprsa -d sql:fips -f ${FIPSPWFILE} 2>&1
michael@0 86 ${BINDIR}/certutil -L -d sql:fips 2>&1
michael@0 87 fi
michael@0 88
michael@0 89 html "</TABLE><BR>"
michael@0 90 }
michael@0 91
michael@0 92 ########################## dbupgrade_cleanup ###########################
michael@0 93 # local shell function to finish this script (no exit since it might be
michael@0 94 # sourced)
michael@0 95 ########################################################################
michael@0 96 dbupgrade_cleanup()
michael@0 97 {
michael@0 98 cd ${QADIR}
michael@0 99 . common/cleanup.sh
michael@0 100 }
michael@0 101
michael@0 102 ################################# main #################################
michael@0 103
michael@0 104 dbupgrade_init
michael@0 105 dbupgrade_main
michael@0 106 dbupgrade_cleanup

mercurial