source: vendor/current/testprogs/blackbox/test_chgdcpass.sh

Last change on this file was 988, checked in by Silvan Scherrer, 9 years ago

Samba Server: update vendor to version 4.4.3

File size: 3.8 KB
Line 
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
6if [ $# -lt 4 ]; then
7cat <<EOF
8Usage: test_kinit.sh SERVER USERNAME REALM DOMAIN PREFIX SMBCLIENT
9EOF
10exit 1;
11fi
12
13SERVER=$1
14USERNAME=$2
15REALM=$3
16DOMAIN=$4
17PREFIX=$5
18ENCTYPE=$6
19PROVDIR=$7
20smbclient=$8
21shift 8
22failed=0
23
24samba4bindir="$BINDIR"
25samba4srcdir="$SRCDIR/source4"
26
27samba4kinit=kinit
28if test -x $BINDIR/samba4kinit; then
29 samba4kinit=bin/samba4kinit
30fi
31
32
33machineaccountccache="$samba4srcdir/scripting/bin/machineaccountccache"
34
35. `dirname $0`/subunit.sh
36
37test_smbclient() {
38 name="$1"
39 cmd="$2"
40 shift
41 shift
42 echo "test: $name"
43 $VALGRIND $smbclient $CONFIGURATION //$SERVER/tmp -c "$cmd" $@
44 status=$?
45 if [ x$status = x0 ]; then
46 echo "success: $name"
47 else
48 echo "failure: $name"
49 fi
50 return $status
51}
52
53test_drs() {
54 function="$1"
55 name="$2"
56 shift
57 shift
58 echo "test: $name"
59 echo $VALGRIND $samba4bindir/samba-tool drs $function $SERVER -k yes $@
60 $VALGRIND $samba4bindir/samba-tool drs $function $SERVER -k yes $@
61 status=$?
62 if [ x$status = x0 ]; then
63 echo "success: $name"
64 else
65 echo "failure: $name"
66 fi
67 return $status
68}
69
70enctype="-e $ENCTYPE"
71
72KRB5CCNAME="$PREFIX/tmpccache"
73export KRB5CCNAME
74rm -f $KRB5CCNAME
75testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private/secrets.keytab --use-keytab $USERNAME || failed=`expr $failed + 1`
76
77#This is important because it puts the ticket for the old KVNO and password into a local ccache
78test_smbclient "Test login with kerberos ccache before password change" 'ls' -k yes || failed=`expr $failed + 1`
79
80#check that drs bind works before we change the password (prime the ccache)
81test_drs bind "Test drs bind with with kerberos ccache" || failed=`expr $failed + 1`
82
83#check that drs options works before we change the password (prime the ccache)
84test_drs options "Test drs options with with kerberos ccache" || failed=`expr $failed + 1`
85
86testit "change dc password" $samba4srcdir/scripting/devel/chgtdcpass -s $PROVDIR/etc/smb.conf || failed=`expr $failed + 1`
87
88#This is important because it shows that the old ticket remains valid (as it must) for incoming connections after the DC password is changed
89test_smbclient "Test login with kerberos ccache after password change" 'ls' -k yes || failed=`expr $failed + 1`
90
91#check that drs bind works after we change the password
92test_drs bind "Test drs bind with new password" || failed=`expr $failed + 1`
93
94#check that drs options works after we change the password
95test_drs options "Test drs options with new password" || failed=`expr $failed + 1`
96
97testit "change dc password (2nd time)" $samba4srcdir/scripting/devel/chgtdcpass -s $PROVDIR/etc/smb.conf || failed=`expr $failed + 1`
98
99# 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.
100# This also ensures we handle the case where the domain is re-provisioned etc
101test_smbclient "Test login with kerberos ccache after 2nd password change" 'ls' -k yes || failed=`expr $failed + 1`
102
103#check that drs bind works after we change the password a 2nd time
104test_drs bind "Test drs bind after 2nd password change" || failed=`expr $failed + 1`
105
106#check that drs options works after we change the password a 2nd time
107test_drs options "Test drs options after 2nd password change" || failed=`expr $failed + 1`
108
109#This confirms that the DC password is valid for a kinit too
110testit "kinit with keytab" $samba4kinit $enctype -t $PROVDIR/private/secrets.keytab --use-keytab $USERNAME || failed=`expr $failed + 1`
111test_smbclient "Test login with kerberos ccache with fresh kinit" 'ls' -k yes || failed=`expr $failed + 1`
112rm -f $KRB5CCNAME
113
114rm -f $PREFIX/tmpccache tmpccfile tmppassfile tmpuserpassfile tmpuserccache tmpkpasswdscript
115exit $failed
Note: See TracBrowser for help on using the repository browser.