c38bbe5d1849fa5228b01a1354d4b13f00c3b79a
[ira/wip.git] / testsuite / build_farm / basicsmb.fns
1 template_smb_conf_setup() {
2         cat basicsmb.smb.conf$1.template | \
3               sed "s|PREFIX|$prefix|g" | \
4               sed "s|BUILD_FARM|$pwd|g" | \
5               sed "s|WHOAMI|$whoami|g" | \
6               sed "s|LOGLEVEL|$loglevel|g" \
7         > $prefix/lib/smb.conf$1
8 }
9
10 test_smb_conf_setup() {
11     template_smb_conf_setup 
12     template_smb_conf_setup .hostsequiv
13     template_smb_conf_setup .invalidusers
14
15         echo "127.0.0.1    localhost">$prefix/lib/lmhosts
16         echo "127.0.0.2    BUILDFARM">>$prefix/lib/lmhosts
17     echo "127.0.0.3    SHARE">>$prefix/lib/lmhosts
18     echo "127.0.0.4    USER">>$prefix/lib/lmhosts
19     echo "127.0.0.5    SERVER">>$prefix/lib/lmhosts
20     echo "127.0.0.6    DOMAIN">>$prefix/lib/lmhosts
21     echo "127.0.0.7    HOSTSEQUIV">>$prefix/lib/lmhosts
22
23     echo "localhost" > $prefix/lib/hosts.equiv
24
25     cp basicsmb.smb.conf.share $prefix/lib/smb.conf.share
26     cp basicsmb.smb.conf.user $prefix/lib/smb.conf.user
27     cp basicsmb.smb.conf.server $prefix/lib/smb.conf.server
28     cp basicsmb.smb.conf.domain $prefix/lib/smb.conf.domain
29
30     touch $prefix/lib/smb.conf.
31     touch $prefix/lib/smb.conf.localhost
32 }
33
34 test_smbpasswd() {
35         test_smbpasswd_password="$1"
36         rm -f $prefix/private/smbpasswd
37         echo "( echo $test_smbpasswd_password ; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -s -a $whoami"
38         ( echo $password ; echo $password; ) | $prefix/bin/smbpasswd -L -s -a $whoami
39         status=$?
40         if [ $status = 0 ]; then
41             echo "smbpasswd correctly set initial password ($test_smbpasswd_password)"
42         else
43             echo "smbpasswd failed to set initial password ($test_smbpasswd_password)! (status $status)"
44             return 1
45         fi
46         return 0
47 }
48
49 test_listfilesauth() {
50         remote_name="$1"
51         echo $prefix/bin/smbclient//$remote_name/samba  -n buildclient -U$whoami%$password -c 'ls'
52         $prefix/bin/smbclient //$remote_name/samba  -n buildclient -U$whoami%$password -c 'ls'
53         status=$?
54         if [ $status = 0 ]; then
55                 echo "listed files OK"
56         else 
57                 echo "listing files with smbd failed with status $status"
58                 return 1
59         fi
60         return 0
61 }
62
63 test_listfilesnpw() {
64         remote_name="$1"
65         echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%  -c 'ls'
66         $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
67         status=$?
68         if [ $status = 0 ]; then
69                 echo "smbd listed files with NO PASSWORD on an authenticated share!"
70                 return 1
71         else 
72                 echo "listing files with smbd failed with status $status (correct)"
73         fi
74         return 0
75 }
76
77 test_listfilesauth_should_deny() {
78         remote_name="$1"
79         echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password  -c 'ls'
80         $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
81         status=$?
82         if [ $status = 0 ]; then
83                 echo "smbd LISTED FILES despite smb.conf entires to the contary!"
84                 return 1
85         else 
86                 echo "listing files with smbd failed with status $status (correct)"
87         fi
88         return 0
89 }