1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-24 02:04:21 +03:00

samba3.blackbox.smbclient.forceuser_validusers: Add new test for force user option.

Test covers commit
cf0934caf282f4ade8c8a701b0e40b68a2f17ace

BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651

How to test:
$ make -j test TESTS="samba3.blackbox.smbclient.forceuser_validusers"
RESULD: Should PASS
$ git revert cf0934caf282f4ade8c8a701b0e40b68a2f17ace
$ make -j test TESTS="samba3.blackbox.smbclient.forceuser_validusers"
RESULT: Should FAIL

Signed-off-by: Robin Hack <rhack@redhat.com>
Reviewed-by: Uri Simchoni <uri@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Uri Simchoni <uri@samba.org>
Autobuild-Date(master): Thu Feb  4 03:44:42 CET 2016 on sn-devel-144
This commit is contained in:
Robin Hack 2015-12-04 14:50:56 +01:00 committed by Uri Simchoni
parent 498383afef
commit e2699685ca
3 changed files with 93 additions and 2 deletions

View File

@ -599,6 +599,9 @@ sub setup_fileserver($$)
my $offline_sharedir="$share_dir/offline";
push(@dirs,$offline_sharedir);
my $force_user_valid_users_dir = "$share_dir/force_user_valid_users";
push(@dirs, $force_user_valid_users_dir);
my $fileserver_options = "
[lowercase]
path = $lower_case_share_dir
@ -624,6 +627,16 @@ sub setup_fileserver($$)
[offline]
path = $offline_sharedir
vfs objects = offline
# BUG: https://bugzilla.samba.org/show_bug.cgi?id=9878
# RH BUG: https://bugzilla.redhat.com/show_bug.cgi?id=1077651
[force_user_valid_users]
path = $force_user_valid_users_dir
comment = force user with valid users combination test share
valid users = +force_user
force user = force_user
force group = everyone
write list = force_user
";
my $vars = $self->provision($path,
@ -1266,10 +1279,12 @@ sub provision($$$$$$$$)
my ($max_uid, $max_gid);
my ($uid_nobody, $uid_root, $uid_pdbtest, $uid_pdbtest2, $uid_userdup);
my ($uid_pdbtest_wkn);
my ($uid_force_user);
my ($gid_nobody, $gid_nogroup, $gid_root, $gid_domusers, $gid_domadmins);
my ($gid_userdup, $gid_everyone);
my ($gid_force_user);
if ($unix_uid < 0xffff - 5) {
if ($unix_uid < 0xffff - 7) {
$max_uid = 0xffff;
} else {
$max_uid = $unix_uid;
@ -1281,8 +1296,9 @@ sub provision($$$$$$$$)
$uid_pdbtest2 = $max_uid - 4;
$uid_userdup = $max_uid - 5;
$uid_pdbtest_wkn = $max_uid - 6;
$uid_force_user = $max_uid - 7;
if ($unix_gids[0] < 0xffff - 7) {
if ($unix_gids[0] < 0xffff - 8) {
$max_gid = 0xffff;
} else {
$max_gid = $unix_gids[0];
@ -1295,6 +1311,7 @@ sub provision($$$$$$$$)
$gid_domadmins = $max_gid - 5;
$gid_userdup = $max_gid - 6;
$gid_everyone = $max_gid - 7;
$gid_force_user = $max_gid - 8;
##
## create conffile
@ -1659,6 +1676,7 @@ pdbtest:x:$uid_pdbtest:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
pdbtest2:x:$uid_pdbtest2:$gid_nogroup:pdbtest gecos:$prefix_abs:/bin/false
userdup:x:$uid_userdup:$gid_userdup:userdup gecos:$prefix_abs:/bin/false
pdbtest_wkn:x:$uid_pdbtest_wkn:$gid_everyone:pdbtest_wkn gecos:$prefix_abs:/bin/false
force_user:x:$uid_force_user:$gid_force_user:force user gecos:$prefix_abs:/bin/false
";
if ($unix_uid != 0) {
print PASSWD "root:x:$uid_root:$gid_root:root gecos:$prefix_abs:/bin/false
@ -1677,6 +1695,7 @@ domusers:X:$gid_domusers:
domadmins:X:$gid_domadmins:
userdup:x:$gid_userdup:$unix_name
everyone:x:$gid_everyone:
force_user:x:$gid_force_user:
";
if ($unix_gids[0] != 0) {
print GROUP "root:x:$gid_root:
@ -1739,6 +1758,18 @@ everyone:x:$gid_everyone:
warn("Unable to set password for test account\n$cmd");
return undef;
}
# Add another user named: force_user
my $cmd = "UID_WRAPPER_ROOT=1 " . Samba::bindir_path($self, "smbpasswd")." -c $conffile -L -s -a force_user > /dev/null";
unless (open(PWD, "|$cmd")) {
warn("Unable to set password for test account force_user\n$cmd");
return undef;
}
print PWD "$password\n$password\n";
unless (close(PWD)) {
warn("Unable to set password for test account force_user\n$cmd");
return undef;
}
print "DONE\n";
open(DNS_UPDATE_LIST, ">$prefix/dns_update_list") or die("Unable to open $$prefix/dns_update_list");

View File

@ -0,0 +1,59 @@
#!/bin/sh
#
# Blackbox test for share with force user settings
#
if [ $# -lt 6 ]; then
cat <<EOF
Usage: test_forceuser.sh SERVER DOMAIN USERNAME PASSWORD LOCAL_PATH SMBCLIENT <smbclient arguments>
EOF
exit 1;
fi
SERVER="$1"
DOMAIN="$2"
USERNAME="force_user"
PASSWORD="$4"
LOCAL_PATH="$5"
SMBCLIENT="$6"
SMBCLIENT="$VALGRIND ${SMBCLIENT}"
shift 6
ADDARGS="$*"
failed=0
incdir=`dirname $0`/../../../testprogs/blackbox
. $incdir/subunit.sh
run_cmd_nooutput() {
CMD="$1"
out=`eval ${CMD} &> TESTOUT`
if [ $? != 0 ] ; then
cat TESTOUT
rm -f TESTOUT
echo "command failed"
false
return
fi
rm -f TESTOUT
true
return
}
test_force_user_valid_users()
{
SMB_SHARE="force_user_valid_users"
run_cmd_nooutput "${SMBCLIENT} //${SERVER}/${SMB_SHARE} -U$USERNAME%$PASSWORD -c 'ls'"
}
# Test
testit "force user not works when combined with valid users" \
test_force_user_valid_users || failed=`expr $failed + 1`
# Cleanup
# Results
testok $0 $failed

View File

@ -181,6 +181,7 @@ for env in ["fileserver"]:
plantestsuite("samba3.blackbox.valid_users (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_valid_users.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$PREFIX', smbclient3])
plantestsuite("samba3.blackbox.offline (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_offline.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/offline', smbclient3])
plantestsuite("samba3.blackbox.shadow_copy2 (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_shadow_copy.sh"), '$SERVER', '$SERVER_IP', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH/shadow', smbclient3])
plantestsuite("samba3.blackbox.smbclient.forceuser_validusers (%s)" % env, env, [os.path.join(samba3srcdir, "script/tests/test_forceuser_validusers.sh"), '$SERVER', '$DOMAIN', '$USERNAME', '$PASSWORD', '$LOCAL_PATH', smbclient3])
#
# tar command tests