3 # Common functions for Samba build scripts.
5 # Copyright (C) 2001 by Martin Pool <mbp@samba.org>
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 template_smb_conf_setup() {
19 cat basicsmb.smb.conf$1.template | \
20 sed "s|PREFIX|$prefix|g" | \
21 sed "s|BUILD_FARM|$pwd|g" | \
22 sed "s|WHOAMI|$whoami|g" | \
23 sed "s|LOGLEVEL|$loglevel|g" \
24 > $prefix/lib/smb.conf$1
25 echo "template_smb_conf_setup: Created $prefix/lib/smb.conf$1"
28 test_smb_conf_setup() {
29 echo "test_smb_conf_setup: Configuring: "
30 echo " PREFIX=$prefix"
31 echo " BUILD_FARM=$pwd"
32 echo " WHOAMI=$whoami"
33 echo " LOGLEVEL=$loglevel"
37 echo "** I don't want to clobber your installation in "
39 echo "** by running tests there. Please reconfigure this source tree to"
40 echo "** use a different prefix."
44 template_smb_conf_setup
45 template_smb_conf_setup .hostsequiv
46 template_smb_conf_setup .invalidusers
48 echo "127.0.0.1 localhost">$prefix/lib/lmhosts
49 echo "127.0.0.2 BUILDFARM">>$prefix/lib/lmhosts
50 echo "127.0.0.3 SHARE">>$prefix/lib/lmhosts
51 echo "127.0.0.4 USER">>$prefix/lib/lmhosts
52 echo "127.0.0.5 SERVER">>$prefix/lib/lmhosts
53 echo "127.0.0.6 DOMAIN">>$prefix/lib/lmhosts
54 echo "127.0.0.7 HOSTSEQUIV">>$prefix/lib/lmhosts
56 echo "127.0.0.1" > $prefix/lib/hosts.equiv
58 cp basicsmb.smb.conf.share $prefix/lib/smb.conf.share
59 cp basicsmb.smb.conf.user $prefix/lib/smb.conf.user
60 cp basicsmb.smb.conf.server $prefix/lib/smb.conf.server
61 cp basicsmb.smb.conf.domain $prefix/lib/smb.conf.domain
63 touch $prefix/lib/smb.conf.
64 touch $prefix/lib/smb.conf.localhost
68 test_smbpasswd_password="$1"
69 rm -f $prefix/private/smbpasswd
70 echo "( echo $test_smbpasswd_password ; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -s -a $whoami"
71 ( echo $password ; echo $password; ) | $prefix/bin/smbpasswd -L -s -a $whoami
73 if [ $status = 0 ]; then
74 echo "smbpasswd correctly set initial password ($test_smbpasswd_password)"
76 echo "smbpasswd failed to set initial password ($test_smbpasswd_password)! (status $status)"
82 test_listfilesauth() {
84 echo $prefix/bin/smbclient//$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
85 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
87 if [ $status = 0 ]; then
88 echo "listed files OK"
90 echo "listing files with smbd failed with status $status"
98 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
99 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
101 if [ $status = 0 ]; then
102 echo "smbd listed files with NO PASSWORD on an authenticated share!"
105 echo "listing files with smbd failed with status $status (correct)"
110 test_listfilesauth_should_deny() {
112 echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
113 $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
115 if [ $status = 0 ]; then
116 echo "smbd LISTED FILES despite smb.conf entires to the contary!"
119 echo "listing files with smbd failed with status $status (correct)"
124 echo "LIBSMB_PROG=$LIBSMB_PROG" >&2