2010-07-04 16:39:17 +04:00
#!/bin/sh
# Blackbox tests for kinit and kerberos integration with smbclient etc
# Copyright (C) 2006-2007 Jelmer Vernooij <jelmer@samba.org>
# Copyright (C) 2006-2008 Andrew Bartlett <abartlet@samba.org>
if [ $# -lt 4 ] ; then
cat <<EOF
Usage: test_kinit.sh SERVER USERNAME REALM DOMAIN PREFIX
EOF
exit 1;
fi
SERVER = $1
USERNAME = $2
REALM = $3
DOMAIN = $4
PREFIX = $5
ENCTYPE = $6
PROVDIR = $7
shift 7
failed = 0
2011-04-15 06:41:22 +04:00
samba4bindir = " $BINDIR "
2011-02-03 09:30:53 +03:00
samba4srcdir = " $SRCDIR /source4 "
2010-07-15 04:54:08 +04:00
smbclient = " $samba4bindir /smbclient $EXEEXT "
2010-07-04 16:39:17 +04:00
samba4kinit = " $samba4bindir /samba4kinit $EXEEXT "
2011-02-03 09:30:53 +03:00
machineaccountccache = " $samba4srcdir /scripting/bin/machineaccountccache "
2010-07-04 16:39:17 +04:00
. ` dirname $0 ` /subunit.sh
2010-07-15 04:54:08 +04:00
test_smbclient( ) {
name = " $1 "
cmd = " $2 "
shift
shift
echo " test: $name "
$VALGRIND $smbclient $CONFIGURATION //$SERVER /tmp -c " $cmd " -W " $DOMAIN " $@
status = $?
if [ x$status = x0 ] ; then
echo " success: $name "
else
echo " failure: $name "
fi
return $status
}
2010-07-04 16:39:17 +04:00
enctype = " -e $ENCTYPE "
KRB5CCNAME = " $PREFIX /tmpccache "
export KRB5CCNAME
rm -f $KRB5CCNAME
testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR /private/secrets.keytab --use-keytab $USERNAME || failed = ` expr $failed + 1`
2010-07-15 04:54:08 +04:00
2010-07-15 08:05:23 +04:00
#This is important because it puts the ticket for the old KVNO and password into a local ccache
test_smbclient "Test login with kerberos ccache before password change" 'ls' -k yes || failed = ` expr $failed + 1`
2011-02-03 09:30:53 +03:00
testit "change dc password" $samba4srcdir /scripting/devel/chgtdcpass -s $PROVDIR /etc/smb.conf || failed = ` expr $failed + 1`
2010-07-15 04:54:08 +04:00
2010-07-15 08:05:23 +04:00
#This is important because it shows that the old ticket remains valid (as it must) for incoming connections after the DC password is changed
test_smbclient "Test login with kerberos ccache after password change" 'ls' -k yes || failed = ` expr $failed + 1`
2010-07-15 04:54:08 +04:00
#This confirms that the DC password is valid for a kinit too
2010-07-04 16:39:17 +04:00
testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR /private/secrets.keytab --use-keytab $USERNAME || failed = ` expr $failed + 1`
2010-07-15 04:54:08 +04:00
test_smbclient "Test login with kerberos ccache with fresh kinit" 'ls' -k yes || failed = ` expr $failed + 1`
2010-07-04 16:39:17 +04:00
rm -f $KRB5CCNAME
rm -f $PREFIX /tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript
exit $failed