2 # Copyright (C) 2015 Stefan Metzmacher <metze@samba.org>
6 Usage: test_kinit_trusts.sh SERVER USERNAME PASSWORD REALM DOMAIN TRUST_USERNAME TRUST_PASSWORD TRUST_REALM TRUST_DOMAIN PREFIX TYPE ENCTYPE
29 samba4bindir
="$BINDIR"
31 if test -x $samba4bindir/samba4kinit
; then
32 samba4kinit
=$samba4bindir/samba4kinit
35 smbclient
="$samba4bindir/smbclient"
36 wbinfo
="$samba4bindir/wbinfo"
37 rpcclient
="$samba4bindir/rpcclient"
38 samba_tool
="$samba4bindir/samba-tool"
40 .
`dirname $0`/subunit.sh
41 .
`dirname $0`/common_test_fns.inc
43 unc
="//$SERVER.$REALM/tmp"
47 KRB5CCNAME_PATH
="$PREFIX/tmpccache"
48 KRB5CCNAME
="FILE:$KRB5CCNAME_PATH"
50 rm -rf $KRB5CCNAME_PATH
52 echo $TRUST_PASSWORD > $PREFIX/tmppassfile
53 testit
"kinit with password" $samba4kinit $enctype --password-file=$PREFIX/tmppassfile
--request-pac $TRUST_USERNAME@
$TRUST_REALM || failed
=`expr $failed + 1`
54 test_smbclient
"Test login with user kerberos ccache" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
55 rm -rf $KRB5CCNAME_PATH
57 # Test with smbclient4
58 smbclient
="$samba4bindir/smbclient4"
59 testit
"kinit with password" $samba4kinit $enctype --password-file=$PREFIX/tmppassfile
--request-pac $TRUST_USERNAME@
$TRUST_REALM || failed
=`expr $failed + 1`
60 test_smbclient
"Test login with user kerberos ccache (smbclient4)" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
61 rm -rf $KRB5CCNAME_PATH
63 testit
"kinit with password (enterprise style)" $samba4kinit $enctype --enterprise --password-file=$PREFIX/tmppassfile
--request-pac $TRUST_USERNAME@
$TRUST_REALM || failed
=`expr $failed + 1`
64 smbclient
="$samba4bindir/smbclient"
65 test_smbclient
"Test login with user kerberos ccache" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
67 if test x
"${TYPE}" = x
"forest" ;then
68 testit
"kinit with password (upn enterprise style)" $samba4kinit $enctype --enterprise --password-file=$PREFIX/tmppassfile
--request-pac testdenied_upn@
${TRUST_REALM}.upn || failed
=`expr $failed + 1`
69 test_smbclient
"Test login with user kerberos ccache" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
72 testit
"kinit with password (windows style)" $samba4kinit $enctype --renewable --windows --password-file=$PREFIX/tmppassfile
--request-pac $TRUST_USERNAME@
$TRUST_REALM || failed
=`expr $failed + 1`
73 test_smbclient
"Test login with user kerberos ccache" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
75 testit
"kinit renew ticket" $samba4kinit $enctype --request-pac -R
77 test_smbclient
"Test login with kerberos ccache" 'ls' "$unc" -k yes || failed
=`expr $failed + 1`
79 testit
"check time with kerberos ccache" $VALGRIND $samba_tool time $SERVER.
$REALM $CONFIGURATION -k yes $@ || failed
=`expr $failed + 1`
81 lowerrealm
=$
(echo $TRUST_REALM |
tr '[A-Z]' '[a-z]')
82 test_smbclient
"Test login with user kerberos lowercase realm" 'ls' "$unc" -k yes -U$TRUST_USERNAME@
$lowerrealm%$TRUST_PASSWORD || failed
=`expr $failed + 1`
83 test_smbclient
"Test login with user kerberos lowercase realm 2" 'ls' "$unc" -k yes -U$TRUST_USERNAME@
$TRUST_REALM%$TRUST_PASSWORD --realm=$lowerrealm || failed
=`expr $failed + 1`
85 # Test the outgoing direction
86 SMBCLIENT_UNC
="//$TRUST_SERVER.$TRUST_REALM/tmp"
87 test_smbclient
"Test user login with the first outgoing secret" 'ls' "$unc" -k yes -U$USERNAME@
$REALM%$PASSWORD || failed
=`expr $failed + 1`
89 testit_expect_failure
"setpassword should not work" $VALGRIND $samba_tool user setpassword
"${TRUST_DOMAIN}\$" --random-password || failed
=`expr $failed + 1`
91 testit
"wbinfo ping dc" $VALGRIND $wbinfo --ping-dc --domain=$TRUST_DOMAIN || failed
=`expr $failed + 1`
92 testit
"wbinfo change outgoing trust pw" $VALGRIND $wbinfo --change-secret --domain=$TRUST_DOMAIN || failed
=`expr $failed + 1`
93 testit
"wbinfo check outgoing trust pw" $VALGRIND $wbinfo --check-secret --domain=$TRUST_DOMAIN || failed
=`expr $failed + 1`
95 test_smbclient
"Test user login with the changed outgoing secret" 'ls' "$unc" -k yes -U$USERNAME@
$REALM%$PASSWORD || failed
=`expr $failed + 1`
97 rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript