PageRenderTime 24ms CodeModel.GetById 17ms app.highlight 5ms RepoModel.GetById 1ms app.codeStats 0ms

/security/nss/tests/dbupgrade/dbupgrade.sh

http://github.com/zpao/v8monkey
Shell | 138 lines | 60 code | 13 blank | 65 comment | 8 complexity | 850bfcce38ad7c37b88803c8d6eee37e MD5 | raw file
  1#!/bin/sh
  2#
  3# ***** BEGIN LICENSE BLOCK *****
  4# Version: MPL 1.1/GPL 2.0/LGPL 2.1
  5#
  6# The contents of this file are subject to the Mozilla Public License Version
  7# 1.1 (the "License"); you may not use this file except in compliance with
  8# the License. You may obtain a copy of the License at
  9# http://www.mozilla.org/MPL/
 10#
 11# Software distributed under the License is distributed on an "AS IS" basis,
 12# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
 13# for the specific language governing rights and limitations under the
 14# License.
 15#
 16# The Original Code is the Netscape security libraries.
 17#
 18# The Initial Developer of the Original Code is
 19# Netscape Communications Corporation.
 20# Portions created by the Initial Developer are Copyright (C) 1994-2009
 21# the Initial Developer. All Rights Reserved.
 22#
 23# Contributor(s):
 24#
 25# Alternatively, the contents of this file may be used under the terms of
 26# either the GNU General Public License Version 2 or later (the "GPL"), or
 27# the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
 28# in which case the provisions of the GPL or the LGPL are applicable instead
 29# of those above. If you wish to allow use of your version of this file only
 30# under the terms of either the GPL or the LGPL, and not to allow others to
 31# use your version of this file under the terms of the MPL, indicate your
 32# decision by deleting the provisions above and replace them with the notice
 33# and other provisions required by the GPL or the LGPL. If you do not delete
 34# the provisions above, a recipient may use your version of this file under
 35# the terms of any one of the MPL, the GPL or the LGPL.
 36#
 37# ***** END LICENSE BLOCK *****
 38
 39########################################################################
 40#
 41# mozilla/security/nss/tests/dbupgrade/dbupgrade.sh
 42#
 43# Script to upgrade databases to Shared DB
 44#
 45# needs to work on all Unix and Windows platforms
 46#
 47# special strings
 48# ---------------
 49#   FIXME ... known problems, search for this string
 50#   NOTE .... unexpected behavior
 51#
 52########################################################################
 53
 54############################ dbupgrade_init ############################
 55# local shell function to initialize this script
 56########################################################################
 57dbupgrade_init()
 58{
 59	if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then 
 60		cd ${QADIR}/common
 61		. ./init.sh
 62	fi
 63	
 64	if [ ! -r "${CERT_LOG_FILE}" ]; then  # we need certificates here
 65		cd ${QADIR}/cert 
 66		. ./cert.sh
 67	fi
 68
 69	if [ ! -d ${HOSTDIR}/SDR ]; then  # we also need sdr as well
 70		cd ${QADIR}/sdr
 71		. ./sdr.sh
 72	fi
 73	
 74	SCRIPTNAME=dbupgrade.sh
 75	if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
 76		CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
 77	fi
 78	
 79	echo "$SCRIPTNAME: DB upgrade tests ==============================="
 80}
 81
 82############################ dbupgrade_main ############################
 83# local shell function to upgrade certificate databases
 84########################################################################
 85dbupgrade_main()
 86{
 87	# 'reset' the databases to initial values
 88	echo "Reset databases to their initial values:"
 89	cd ${HOSTDIR}
 90	${BINDIR}/certutil -D -n objsigner -d alicedir 2>&1
 91	${BINDIR}/certutil -M -n FIPS_PUB_140_Test_Certificate -t "C,C,C" -d fips -f ${FIPSPWFILE} 2>&1
 92	${BINDIR}/certutil -L -d fips 2>&1
 93	rm -f smime/alicehello.env
 94	
 95	# test upgrade to the new database
 96	echo "nss" > ${PWFILE}
 97	html_head "Legacy to shared Library update"
 98	dirs="alicedir bobdir CA cert_extensions client clientCA dave eccurves eve ext_client ext_server SDR server serverCA tools/copydir"
 99	for i in $dirs
100	do
101		echo $i
102		if [ -d $i ]; then
103			echo "upgrading db $i"
104			${BINDIR}/certutil -G -g 512 -d sql:$i -f ${PWFILE} -z ${NOISE_FILE} 2>&1
105			html_msg $? 0 "Upgrading $i"
106		else
107			echo "skipping db $i"
108			html_msg 0 0 "No directory $i"
109		fi
110	done
111	
112	if [ -d fips ]; then
113		echo "upgrading db fips"
114		${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
115		html_msg $? 0 "Upgrading fips"
116		# remove our temp certificate we created in the fist token
117		${BINDIR}/certutil -F -n tmprsa -d sql:fips -f ${FIPSPWFILE} 2>&1
118		${BINDIR}/certutil -L -d sql:fips 2>&1
119	fi
120	
121	html "</TABLE><BR>"
122}
123
124########################## dbupgrade_cleanup ###########################
125# local shell function to finish this script (no exit since it might be
126# sourced)
127########################################################################
128dbupgrade_cleanup()
129{
130	cd ${QADIR}
131	. common/cleanup.sh
132}
133
134################################# main #################################
135
136dbupgrade_init
137dbupgrade_main
138dbupgrade_cleanup