1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-11 05:18:09 +03:00

Add and modify some of the various tests I have had sitting around here for a

little while.  This should give us a bit more coverage.

Andrew Bartlett
This commit is contained in:
Andrew Bartlett 0001-01-01 00:00:00 +00:00
parent ba1b411f55
commit 9e5a1d1623
12 changed files with 147 additions and 10 deletions

View File

@ -0,0 +1,31 @@
if [ $whoami != "root" ]; then
exit 0;
fi
. basicsmb.fns
test_joindomain_nt4() {
smbpasswd -a -m buildfarm$
echo $prefix/bin/smbpasswd -L -j TESTWG
$prefix/bin/smbpasswd -L -j TESTWG
status=$?
if [ $status = 0 ]; then
echo "smbpasswd correctly joined the domain ($workgroup)"
else
echo "smbpasswd failed to join the domain ($workgroup)! (status $status)"
return 1
fi
return 0
}
password=samba
security=DOMAIN
(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
test_joindomain_nt4 $password || exit 1
test_listfilesauth $security || exit 1
test_listfilesnpw $security || exit 1

View File

@ -1,9 +1,30 @@
if [ $whoami != "root" ]; then
exit 0;
fi
. basicsmb.fns
test_joindomain() {
test_joindomain_password="$1"
echo "$prefix/bin/smbpasswd -L -j TESTWG -U $whoami%$test_join_domain_password"
$prefix/bin/smbpasswd -L -j TESTWG -U $whoami%$test_join_domain_password
status=$?
if [ $status = 0 ]; then
echo "smbpasswd correctly joined the domain ($workgroup)"
else
echo "smbpasswd failed to join the domain ($workgroup)! (status $status)"
return 1
fi
return 0
}
password=samba
security=DOMAIN
(test_smb_conf_setup && test_smbpasswd $password ) || exit 1
test_joindomain $password || exit 1
test_listfilesauth $security || exit 1
test_listfilesnpw $security || exit 1

View File

@ -0,0 +1,18 @@
. basicsmb.fns
password="samba"
security="hostsdeny"
(test_smb_conf_setup && test_smbpasswd $password) || exit 1
(test_listfilesauth_should_deny $security) || exit 1

View File

@ -0,0 +1,28 @@
if [ $whoami = "root" ]; then
exit 0;
fi
. basicsmb.fns
test_listfilesrootnpw() {
remote_name="$1"
echo $prefix/bin/smbclient //$remote_name/samba -n buildclient -Uroot% -c 'ls'
$prefix/bin/smbclient //$remote_name/samba -n buildclient -Uroot% -c 'ls'
status=$?
if [ $status = 0 ]; then
echo "smbd listed files AS ROOT with NO PASSWORD (hosts equiv test)!"
return 1
else
echo "listing files with smbd failed with status $status (correct)"
fi
return 0
}
password="not-a-valid-password"
security="hostsequiv"
(test_smb_conf_setup ) || exit 1
(test_listfilesauth $security) || exit 1
# (test_listfilesrootnpw $security) || exit 1
# Unfortuetly we map to guest, and this is allowed access due to a BUG. This
# test disabled till we fix it.

View File

@ -0,0 +1,8 @@
. basicsmb.fns
password="samba"
security="invalidusers"
(test_smb_conf_setup && test_smbpasswd $password) || exit 1
(test_listfilesauth_should_deny $security) || exit 1

View File

@ -1,21 +1,32 @@
test_smb_conf_setup() {
cat basicsmb.smb.conf.template | \
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
> $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.1 BUILDFARM">>$prefix/lib/lmhosts
echo "127.0.0.1 SHARE">>$prefix/lib/lmhosts
echo "127.0.0.1 USER">>$prefix/lib/lmhosts
echo "127.0.0.1 SERVER">>$prefix/lib/lmhosts
echo "127.0.0.1 DOMAIN">>$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 "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
}
@ -63,3 +74,16 @@ test_listfilesnpw() {
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
}

View File

@ -1,2 +1,2 @@
security=domain
password server=127.0.0.1
password server=user

View File

@ -0,0 +1 @@
hosts deny = 127.

View File

@ -0,0 +1,3 @@
hostname lookups = yes
hosts equiv=PREFIX/lib/hosts.equiv

View File

@ -0,0 +1 @@
invalid users = WHOAMI

View File

@ -13,6 +13,8 @@
include = PREFIX/lib/smb.conf.%L
add machine script = useradd %u -d /dev/null -s /bin/false
[test]
path = PREFIX/testdir
read only = no

View File

@ -1,3 +1,3 @@
TEST_ALL="basicsmb-sharelist basicsmb-sharesec basicsmb-usersec basicsmb-serversec basicsmb-shareguest torture-FDPASS torture-LOCK1 torture-LOCK2 torture-LOCK3 torture-LOCK4 torture-LOCK5 torture-UNLINK torture-BROWSE torture-ATTR torture-TRANS2 torture-TORTURE torture-OPLOCK1 torture-OPLOCK3 torture-DIR torture-DENY1 torture-DENY2 torture-TCON torture-RW1 torture-RW2 torture-OPEN torture-DELETE"
TEST_ALL="basicsmb-sharelist basicsmb-sharesec basicsmb-usersec basicsmb-serversec basicsmb-domainsec basicsmb-domainsec-nt4 basicsmb-shareguest basicsmb-hostsequiv basicsmb-invalidusers basicsmb-hostsdeny torture-FDPASS torture-LOCK1 torture-LOCK2 torture-LOCK3 torture-LOCK4 torture-LOCK5 torture-UNLINK torture-BROWSE torture-ATTR torture-TRANS2 torture-TORTURE torture-OPLOCK1 torture-OPLOCK3 torture-DIR torture-DENY1 torture-DENY2 torture-TCON torture-RW1 torture-RW2 torture-OPEN torture-DELETE"
#basicsmb-serversec