s4-privs Seperate rights and privileges
[kai/samba.git] / testprogs / blackbox / test_chgdcpass.sh
1 #!/bin/sh
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>
5
6 if [ $# -lt 4 ]; then
7 cat <<EOF
8 Usage: test_kinit.sh SERVER USERNAME REALM DOMAIN PREFIX
9 EOF
10 exit 1;
11 fi
12
13 SERVER=$1
14 USERNAME=$2
15 REALM=$3
16 DOMAIN=$4
17 PREFIX=$5
18 ENCTYPE=$6
19 PROVDIR=$7
20 shift 7
21 failed=0
22
23 samba4bindir="$BUILDDIR/bin"
24 smbclient="$samba4bindir/smbclient$EXEEXT"
25 samba4kinit="$samba4bindir/samba4kinit$EXEEXT"
26 machineaccountccache="$BUILDDIR/scripting/bin/machineaccountccache"
27
28 . `dirname $0`/subunit.sh
29
30 test_smbclient() {
31         name="$1"
32         cmd="$2"
33         shift
34         shift
35         echo "test: $name"
36         $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" -W "$DOMAIN" $@
37         status=$?
38         if [ x$status = x0 ]; then
39                 echo "success: $name"
40         else
41                 echo "failure: $name"
42         fi
43         return $status
44 }
45
46 enctype="-e $ENCTYPE"
47
48 KRB5CCNAME="$PREFIX/tmpccache"
49 export KRB5CCNAME
50 rm -f $KRB5CCNAME
51 testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private/secrets.keytab --use-keytab $USERNAME   || failed=`expr $failed + 1`
52
53 #This is important because it puts the ticket for the old KVNO and password into a local ccache
54 test_smbclient "Test login with kerberos ccache before password change" 'ls' -k yes || failed=`expr $failed + 1`
55 testit "change dc password" ./scripting/devel/chgtdcpass -s $PROVDIR/etc/smb.conf || failed=`expr $failed + 1`
56
57 #This is important because it shows that the old ticket remains valid (as it must) for incoming connections after the DC password is changed
58 test_smbclient "Test login with kerberos ccache after password change" 'ls' -k yes || failed=`expr $failed + 1`
59
60 #This confirms that the DC password is valid for a kinit too
61 testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private/secrets.keytab --use-keytab $USERNAME   || failed=`expr $failed + 1`
62 test_smbclient "Test login with kerberos ccache with fresh kinit" 'ls' -k yes || failed=`expr $failed + 1`
63 rm -f $KRB5CCNAME
64
65 rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript
66 exit $failed