tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

policy.sh (1929B)


      1 #! /bin/bash
      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/policy/policy.sh
     10 #
     11 # Script to test NSS crypto policy code
     12 #
     13 ########################################################################
     14 
     15 policy_init()
     16 {
     17  SCRIPTNAME=policy.sh      # sourced - $0 would point to all.sh
     18 
     19  if [ -z "${CLEANUP}" ] ; then     # if nobody else is responsible for
     20      CLEANUP="${SCRIPTNAME}"       # cleaning this script will do it
     21  fi
     22 
     23  if [ -z "${INIT_SOURCED}" -o "${INIT_SOURCED}" != "TRUE" ]; then
     24      cd ../common
     25      . ./init.sh
     26  fi
     27  SCRIPTNAME=policy.sh
     28 
     29 }
     30 
     31 policy_cleanup()
     32 {
     33  cd ${QADIR}
     34  . common/cleanup.sh
     35 }
     36 
     37 policy_run_tests()
     38 {
     39  html_head "CRYPTO-POLICY"
     40 
     41  POLICY_INPUT=${QADIR}/policy/crypto-policy.txt
     42 
     43  ignore_blank_lines ${POLICY_INPUT} | \
     44  while read value policy match testname
     45  do
     46    echo "$SCRIPTNAME: running \"$testname\" ----------------------------"
     47    policy=`echo ${policy} | sed -e 's;_; ;g'`
     48    match=`echo ${match} | sed -e 's;_; ;g'`
     49    POLICY_FILE="${TMP}/nss-policy"
     50 
     51    echo "$SCRIPTNAME: policy: \"$policy\""
     52 
     53    cat > "$POLICY_FILE" << ++EOF++
     54 library=
     55 name=Policy
     56 NSS=flags=policyOnly,moduleDB
     57 ++EOF++
     58    echo "config=\"${policy}\"" >> "$POLICY_FILE"
     59    echo "" >> "$POLICY_FILE"
     60 
     61    nss-policy-check -f identifier -f value "$POLICY_FILE" >${TMP}/$HOST.tmp.$$ 2>&1
     62    ret=$?
     63    cat ${TMP}/$HOST.tmp.$$
     64 
     65    html_msg $ret $value "\"${testname}\"" \
     66        "produced a returncode of $ret, expected is $value"
     67 
     68    egrep "${match}" ${TMP}/$HOST.tmp.$$
     69    ret=$?
     70    html_msg $ret 0 "\"${testname}\" output is expected to match \"${match}\""
     71 
     72  done
     73  html "</TABLE><BR>"
     74 }
     75 
     76 policy_init
     77 policy_run_tests
     78 policy_cleanup