1#! /bin/csh -f
2#
3# Run cmstest, handsoff, any user, any environment. 
4# This uses a keychain we have right here for this purpose. It's insecure - we 
5# know its passphrase and use it here in the clear to unlock - and its private
6# keys have wide-open ACLs to avoid UI. We use the root used to generate the 
7# certs in that keychain in the -A option to newCmsTool. 
8#
9# We copy the test's keychain to ${BUILD_DIR}/cmsKeychain just to keep the UI spew to 
10# a minimum. 
11#
12
13#
14# safely look for this required env var
15#
16setenv | /usr/bin/grep LOCAL_BUILD_DIR > /dev/null
17if($status != 0) then
18        echo Please set env var LOCAL_BUILD_DIR.
19        exit(1)
20endif
21set BUILD_DIR=$LOCAL_BUILD_DIR
22
23set TESTDIR=`pwd`
24set CMS_KEYCHAIN_SRC=cmsKeychain
25set CMS_KEYCHAIN_DST=${BUILD_DIR}/cmsKeychain
26set CMS_KEYCHAIN_PASSWORD=cmsKeychain
27set CMS_KEYCHAIN_ROOT=cmsRoot.cer
28set USER1=user1@debug.apple.com
29set USER2=user2@debug.apple.com
30set QUIET=
31set OUR_QUIET=NO
32
33while ( $#argv > 0 )
34    switch ( "$argv[1]" )
35        case -q:
36            set QUIET="-q"
37			set OUR_QUIET=YES
38            shift
39            breaksw
40        default:
41            echo "Usage: cmstestHandsoff [-q(uiet)]"
42            exit(1)
43    endsw
44end
45
46echo Starting cmstestHandsoff
47
48set cmd="cp $CMS_KEYCHAIN_SRC $CMS_KEYCHAIN_DST"
49if($OUR_QUIET == NO) then
50	echo $cmd
51endif
52# ignore errors here...we'll soon fail if this does
53$cmd
54
55set cmd="/usr/bin/security unlock -p $CMS_KEYCHAIN_PASSWORD $CMS_KEYCHAIN_DST"
56if($OUR_QUIET == NO) then
57	echo $cmd
58endif
59$cmd || exit(1)
60
61set cmd="./cmstest -s $USER1 -S $USER2 -k $CMS_KEYCHAIN_DST -a $CMS_KEYCHAIN_ROOT $QUIET"
62if($OUR_QUIET == NO) then
63	echo $cmd
64endif
65$cmd || exit(1)
66
67# and try to be nice
68set cmd="rm $CMS_KEYCHAIN_DST"
69if($OUR_QUIET == NO) then
70	echo $cmd
71endif
72$cmd || exit(1)
73
74if($OUR_QUIET == NO) then
75	echo === cmstestHandsoff Succeeded ===
76endif
77
78