summaryrefslogtreecommitdiff
path: root/testsuite/build_farm/basicsmb.fns
blob: 68411caff7909da45212f0bd062dc72f55908cd4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
template_smb_conf_setup() {
	cat basicsmb.smb.conf$1.template | \
              sed "s|PREFIX|$prefix|g" | \
	      sed "s|BUILD_FARM|$pwd|g" | \
	      sed "s|WHOAMI|$whoami|g" | \
	      sed "s|LOGLEVEL|$loglevel|g" \
        > $prefix/lib/smb.conf$1
}

test_smb_conf_setup() {
    template_smb_conf_setup 
    template_smb_conf_setup .hostsequiv
    template_smb_conf_setup .invalidusers

	echo "127.0.0.1    localhost">$prefix/lib/lmhosts
	echo "127.0.0.2    BUILDFARM">>$prefix/lib/lmhosts
    echo "127.0.0.3    SHARE">>$prefix/lib/lmhosts
    echo "127.0.0.4    USER">>$prefix/lib/lmhosts
    echo "127.0.0.5    SERVER">>$prefix/lib/lmhosts
    echo "127.0.0.6    DOMAIN">>$prefix/lib/lmhosts
    echo "127.0.0.7    HOSTSEQUIV">>$prefix/lib/lmhosts

	echo $host > $prefix/lib/hosts.equiv
    echo "localhost" >> $prefix/lib/hosts.equiv

    cp basicsmb.smb.conf.share $prefix/lib/smb.conf.share
    cp basicsmb.smb.conf.user $prefix/lib/smb.conf.user
    cp basicsmb.smb.conf.server $prefix/lib/smb.conf.server
    cp basicsmb.smb.conf.domain $prefix/lib/smb.conf.domain

    touch $prefix/lib/smb.conf.
    touch $prefix/lib/smb.conf.localhost
}

test_smbpasswd() {
	test_smbpasswd_password="$1"
	rm -f $prefix/private/smbpasswd
	echo "( echo $test_smbpasswd_password ; echo $test_smbpasswd_password; ) | $prefix/bin/smbpasswd -L -s -a $whoami"
	( echo $password ; echo $password; ) | $prefix/bin/smbpasswd -L -s -a $whoami
	status=$?
	if [ $status = 0 ]; then
	    echo "smbpasswd correctly set initial password ($test_smbpasswd_password)"
	else
	    echo "smbpasswd failed to set initial password ($test_smbpasswd_password)! (status $status)"
	    return 1
	fi
	return 0
}

test_listfilesauth() {
	remote_name="$1"
	echo $prefix/bin/smbclient//$remote_name/samba  -n buildclient -U$whoami%$password -c 'ls'
	$prefix/bin/smbclient //$remote_name/samba  -n buildclient -U$whoami%$password -c 'ls'
	status=$?
	if [ $status = 0 ]; then
		echo "listed files OK"
	else 
		echo "listing files with smbd failed with status $status"
		return 1
	fi
	return 0
}

test_listfilesnpw() {
	remote_name="$1"
	echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%  -c 'ls'
	$prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami% -c 'ls'
	status=$?
	if [ $status = 0 ]; then
		echo "smbd listed files with NO PASSWORD on an authenticated share!"
		return 1
	else 
		echo "listing files with smbd failed with status $status (correct)"
	fi
	return 0
}

test_listfilesauth_should_deny() {
	remote_name="$1"
	echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password  -c 'ls'
	$prefix/bin/smbclient //$remote_name/samba -n buildclient -U$whoami%$password -c 'ls'
	status=$?
	if [ $status = 0 ]; then
		echo "smbd LISTED FILES despite smb.conf entires to the contary!"
		return 1
	else 
		echo "listing files with smbd failed with status $status (correct)"
	fi
	return 0
}