g_lock: Fix uninitalized variable reads
[Samba.git] / testprogs / blackbox / test_client_kerberos.sh
blobf56698603b805c13b1a0df491c53934c21c7c1c1
1 #!/bin/sh
2 # Blackbox tests for kerberos client options
3 # Copyright (c) 2019 Andreas Schneider <asn@samba.org>
5 if [ $# -lt 6 ]; then
6 cat <<EOF
7 Usage: test_client_kerberos.sh DOMAIN REALM USERNAME PASSWORD SERVER PREFIX CONFIGURATION
8 EOF
9 exit 1;
12 DOMAIN=$1
13 REALM=$2
14 USERNAME=$3
15 PASSWORD=$4
16 SERVER=$5
17 PREFIX=$6
18 CONFIGURATION=$7
19 shift 7
21 failed=0
23 . $(dirname $0)/subunit.sh
24 . $(dirname $0)/common_test_fns.inc
26 samba_bindir="$BINDIR"
27 samba_rpcclient="$samba_bindir/rpcclient"
28 samba_smbclient="$samba_bindir/smbclient"
29 samba_smbtorture="$samba_bindir/smbtorture"
31 samba_kinit=kinit
32 if test -x ${samba_bindir}/samba4kinit; then
33 samba_kinit=${samba_bindir}/samba4kinit
36 samba_kdestroy=kdestroy
37 if test -x ${samba_bindir}/samba4kdestroy; then
38 samba_kinit=${samba_bindir}/samba4kdestroy
41 test_rpc_getusername_legacy() {
42 eval echo "$cmd"
43 out=$(eval $cmd)
44 ret=$?
45 if [ $ret -ne 0 ] ; then
46 echo "Failed to connect! Error: $ret"
47 echo "$out"
48 return 1
51 echo "$out" | grep -q "Account Name: $USERNAME, Authority Name: $DOMAIN"
52 ret=$?
53 if [ $ret -ne 0 ] ; then
54 echo "Incorrect account/authority name! Error: $ret"
55 echo "$out"
56 return 1
59 return 0
62 test_smbclient_legacy() {
63 eval echo "$cmd"
64 out=$(eval $cmd)
65 ret=$?
66 if [ $ret -ne 0 ] ; then
67 echo "Failed to connect! Error: $ret"
68 echo "$out"
71 return $ret
74 ### CHECK -k flag
76 ### RPCCLIENT
77 cmd='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} -c getusername 2>&1'
78 testit "test rpcclient legacy ntlm" \
79 test_rpc_getusername_legacy || \
80 failed=$(expr $failed + 1)
82 cmd='echo ${PASSWORD} | USER=${USERNAME} $samba_rpcclient ncacn_np:${SERVER} --configfile=${CONFIGURATION} -c getusername 2>&1'
83 testit "test rpcclient legacy ntlm interactive" \
84 test_rpc_getusername_legacy || \
85 failed=$(expr $failed + 1)
87 cmd='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} --configfile=${CONFIGURATION} -c getusername 2>&1'
88 testit "test rpcclient legacy ntlm interactive with -U" \
89 test_rpc_getusername_legacy || \
90 failed=$(expr $failed + 1)
92 cmd='$samba_rpcclient ncacn_np:${SERVER} -U${USERNAME}%${PASSWORD} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
93 testit "test rpcclient legacy kerberos" \
94 test_rpc_getusername_legacy || \
95 failed=$(expr $failed + 1)
97 cmd='echo ${PASSWORD} | $samba_rpcclient ncacn_np:${SERVER} -U${USERNAME} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
98 testit_expect_failure "test rpcclient legacy kerberos interactive (negative test)" \
99 test_rpc_getusername_legacy || \
100 failed=$(expr $failed + 1)
102 kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
103 cmd='$samba_rpcclient ncacn_np:${SERVER} -k --configfile=${CONFIGURATION} -c getusername 2>&1'
104 testit "test rpcclient legacy kerberos ccache" \
105 test_rpc_getusername_legacy || \
106 failed=$(expr $failed + 1)
107 $samba_kdestroy
109 ### SMBTORTURE
111 cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
112 testit "test smbtorture legacy default" \
113 test_rpc_getusername_legacy || \
114 failed=$(expr $failed + 1)
116 cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} -k no --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
117 testit "test smbtorture legacy ntlm (kerberos=no)" \
118 test_rpc_getusername_legacy || \
119 failed=$(expr $failed + 1)
121 cmd='$samba_smbtorture -U${USERNAME}%${PASSWORD} -k yes --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
122 testit "test smbtorture legacy kerberos=yes" \
123 test_rpc_getusername_legacy || \
124 failed=$(expr $failed + 1)
126 kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
127 cmd='$samba_smbtorture -k yes --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
128 testit "test smbtorture legacy kerberos=yes ccache" \
129 test_rpc_getusername_legacy || \
130 failed=$(expr $failed + 1)
131 $samba_kdestroy
133 kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
134 cmd='$samba_smbtorture -k no --configfile=${CONFIGURATION} --maximum-runtime=30 --basedir=$PREFIX --option=torture:progress=no --target=samba4 ncacn_np:${SERVER} rpc.lsa-getuser 2>&1'
135 testit_expect_failure "test smbtorture legacy kerberos=no ccache (negative test)" \
136 test_rpc_getusername_legacy || \
137 failed=$(expr $failed + 1)
138 $samba_kdestroy
140 ### SMBCLIENT
141 cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} --configfile=${CONFIGURATION} -c "ls; quit"'
142 testit "test smbclient legacy ntlm" \
143 test_smbclient_legacy || \
144 failed=$(expr $failed + 1)
146 cmd='echo ${PASSWORD} | USER=$USERNAME $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} --configfile=${CONFIGURATION} -c "ls; quit"'
147 testit "test smbclient legacy ntlm interactive" \
148 test_smbclient_legacy || \
149 failed=$(expr $failed + 1)
151 cmd='echo ${PASSWORD} | $samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME} --configfile=${CONFIGURATION} -c "ls; quit"'
152 testit "test smbclient legacy ntlm interactive with -U" \
153 test_smbclient_legacy || \
154 failed=$(expr $failed + 1)
156 cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -U${USERNAME}%${PASSWORD} -k --configfile=${CONFIGURATION} -c "ls; quit"'
157 testit "test smbclient legacy kerberos" \
158 test_smbclient_legacy || \
159 failed=$(expr $failed + 1)
161 kerberos_kinit $samba_kinit ${USERNAME}@${REALM} ${PASSWORD}
162 cmd='$samba_smbclient //${SERVER}/tmp -W ${DOMAIN} -k --configfile=${CONFIGURATION} -c "ls; quit"'
163 testit "test smbclient legacy kerberos ccache" \
164 test_smbclient_legacy || \
165 failed=$(expr $failed + 1)
166 $samba_kdestroy
168 exit $failed