/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. # mozilla/security/nss/tests/dbupgrade/dbupgrade.sh
  41. #
  42. # Script to upgrade databases to Shared DB
  43. #
  44. # needs to work on all Unix and Windows platforms
  45. #
  46. # special strings
  47. # ---------------
  48. # FIXME ... known problems, search for this string
  49. # NOTE .... unexpected behavior
  50. #
  51. ########################################################################
  52. ############################ dbupgrade_init ############################
  53. # local shell function to initialize this script
  54. ########################################################################
  55. dbupgrade_init()
  56. {
  57. if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
  58. cd ${QADIR}/common
  59. . ./init.sh
  60. fi
  61. if [ ! -r "${CERT_LOG_FILE}" ]; then # we need certificates here
  62. cd ${QADIR}/cert
  63. . ./cert.sh
  64. fi
  65. if [ ! -d ${HOSTDIR}/SDR ]; then # we also need sdr as well
  66. cd ${QADIR}/sdr
  67. . ./sdr.sh
  68. fi
  69. SCRIPTNAME=dbupgrade.sh
  70. if [ -z "${CLEANUP}" ] ; then # if nobody else is responsible for
  71. CLEANUP="${SCRIPTNAME}" # cleaning this script will do it
  72. fi
  73. echo "$SCRIPTNAME: DB upgrade tests ==============================="
  74. }
  75. ############################ dbupgrade_main ############################
  76. # local shell function to upgrade certificate databases
  77. ########################################################################
  78. dbupgrade_main()
  79. {
  80. # 'reset' the databases to initial values
  81. echo "Reset databases to their initial values:"
  82. cd ${HOSTDIR}
  83. ${BINDIR}/certutil -D -n objsigner -d alicedir 2>&1
  84. ${BINDIR}/certutil -M -n FIPS_PUB_140_Test_Certificate -t "C,C,C" -d fips -f ${FIPSPWFILE} 2>&1
  85. ${BINDIR}/certutil -L -d fips 2>&1
  86. rm -f smime/alicehello.env
  87. # test upgrade to the new database
  88. echo "nss" > ${PWFILE}
  89. html_head "Legacy to shared Library update"
  90. dirs="alicedir bobdir CA cert_extensions client clientCA dave eccurves eve ext_client ext_server SDR server serverCA tools/copydir"
  91. for i in $dirs
  92. do
  93. echo $i
  94. if [ -d $i ]; then
  95. echo "upgrading db $i"
  96. ${BINDIR}/certutil -G -g 512 -d sql:$i -f ${PWFILE} -z ${NOISE_FILE} 2>&1
  97. html_msg $? 0 "Upgrading $i"
  98. else
  99. echo "skipping db $i"
  100. html_msg 0 0 "No directory $i"
  101. fi
  102. done
  103. if [ -d fips ]; then
  104. echo "upgrading db fips"
  105. ${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
  106. html_msg $? 0 "Upgrading fips"
  107. # remove our temp certificate we created in the fist token
  108. ${BINDIR}/certutil -F -n tmprsa -d sql:fips -f ${FIPSPWFILE} 2>&1
  109. ${BINDIR}/certutil -L -d sql:fips 2>&1
  110. fi
  111. html "</TABLE><BR>"
  112. }
  113. ########################## dbupgrade_cleanup ###########################
  114. # local shell function to finish this script (no exit since it might be
  115. # sourced)
  116. ########################################################################
  117. dbupgrade_cleanup()
  118. {
  119. cd ${QADIR}
  120. . common/cleanup.sh
  121. }
  122. ################################# main #################################
  123. dbupgrade_init
  124. dbupgrade_main
  125. dbupgrade_cleanup