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