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
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
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.
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" \
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"
48 echo "** I don't want to clobber your installation in "
50 echo "** by running tests there. Please reconfigure this source tree to"
51 echo "** use a different prefix."
55 template_smb_conf_setup
56 template_smb_conf_setup .hostsequiv
57 template_smb_conf_setup .validusers
58 template_smb_conf_setup .invalidusers
59 template_smb_conf_setup .preexec
60 template_smb_conf_setup .preexec_close
61 template_smb_conf_setup .preexec_cl_fail
63 template_setup preexec lib/preexec
65 echo "127.0.0.1 localhost">$prefix/lib/lmhosts
66 echo "127.0.0.2 BUILDFARM">>$prefix/lib/lmhosts
67 echo "127.0.0.3 SHARE">>$prefix/lib/lmhosts
68 echo "127.0.0.4 USER">>$prefix/lib/lmhosts
69 echo "127.0.0.5 SERVER">>$prefix/lib/lmhosts
70 echo "127.0.0.6 DOMAIN">>$prefix/lib/lmhosts
71 echo "127.0.0.7 HOSTSEQUIV">>$prefix/lib/lmhosts
72 echo "127.0.0.7 VALIDUSERS">>$prefix/lib/lmhosts
73 echo "127.0.0.7 INVALIDUSERS">>$prefix/lib/lmhosts
74 echo "127.0.0.7 PREEXEC">>$prefix/lib/lmhosts
75 echo "127.0.0.7 PREEXEC_CLOSE">>$prefix/lib/lmhosts
76 echo "127.0.0.7 PREEXEC_CL_FAIL">>$prefix/lib/lmhosts
79 echo "127.0.0.1" > $prefix/lib/hosts.equiv
81 cp basicsmb.smb.conf.share $prefix/lib/smb.conf.share
82 cp basicsmb.smb.conf.user $prefix/lib/smb.conf.user
83 cp basicsmb.smb.conf.server $prefix/lib/smb.conf.server
84 cp basicsmb.smb.conf.domain $prefix/lib/smb.conf.domain
86 touch $prefix/lib/smb.conf.
87 touch $prefix/lib/smb.conf.localhost
91 test_smbpasswd_password="$1"
92 rm -f $prefix/private/smbpasswd
93 echo "( echo $test_smbpasswd_password ; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -s -a $whoami"
94 ( echo $test_smbpasswd_password; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -s -a $whoami
96 if [ $status = 0 ]; then
97 echo "smbpasswd correctly set initial password ($test_smbpasswd_password)"
99 echo "smbpasswd failed to set initial password ($test_smbpasswd_password)! (status $status)"
105 test_smbpasswd_remote() {
106 test_smbpasswd_rem_password="$1"
107 test_smbpasswd_rem_newpassword="$2"
108 echo "( echo $test_smbpasswd_rem_password; echo $test_smbpasswd_rem_newpassword; echo $test_smbpasswd_rem_newpassword; ) | $prefix/bin/smbpasswd -r localhost -s -U $whoami"
109 ( echo $test_smbpasswd_rem_password; echo $test_smbpasswd_rem_newpassword; echo $test_smbpasswd_rem_newpassword; ) | $prefix/bin/smbpasswd -r localhost -s -U $whoami
111 if [ $status = 0 ]; then
112 echo "smbpasswd correctly remotely changed password ($test_smbpasswd_rem_password -> $test_smbpasswd_rem_newpassword)"
114 echo "smbpasswd failed to remotely changed password ($test_smbpasswd_rem_password -> $test_smbpasswd_rem_newpassword)! (status $status)"
120 test_smbpasswd_local() {
121 test_smbpasswd_newpassword="$2"
122 echo "( echo $test_smbpasswd_newpassword ; echo $test_smbpasswd_newpassword; ) | $prefix/bin/smbpasswd -L -s $whoami"
123 ( echo $test_smbpasswd_newpassword ; echo $test_smbpasswd_newpassword; ) | $prefix/bin/smbpasswd -L -s $whoami
125 if [ $status = 0 ]; then
126 echo "smbpasswd correctly locally changed password ($test_smbpasswd_password -> $test_smbpasswd_newpassword)"
128 echo "smbpasswd failed to locallly changed password ($test_smbpasswd_password -> $test_smbpasswd_newpassword)! (status $status)"
134 test_listfilesauth() {
136 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
137 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
139 if [ $status = 0 ]; then
140 echo "listed files OK"
142 echo "listing files with smbd failed with status $status"
148 test_listfilesnpw() {
150 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
151 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
153 if [ $status = 0 ]; then
154 echo "smbd listed files with NO PASSWORD on an authenticated share!"
157 echo "listing files with smbd failed with status $status (correct)"
162 test_listfilesauth_should_deny() {
164 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
165 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
167 if [ $status = 0 ]; then
168 echo "smbd LISTED FILES despite smb.conf entires to the contary!"
171 echo "listing files with smbd failed with status $status (correct)"
176 echo "LIBSMB_PROG=$LIBSMB_PROG" >&2
180 # Give sensible defaults to some variables.
182 # "What's my age again?"
184 if [ ! $USER = "" ]; then
187 if [ ! $LOGNAME = "" ]; then
196 if test -z "$loglevel"