5 Usage: test_update_keytab.sh DOMAIN CONFIGURATION
10 incdir
="$(dirname "$0")/../../../testprogs/blackbox"
11 .
"${incdir}/subunit.sh"
12 .
"${incdir}/common_test_fns.inc"
18 samba_wbinfo
="$BINDIR/wbinfo"
19 samba_net
="$BINDIR/net $CONFIGURATION"
20 samba_rpcclient
="$BINDIR/rpcclient $CONFIGURATION"
21 smbclient
="${BINDIR}/smbclient"
22 smbcontrol
="$BINDIR/smbcontrol"
24 keytabs_sync_kvno
="keytab0k keytab1k keytab2k keytab3k"
25 keytabs_nosync_kvno
="keytab0 keytab1 keytab2 keytab3"
26 keytabs_all
="$keytabs_sync_kvno $keytabs_nosync_kvno"
28 check_net_ads_testjoin
()
30 UID_WRAPPER_ROOT
=1 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_INITIAL_EUID
=0 $samba_net ads testjoin
34 # find the biggest vno and store it into global variable vno
38 local cmd
="UID_WRAPPER_ROOT=1 UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $samba_net ads keytab list $keytab"
45 if [ $ret != 0 ] ; then
51 vno
=$
(echo "$out" |
sort -n |
tail -1 |
awk '{printf $1}')
53 if [ -z "$vno" ] ; then
54 echo "There is no key with vno in the keytab list above."
65 # command to change the password
68 # get biggest vno before password change
69 get_biggest_vno
"$PREFIX_ABS/clusteredmember/node.0/keytab0"
71 get_biggest_vno
"$PREFIX_ABS/clusteredmember/node.1/keytab0"
73 get_biggest_vno
"$PREFIX_ABS/clusteredmember/node.2/keytab0"
76 if [ ! "$old_vno_node0" -gt 0 ] ; then
77 echo "There is no key with vno in the keytab list above."
80 if [ "$old_vno_node0" -ne "$old_vno_node1" ] ||
[ "$old_vno_node0" -ne "$old_vno_node2" ] ; then
81 echo "VNOs differs on nodes!"
90 if [ $ret != 0 ] ; then
97 cmd
="UID_WRAPPER_ROOT=1 UID_WRAPPER_INITIAL_RUID=0 UID_WRAPPER_INITIAL_EUID=0 $samba_net ads testjoin"
102 if [ $ret != 0 ] ; then
104 echo "command failed"
108 # if keytab was updated the bigest vno should be incremented by one
109 get_biggest_vno
"$PREFIX_ABS/clusteredmember/node.0/keytab0"
111 get_biggest_vno
"$PREFIX_ABS/clusteredmember/node.0/keytab0"
113 get_biggest_vno
"$PREFIX_ABS/clusteredmember/node.0/keytab0"
116 if [ ! "$new_vno_node0" -eq $
((old_vno_node0
+ 1)) ] ; then
117 echo "Old vno=$old_vno_node0, new vno=$new_vno_node0. Increment by one failed."
120 if [ "$new_vno_node0" -ne "$new_vno_node1" ] ||
[ "$new_vno_node0" -ne "$new_vno_node2" ] ; then
121 echo "VNOs differs on nodes!"
130 UID_WRAPPER_INITIAL_EUID
=0 UID_WRAPPER_INITIAL_RUID
=0 UID_WRAPPER_ROOT
=1 $samba_net ads keytab create ||
return 1
134 DC_DNSNAME
="${DC_SERVER}.${REALM}"
135 SMBCLIENT_UNC
="//${DC_DNSNAME}/tmp"
137 install source3/script
/updatekeytab_test.sh
"$PREFIX_ABS/clusteredmember/updatekeytab.sh"
138 global_inject_conf
=$
(dirname $SMB_CONF_PATH)/global_inject.conf
139 echo "sync machine password script = $PREFIX_ABS/clusteredmember/updatekeytab.sh" >$global_inject_conf
140 UID_WRAPPER_ROOT
=1 $smbcontrol winbindd reload-config
142 testit
"net_ads_testjoin_initial" check_net_ads_testjoin || failed
=$
((failed
+ 1))
144 # To have both old and older password we do one unnecessary password change:
145 testit
"wbinfo_change_secret_initial" \
146 "$samba_wbinfo" --change-secret --domain="${DOMAIN}" \
147 || failed
=$
((failed
+ 1))
149 testit
"wbinfo_check_secret_initial" \
150 "$samba_wbinfo" --check-secret --domain="${DOMAIN}" \
151 || failed
=$
((failed
+ 1))
153 # Create/sync all keytabs
154 testit
"net_ads_keytab_sync" test_keytab_create || failed
=$
((failed
+ 1))
156 testit
"net_ads_testjoin_after_sync" check_net_ads_testjoin || failed
=$
((failed
+ 1))
158 testit
"wbinfo_change_secret_after_sync" \
159 test_pwd_change
"wbinfo_changesecret" \
160 "$samba_wbinfo --change-secret --domain=${DOMAIN}" \
161 || failed
=$
((failed
+ 1))
163 testit
"wbinfo_check_secret_after_sync" \
164 "$samba_wbinfo" --check-secret --domain="${DOMAIN}" \
165 || failed
=$
((failed
+ 1))
167 test_smbclient
"Test machine login with the changed secret" \
168 "ls" "${SMBCLIENT_UNC}" \
170 failed
=$
((failed
+ 1))
172 testit
"net_ads_testjoin_final" check_net_ads_testjoin || failed
=$
((failed
+ 1))
174 echo "" >$global_inject_conf
175 UID_WRAPPER_ROOT
=1 $smbcontrol winbindd reload-config
177 testok
"$0" "$failed"