2 # Blackbox tests for kinit and kerberos integration with smbclient etc
3 # Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
4 # Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
8 Usage: test_kinit.sh SERVER USERNAME REALM DOMAIN PREFIX SMBCLIENT
24 samba4bindir
="$BINDIR"
25 samba4srcdir
="$SRCDIR/source4"
29 if test -x $BINDIR/samba4kinit
; then
31 samba4kinit
=bin
/samba4kinit
35 machineaccountccache
="$samba4srcdir/scripting/bin/machineaccountccache"
39 .
`dirname $0`/subunit.sh
40 .
`dirname $0`/common_test_fns.inc
48 echo $VALGRIND $PYTHON $samba4bindir/samba-tool drs
$function $SERVER -k yes $@
49 $VALGRIND $PYTHON $samba4bindir/samba-tool drs
$function $SERVER -k yes $@
51 if [ x
$status = x0
]; then
61 KRB5CCNAME
="$PREFIX/tmpccache"
65 if [ $heimdal -eq 1 ]; then
66 testit
"kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private
/secrets.keytab
--use-keytab $USERNAME || failed
=`expr $failed + 1`
68 testit
"kinit with keytab" $samba4kinit -k -t $PROVDIR/private
/secrets.keytab
$USERNAME || failed
=`expr $failed + 1`
71 #This is important because it puts the ticket for the old KVNO and password into a local ccache
72 test_smbclient
"Test login with kerberos ccache before password change" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
74 #check that drs bind works before we change the password (prime the ccache)
75 test_drs
bind "Test drs bind with with kerberos ccache" || failed
=`expr $failed + 1`
77 #check that drs options works before we change the password (prime the ccache)
78 test_drs options
"Test drs options with with kerberos ccache" || failed
=`expr $failed + 1`
80 testit
"change dc password" $PYTHON $samba4srcdir/scripting
/devel
/chgtdcpass
-s $PROVDIR/etc
/smb.conf || failed
=`expr $failed + 1`
82 #This is important because it shows that the old ticket remains valid (as it must) for incoming connections after the DC password is changed
83 test_smbclient
"Test login with kerberos ccache after password change" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
85 #check that drs bind works after we change the password
86 test_drs
bind "Test drs bind with new password" || failed
=`expr $failed + 1`
88 #check that drs options works after we change the password
89 test_drs options
"Test drs options with new password" || failed
=`expr $failed + 1`
91 testit
"change dc password (2nd time)" $PYTHON $samba4srcdir/scripting
/devel
/chgtdcpass
-s $PROVDIR/etc
/smb.conf || failed
=`expr $failed + 1`
93 # This is important because it shows that the old ticket is discarded if the server rejects it (as it must) after the password was changed twice in succession.
94 # This also ensures we handle the case where the domain is re-provisioned etc
95 test_smbclient
"Test login with kerberos ccache after 2nd password change" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
97 #check that drs bind works after we change the password a 2nd time
98 test_drs
bind "Test drs bind after 2nd password change" || failed
=`expr $failed + 1`
100 #check that drs options works after we change the password a 2nd time
101 test_drs options
"Test drs options after 2nd password change" || failed
=`expr $failed + 1`
103 #This confirms that the DC password is valid for a kinit too
104 if [ $heimdal -eq 1 ]; then
105 testit
"kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private
/secrets.keytab
--use-keytab $USERNAME || failed
=`expr $failed + 1`
107 testit
"kinit with keytab" $samba4kinit -k -t $PROVDIR/private
/secrets.keytab
$USERNAME || failed
=`expr $failed + 1`
109 test_smbclient
"Test login with kerberos ccache with fresh kinit" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
113 rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache