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 PASSWORD REALM DOMAIN PREFIX ENCTYPE SMBCLIENT
24 samba4bindir
="$BINDIR"
25 samba4srcdir
="$SRCDIR/source4"
26 samba4kinit
="$samba4bindir/samba4kinit"
27 samba_tool
="$samba4bindir/samba-tool"
28 ldbmodify
="$samba4bindir/ldbmodify"
29 ldbsearch
="$samba4bindir/ldbsearch"
30 rkpty
="$samba4bindir/rkpty"
31 samba4kpasswd
="$samba4bindir/samba4kpasswd"
32 enableaccount
="$samba_tool user enable"
33 machineaccountccache
="$samba4srcdir/scripting/bin/machineaccountccache"
35 .
`dirname $0`/subunit.sh
43 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp
-c "$cmd" $@
45 if [ x
$status = x0
]; then
55 PWSETCONFIG
="-H ldap://$SERVER -U$USERNAME%$PASSWORD"
58 KRB5CCNAME
="$PREFIX/tmpccache"
61 testit
"reset password policies beside of minimum password age of 0 days" $VALGRIND $samba_tool domain passwordsettings
$PWSETCONFIG set --complexity=default
--history-length=default
--min-pwd-length=default
--min-pwd-age=0 --max-pwd-age=default || failed
=`expr $failed + 1`
63 echo $PASSWORD > $PREFIX/tmppassfile
64 #testit "kinit with keytab" $samba4kinit $enctype --keytab=$PREFIX/dc/private/secrets.keytab $SERVER\$@$REALM || failed=`expr $failed + 1`
65 testit
"kinit with password" $samba4kinit $enctype --password-file=$PREFIX/tmppassfile
--request-pac $USERNAME@
$REALM || failed
=`expr $failed + 1`
66 testit
"kinit with password (enterprise style)" $samba4kinit $enctype --enterprise --password-file=$PREFIX/tmppassfile
--request-pac $USERNAME@
$REALM || failed
=`expr $failed + 1`
67 testit
"kinit with password (windows style)" $samba4kinit $enctype --renewable --windows --password-file=$PREFIX/tmppassfile
--request-pac $USERNAME@
$REALM || failed
=`expr $failed + 1`
68 testit
"kinit renew ticket" $samba4kinit $enctype --request-pac -R
70 test_smbclient
"Test login with kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
72 testit
"check time with kerberos ccache" $VALGRIND $samba_tool time $SERVER $CONFIGURATION -k yes $@ || failed
=`expr $failed + 1`
75 echo $USERPASS > $PREFIX/tmpuserpassfile
76 testit
"add user with kerberos ccache" $VALGRIND $samba_tool user create nettestuser
$USERPASS $CONFIGURATION -k yes $@ || failed
=`expr $failed + 1`
78 echo "Getting defaultNamingContext"
79 BASEDN
=`$ldbsearch $options --basedn='' -H ldap://$SERVER -s base DUMMY=x defaultNamingContext | grep defaultNamingContext | awk '{print $2}'`
81 cat > $PREFIX/tmpldbmodify
<<EOF
82 dn: cn=nettestuser,cn=users,$BASEDN
84 add: servicePrincipalName
85 servicePrincipalName: host/nettestuser
88 testit
"modify servicePrincipalName" $VALGRIND $ldbmodify -H ldap
://$SERVER $PREFIX/tmpldbmodify
-k yes $@ || failed
=`expr $failed + 1`
90 testit
"set user password with kerberos ccache" $VALGRIND $samba_tool user setpassword nettestuser
--newpassword=$USERPASS $CONFIGURATION -k yes $@ || failed
=`expr $failed + 1`
92 testit
"enable user with kerberos cache" $VALGRIND $enableaccount nettestuser
-H ldap
://$SERVER -k yes $@ || failed
=`expr $failed + 1`
94 KRB5CCNAME
="$PREFIX/tmpuserccache"
97 testit
"kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
99 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
101 NEWUSERPASS
=testPaSS@
34%
102 testit
"change user password with 'samba-tool user password' (rpc)" $VALGRIND $samba_tool user password
-W$DOMAIN -Unettestuser%$USERPASS $CONFIGURATION -k no
--newpassword=$NEWUSERPASS $@ || failed
=`expr $failed + 1`
104 echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
105 testit
"kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
107 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
110 USERPASS
=$NEWUSERPASS
111 NEWUSERPASS
=testPaSS@
56%
112 echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
114 cat > $PREFIX/tmpkpasswdscript
<<EOF
116 password ${USERPASS}\n
118 send ${NEWUSERPASS}\n
119 expect Verify password
120 send ${NEWUSERPASS}\n
124 testit
"change user password with kpasswd" $rkpty $PREFIX/tmpkpasswdscript
$samba4kpasswd nettestuser@
$REALM || failed
=`expr $failed + 1`
126 testit
"kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
128 NEWUSERPASS
=testPaSS@
78%
129 echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
131 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
133 cat > $PREFIX/tmpkpasswdscript
<<EOF
135 send ${NEWUSERPASS}\n
136 expect Verify password
137 send ${NEWUSERPASS}\n
141 testit
"set user password with kpasswd" $rkpty $PREFIX/tmpkpasswdscript
$samba4kpasswd --cache=$PREFIX/tmpccache nettestuser@
$REALM || failed
=`expr $failed + 1`
143 testit
"kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
145 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
147 NEWUSERPASS
=testPaSS@
910%
148 echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
150 cat > $PREFIX/tmpkpasswdscript
<<EOF
152 send ${NEWUSERPASS}\n
153 expect Verify password
154 send ${NEWUSERPASS}\n
158 testit
"set user password with kpasswd and servicePrincipalName" $rkpty $PREFIX/tmpkpasswdscript
$samba4kpasswd --cache=$PREFIX/tmpccache host
/nettestuser@
$REALM || failed
=`expr $failed + 1`
160 testit
"kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
162 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
164 cat > $PREFIX/tmpldbmodify
<<EOF
165 dn: cn=nettestuser,cn=users,$BASEDN
171 USERPASS
=$NEWUSERPASS
172 NEWUSERPASS
=testPaSS@
911%
174 testit
"modify pwdLastSet" $VALGRIND $ldbmodify $PWSETCONFIG $PREFIX/tmpldbmodify
$PREFIX/tmpldbmodify
-k yes $@ || failed
=`expr $failed + 1`
176 cat > $PREFIX/tmppasswordchange
<<EOF
177 expect nettestuser@${REALM}'s Password:
179 expect Your password will expire at
180 expect Changing password
182 send ${NEWUSERPASS}\n
183 expect Repeat new password:
184 send ${NEWUSERPASS}\n
185 expect Success: Password changed
188 testit
"kinit with user password for expired password" $rkpty $PREFIX/tmppasswordchange
$samba4kinit $enctype --request-pac nettestuser@
$REALM && failed
=`expr $failed + 1`
190 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
192 echo $NEWUSERPASS > $PREFIX/tmpuserpassfile
193 testit
"kinit with user password" $samba4kinit $enctype --password-file=$PREFIX/tmpuserpassfile
--request-pac nettestuser@
$REALM || failed
=`expr $failed + 1`
195 test_smbclient
"Test login with user kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
197 KRB5CCNAME
="$PREFIX/tmpccache"
200 lowerrealm
=$
(echo $REALM |
tr '[A-Z]' '[a-z]')
201 test_smbclient
"Test login with user kerberos lowercase realm" 'ls' -k yes -Unettestuser@
$lowerrealm%$NEWUSERPASS || failed
=`expr $failed + 1`
202 test_smbclient
"Test login with user kerberos lowercase realm 2" 'ls' -k yes -Unettestuser@
$REALM%$NEWUSERPASS --realm=$lowerrealm || failed
=`expr $failed + 1`
204 testit
"del user with kerberos ccache" $VALGRIND $samba_tool user delete nettestuser
$CONFIGURATION -k yes $@ || failed
=`expr $failed + 1`
207 testit
"kinit with machineaccountccache script" $machineaccountccache $CONFIGURATION $KRB5CCNAME || failed
=`expr $failed + 1`
208 test_smbclient
"Test machine account login with kerberos ccache" 'ls' -k yes || failed
=`expr $failed + 1`
210 testit
"reset password policies" $VALGRIND $samba_tool domain passwordsettings
$PWSETCONFIG set --complexity=default
--history-length=default
--min-pwd-length=default
--min-pwd-age=default
--max-pwd-age=default || failed
=`expr $failed + 1`
212 rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript