]> git.samba.org - metze/samba/wip.git/blob - testprogs/blackbox/test_s4u_heimdal.sh
c63eeaa2e30d0c38f7dafcb7cbb906d1d064e9ea
[metze/samba/wip.git] / testprogs / blackbox / test_s4u_heimdal.sh
1 #!/bin/sh
2
3 if [ $# -lt 5 ]; then
4 cat <<EOF
5 Usage: test_kinit.sh SERVER USERNAME PASSWORD REALM DOMAIN PREFIX
6 EOF
7 exit 1;
8 fi
9
10 SERVER=$1
11 USERNAME=$2
12 PASSWORD=$3
13 REALM=$4
14 DOMAIN=$5
15 TRUST_SERVER=$6
16 TRUST_USERNAME=$7
17 TRUST_PASSWORD=$8
18 TRUST_REALM=$9
19 TRUST_DOMAIN=${10}
20 PREFIX=${11}
21 shift 11
22 failed=0
23
24
25 samba_tool="$VALGRIND $PYTHON $BINDIR/samba-tool"
26
27 samba4kinit=kinit
28 if test -x $BINDIR/samba4kinit; then
29         samba4kinit=$BINDIR/samba4kinit
30 fi
31
32 samba4kgetcred=kgetcred
33 if test -x $BINDIR/samba4kgetcred; then
34         samba4kgetcred=$BINDIR/samba4kgetcred
35 fi
36
37 . `dirname $0`/subunit.sh
38 . `dirname $0`/common_test_fns.inc
39
40 ocache="$PREFIX/tmpoutcache"
41 KRB5CCNAME_PATH="$PREFIX/tmpccache"
42 KRB5CCNAME="FILE:$KRB5CCNAME_PATH"
43 export KRB5CCNAME
44 rm -rf $KRB5CCNAME_PATH
45
46 princ=test_impersonate_princ
47 impersonator=test_impersonator.$REALM
48 target="CIFS/$SERVER.$REALM"
49
50
51 testit "add impersonator principal" $samba_tool user add $impersonator $PASSWORD || failed=`expr $failed + 1`
52 testit "become a service" $samba_tool spn add "HOST/$impersonator" $impersonator || failed=`expr $failed + 1`
53
54 testit "set TrustedToAuthForDelegation" $samba_tool delegation for-any-protocol $impersonator on || failed=`expr $failed + 1`
55 testit "add msDS-AllowedToDelegateTo" $samba_tool delegation add-service $impersonator $target || failed=`expr $failed + 1`
56
57 testit "add a new principal" $samba_tool user add $princ --random-password || failed=`expr $failed + 1`
58 testit "set not-delegated flag" $samba_tool user sensitive $princ on || failed=`expr $failed + 1`
59
60
61 echo $PASSWORD > $PREFIX/tmppassfile
62 testit "kinit impersonator" $samba4kinit -f --password-file=$PREFIX/tmppassfile $impersonator || failed=`expr $failed + 1`
63
64 testit "test S4U2Self with normal user" $samba4kgetcred --out-cache=$ocache --forwardable --impersonate=${USERNAME} $impersonator || failed=`expr $failed + 1`
65 testit "test S4U2Proxy with normal user" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=`expr $failed + 1`
66
67 testit "test S4U2Self with sensitive user" $samba4kgetcred --out-cache=$ocache --forwardable --impersonate=$princ $impersonator || failed=`expr $failed + 1`
68 testit_expect_failure "test S4U2Proxy with sensitive user" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=`expr $failed + 1`
69
70 rm -f $ocache
71 testit "unset not-delegated flag" $samba_tool user sensitive $princ off || failed=`expr $failed + 1`
72
73 testit "test S4U2Self after unsetting ND flag" $samba4kgetcred --out-cache=$ocache --forwardable --impersonate=$princ $impersonator || failed=`expr $failed + 1`
74 testit "test S4U2Proxy after unsetting ND flag" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=`expr $failed + 1`
75
76 testit "kinit user cache" $samba4kinit -c $ocache -f --password-file=$PREFIX/tmppassfile $USERNAME || failed=`expr $failed + 1`
77 testit "get a ticket to impersonator" $samba4kgetcred -c $ocache --forwardable $impersonator || failed=`expr $failed + 1`
78 testit "test S4U2Proxy evidence ticket obtained by TGS" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=`expr $failed + 1`
79
80 echo $TRUST_PASSWORD > $PREFIX/tmppassfile
81 testit "kinit trust user cache" $samba4kinit -c $ocache -f --password-file=$PREFIX/tmppassfile $TRUST_USERNAME@$TRUST_REALM || failed=`expr $failed + 1`
82 testit "get a ticket to impersonator for trust user" $samba4kgetcred -c $ocache --forwardable $impersonator || failed=`expr $failed + 1`
83 testit "test S4U2Proxy evidence ticket obtained by TGS of trust user" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=`expr $failed + 1`
84
85 echo $PASSWORD > $PREFIX/tmppassfile
86 testit "set not-delegated on impersonator" $samba_tool user sensitive $impersonator on || failed=`expr $failed + 1`
87 testit "kinit user cache again" $samba4kinit -c $ocache -f --password-file=$PREFIX/tmppassfile $USERNAME || failed=`expr $failed + 1`
88 testit "get a ticket to sensitive impersonator" $samba4kgetcred -c $ocache --forwardable $impersonator || failed=`expr $failed + 1`
89 testit_expect_failure "test S4U2Proxy using received ticket" $samba4kgetcred --out-cache=$ocache --delegation-credential-cache=${ocache} $target || failed=`expr $failed + 1`
90
91
92 rm -f $ocache $PREFIX/tmpccache $PREFIX/tmppassfile
93 exit $failed