michael@0: #!/bin/sh michael@0: # michael@0: # This Source Code Form is subject to the terms of the Mozilla Public michael@0: # License, v. 2.0. If a copy of the MPL was not distributed with this michael@0: # file, You can obtain one at http://mozilla.org/MPL/2.0/. michael@0: michael@0: ######################################################################## michael@0: # michael@0: # mozilla/security/nss/tests/dbupgrade/dbupgrade.sh michael@0: # michael@0: # Script to upgrade databases to Shared DB michael@0: # michael@0: # needs to work on all Unix and Windows platforms michael@0: # michael@0: # special strings michael@0: # --------------- michael@0: # FIXME ... known problems, search for this string michael@0: # NOTE .... unexpected behavior michael@0: # michael@0: ######################################################################## michael@0: michael@0: ############################ dbupgrade_init ############################ michael@0: # local shell function to initialize this script michael@0: ######################################################################## michael@0: dbupgrade_init() michael@0: { michael@0: if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then michael@0: cd ${QADIR}/common michael@0: . ./init.sh michael@0: fi michael@0: michael@0: if [ ! -r "${CERT_LOG_FILE}" ]; then # we need certificates here michael@0: cd ${QADIR}/cert michael@0: . ./cert.sh michael@0: fi michael@0: michael@0: if [ ! -d ${HOSTDIR}/SDR ]; then # we also need sdr as well michael@0: cd ${QADIR}/sdr michael@0: . ./sdr.sh michael@0: fi michael@0: michael@0: SCRIPTNAME=dbupgrade.sh michael@0: if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for michael@0: CLEANUP="${SCRIPTNAME}" # cleaning this script will do it michael@0: fi michael@0: michael@0: echo "$SCRIPTNAME: DB upgrade tests ===============================" michael@0: } michael@0: michael@0: ############################ dbupgrade_main ############################ michael@0: # local shell function to upgrade certificate databases michael@0: ######################################################################## michael@0: dbupgrade_main() michael@0: { michael@0: # 'reset' the databases to initial values michael@0: echo "Reset databases to their initial values:" michael@0: cd ${HOSTDIR} michael@0: ${BINDIR}/certutil -D -n objsigner -d alicedir 2>&1 michael@0: ${BINDIR}/certutil -M -n FIPS_PUB_140_Test_Certificate -t "C,C,C" -d fips -f ${FIPSPWFILE} 2>&1 michael@0: ${BINDIR}/certutil -L -d fips 2>&1 michael@0: rm -f smime/alicehello.env michael@0: michael@0: # test upgrade to the new database michael@0: echo "nss" > ${PWFILE} michael@0: html_head "Legacy to shared Library update" michael@0: dirs="alicedir bobdir CA cert_extensions client clientCA dave eccurves eve ext_client ext_server SDR server serverCA stapling tools/copydir" michael@0: for i in $dirs michael@0: do michael@0: echo $i michael@0: if [ -d $i ]; then michael@0: echo "upgrading db $i" michael@0: ${BINDIR}/certutil -G -g 512 -d sql:$i -f ${PWFILE} -z ${NOISE_FILE} 2>&1 michael@0: html_msg $? 0 "Upgrading $i" michael@0: else michael@0: echo "skipping db $i" michael@0: html_msg 0 0 "No directory $i" michael@0: fi michael@0: done michael@0: michael@0: if [ -d fips ]; then michael@0: echo "upgrading db fips" michael@0: ${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: html_msg $? 0 "Upgrading fips" michael@0: # remove our temp certificate we created in the fist token michael@0: ${BINDIR}/certutil -F -n tmprsa -d sql:fips -f ${FIPSPWFILE} 2>&1 michael@0: ${BINDIR}/certutil -L -d sql:fips 2>&1 michael@0: fi michael@0: michael@0: html "
" michael@0: } michael@0: michael@0: ########################## dbupgrade_cleanup ########################### michael@0: # local shell function to finish this script (no exit since it might be michael@0: # sourced) michael@0: ######################################################################## michael@0: dbupgrade_cleanup() michael@0: { michael@0: cd ${QADIR} michael@0: . common/cleanup.sh michael@0: } michael@0: michael@0: ################################# main ################################# michael@0: michael@0: dbupgrade_init michael@0: dbupgrade_main michael@0: dbupgrade_cleanup