s3:lib/events: s/EVENT_FD/TEVENT_FD
[Samba/gebeck_regimport.git] / testsuite / build_farm / basicsmb.fns
blob3a9080f473b738b30792b7d3ce8ea3bef89d8a67
1 #! /bin/sh
3 # Common functions for Samba build scripts.
5 # Copyright (C) 2001 by Martin Pool <mbp@samba.org> and others
7 # The following variables are passed in by the calling script. They
8 # originate in either the buildfarm scripts or the configured
9 # Makefile.
11 # PREFIX = Installed prefix of samba test installation. Used to
12 # locate binaries, configuration files, etc.
14 # XXX: It's pretty bad to clobber the installed configuration file and
15 # other data in $prefix, because somebody might unwittingly run this
16 # with prefix=/usr.
18 # Really what we want is a consistent way to pass the location of the
19 # configuration and all other files into *all* Samba programs
20 # (smbclient, smd, ...) and be able to set them to a temporary
21 # directory when testing. Some of them take a -c parameter, but tpot
22 # says it's not done consistently.
24 template_setup() {
25 cat template/$1 | \
26 sed "s|PREFIX|$prefix|g" | \
27 sed "s|BUILD_FARM|$test_root|g" | \
28 sed "s|WHOAMI|$whoami|g" | \
29 sed "s|LOGLEVEL|$loglevel|g" \
30 > $prefix/$2
31 echo "template_setup: Created $prefix/$2"
34 template_smb_conf_setup() {
35 template_setup "basicsmb.smb.conf$1" "lib/smb.conf$1"
38 test_smb_conf_setup() {
39 echo "test_smb_conf_setup: Configuring: "
40 echo " PREFIX=$prefix"
41 echo " BUILD_FARM=$test_root"
42 echo " WHOAMI=$whoami"
43 echo " LOGLEVEL=$loglevel"
44 echo " TREE=$tree"
46 case "$prefix" in
47 /usr*|/|//)
48 echo "** I don't want to clobber your installation in "
49 echo "** $prefix"
50 echo "** by running tests there. Please reconfigure this source tree to"
51 echo "** use a different prefix."
52 exit 1
53 esac
55 # Please keep these names under 15 characters,
56 # so that the final name is 31 characters or fewer.
58 template_smb_conf_setup
59 template_smb_conf_setup .hostsequiv
60 template_smb_conf_setup .validusers
61 template_smb_conf_setup .invalidusers
62 template_smb_conf_setup .preexec
63 template_smb_conf_setup .preexec_close
64 template_smb_conf_setup .preexec_cl_fl
66 template_smb_conf_setup .share
67 template_smb_conf_setup .user
68 template_smb_conf_setup .server
69 template_smb_conf_setup .domain
71 template_setup preexec lib/preexec
73 touch $prefix/lib/smb.conf.
74 touch $prefix/lib/smb.conf.localhost
76 echo "127.0.0.1 localhost">$prefix/lib/lmhosts
77 echo "127.0.0.2 BUILDFARM">>$prefix/lib/lmhosts
78 echo "127.0.0.3 SHARE">>$prefix/lib/lmhosts
79 echo "127.0.0.4 USER">>$prefix/lib/lmhosts
80 echo "127.0.0.5 SERVER">>$prefix/lib/lmhosts
81 echo "127.0.0.6 DOMAIN">>$prefix/lib/lmhosts
82 echo "127.0.0.7 HOSTSEQUIV">>$prefix/lib/lmhosts
83 echo "127.0.0.7 VALIDUSERS">>$prefix/lib/lmhosts
84 echo "127.0.0.7 INVALIDUSERS">>$prefix/lib/lmhosts
85 echo "127.0.0.7 PREEXEC">>$prefix/lib/lmhosts
86 echo "127.0.0.7 PREEXEC_CLOSE">>$prefix/lib/lmhosts
87 echo "127.0.0.7 PREEXEC_CL_FL">>$prefix/lib/lmhosts
90 echo "127.0.0.1" > $prefix/lib/hosts.equiv
94 test_smbpasswd() {
95 test_smbpasswd_password="$1"
96 rm -f $prefix/private/smbpasswd
97 echo "( echo $test_smbpasswd_password ; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -D $loglevel -s -a $whoami"
98 ( echo $test_smbpasswd_password; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -D $loglevel -s -a $whoami
99 status=$?
100 if [ $status = 0 ]; then
101 echo "smbpasswd correctly set initial password ($test_smbpasswd_password)"
102 else
103 echo "smbpasswd failed to set initial password ($test_smbpasswd_password)! (status $status)"
104 return 1
106 return 0
109 test_smbpasswd_remote() {
110 test_smbpasswd_rem_password="$1"
111 test_smbpasswd_rem_newpassword="$2"
112 echo "( echo $test_smbpasswd_rem_password; echo $test_smbpasswd_rem_newpassword; echo $test_smbpasswd_rem_newpassword; ) | $prefix/bin/smbpasswd -r localhost -s -U $whoami"
113 ( echo $test_smbpasswd_rem_password; echo $test_smbpasswd_rem_newpassword; echo $test_smbpasswd_rem_newpassword; ) | $prefix/bin/smbpasswd -r localhost -s -U $whoami
114 status=$?
115 if [ $status = 0 ]; then
116 echo "smbpasswd correctly remotely changed password ($test_smbpasswd_rem_password -> $test_smbpasswd_rem_newpassword)"
117 else
118 echo "smbpasswd failed to remotely changed password ($test_smbpasswd_rem_password -> $test_smbpasswd_rem_newpassword)! (status $status)"
119 return 1
121 return 0
124 test_smbpasswd_local() {
125 test_smbpasswd_newpassword="$2"
126 echo "( echo $test_smbpasswd_newpassword ; echo $test_smbpasswd_newpassword; ) | $prefix/bin/smbpasswd -L -s $whoami"
127 ( echo $test_smbpasswd_newpassword ; echo $test_smbpasswd_newpassword; ) | $prefix/bin/smbpasswd -L -s $whoami
128 status=$?
129 if [ $status = 0 ]; then
130 echo "smbpasswd correctly locally changed password ($test_smbpasswd_password -> $test_smbpasswd_newpassword)"
131 else
132 echo "smbpasswd failed to locallly changed password ($test_smbpasswd_password -> $test_smbpasswd_newpassword)! (status $status)"
133 return 1
135 return 0
138 test_listfilesauth() {
139 remote_name="$1"
140 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
141 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
142 status=$?
143 if [ $status = 0 ]; then
144 echo "listed files OK"
145 else
146 echo "listing files with smbd failed with status $status"
147 return 1
149 return 0
152 test_listfilesnpw() {
153 remote_name="$1"
154 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
155 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
156 status=$?
157 if [ $status = 0 ]; then
158 echo "smbd listed files with NO PASSWORD on an authenticated share!"
159 return 1
160 else
161 echo "listing files with smbd failed with status $status (correct)"
163 return 0
166 test_listfilesauth_should_deny() {
167 remote_name="$1"
168 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
169 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
170 status=$?
171 if [ $status = 0 ]; then
172 echo "smbd LISTED FILES despite smb.conf entires to the contary!"
173 return 1
174 else
175 echo "listing files with smbd failed with status $status (correct)"
177 return 0
180 echo "LIBSMB_PROG=$LIBSMB_PROG" >&2
184 # Give sensible defaults to some variables.
186 # "What's my age again?"
188 if [ ! $USER = "" ]; then
189 whoami=$USER
190 else
191 if [ ! $LOGNAME = "" ]; then
192 whoami=$LOGNAME
193 else
194 whoami=build
200 if test -z "$loglevel"
201 then
202 loglevel=1