From 8776188cdbf688d2022beaafe77a0a0aa657a757 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 27 Nov 2020 12:01:49 +0000 Subject: [PATCH 01/13] s3/script/tests: Fix 'Unrecognized option(s) passed to mkpath()' error 'keep_root' is an unrecognised option for make_path/mkpath BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 4f5a7f11b7732c3efb511e68f6b9d434d59bb3e8) --- source3/script/tests/test_smbclient_tarmode.pl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl index 877eec45cc8..d638ae5ac4b 100755 --- a/source3/script/tests/test_smbclient_tarmode.pl +++ b/source3/script/tests/test_smbclient_tarmode.pl @@ -918,7 +918,7 @@ sub reset_remote { # remove_tree($LOCALPATH . '/'. $DIR); # make_path($LOCALPATH . '/'. $DIR); remove_tree($LOCALPATH, {keep_root => 1}); - make_path($LOCALPATH, {keep_root => 1}); + make_path($LOCALPATH); } =head3 C -- 2.27.0 From ea38767bd3206d1df591a7f1be18a99fb793e107 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Thu, 26 Nov 2020 17:31:50 +0000 Subject: [PATCH 02/13] selftest: Add a new tarmode shares samba3.blackbox.smbclient_tar & samba3.blackbox.smbclient_tar need separate shares with own xattr tdb(s) BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit a250f73366983d2a7397608a611f295f10dbb548) --- selftest/target/Samba3.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 0a8cefa811d..e141f102ef1 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -1334,6 +1334,9 @@ sub setup_fileserver my $tarmode_sharedir="$share_dir/tarmode"; push(@dirs,$tarmode_sharedir); + my $tarmode2_sharedir="$share_dir/tarmode2"; + push(@dirs,$tarmode2_sharedir); + my $smbcacls_sharedir="$share_dir/smbcacls"; push(@dirs,$smbcacls_sharedir); @@ -1362,6 +1365,14 @@ sub setup_fileserver get quota command = $prefix_abs/getset_quota.py set quota command = $prefix_abs/getset_quota.py +[tarmode] + path = $tarmode_sharedir + comment = tar test share + xattr_tdb:file = $prefix_abs/tarmode-xattr.tdb +[tarmode2] + path = $tarmode2_sharedir + comment = tar test share + xattr_tdb:file = $prefix_abs/tarmode2-xattr.tdb [spotlight] path = $share_dir spotlight = yes -- 2.27.0 From f910b10a362c3ec28f3d7fd85fe3d53bb420c7ed Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 27 Nov 2020 15:25:21 +0000 Subject: [PATCH 03/13] s3/script/test: Use different testdir for samba3.blackbox.smbclient_tarmode The other tarmode torture test samba3.blackbox.smbclient_tar now uses a share 'tarmode' which uses the same source path as samba3.blackbox.smbclient_tarmode Avoid conflicting paths and use a new subdir (of the test share) called 'smbclient_tarmode' BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 6cb0a00f4ab4bc1a8193d50cc076ec7174a5ece9) --- source3/script/tests/test_smbclient_tarmode.sh | 8 ++++---- source3/selftest/tests.py | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/source3/script/tests/test_smbclient_tarmode.sh b/source3/script/tests/test_smbclient_tarmode.sh index 3779c38a5ca..298f428b041 100755 --- a/source3/script/tests/test_smbclient_tarmode.sh +++ b/source3/script/tests/test_smbclient_tarmode.sh @@ -105,7 +105,7 @@ test_tarmode_creation() { # Create tarfile with smbclient if ! $SMBCLIENT //$SERVER/tmp $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 \ - $ADDARGS -c "tarmode full" -Tc "$PREFIX/tarmode.tar" "/tarmode"; then + $ADDARGS -c "tarmode full" -Tc "$PREFIX/tarmode.tar" "/smbclient_tar"; then echo "Couldn't create tar file with tarmode -Tc" false return @@ -119,7 +119,7 @@ test_tarmode_creation() { fi # Verify data - if ! validate_data "$PREFIX/tarmode" "$LOCAL_PATH"; then + if ! validate_data "$PREFIX/smbclient_tar" "$LOCAL_PATH"; then echo "Data not equivalent" false return @@ -146,7 +146,7 @@ test_tarmode_extraction() { fi # Create tarfile to extract on client - if ! tar -cf "$PREFIX/tarmode.tar" -C "$PREFIX" tarmode; then + if ! tar -cf "$PREFIX/tarmode.tar" -C "$PREFIX" smbclient_tar; then echo "Couldn't create tar archive" false return @@ -161,7 +161,7 @@ test_tarmode_extraction() { fi # Verify data - if ! validate_data "$PREFIX/tarmode" "$LOCAL_PATH"; then + if ! validate_data "$PREFIX/smbclient_tar" "$LOCAL_PATH"; then echo "Data not equivalent" false return diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index f9202f3f93a..3f425563464 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -476,11 +476,11 @@ for env in ["fileserver"]: plantestsuite("samba3.blackbox.smbclient_tarmode.NT1", env + "_smb1_done", [os.path.join(samba3srcdir, "script/tests/test_smbclient_tarmode.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', - '$LOCAL_PATH/tarmode', '$PREFIX', smbclient3, configuration, "-mNT1"]) + '$LOCAL_PATH/smbclient_tar', '$PREFIX', smbclient3, configuration, "-mNT1"]) plantestsuite("samba3.blackbox.smbclient_tarmode.SMB3", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_tarmode.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', - '$LOCAL_PATH/tarmode', '$PREFIX', smbclient3, configuration, "-mSMB3"]) + '$LOCAL_PATH/smbclient_tar', '$PREFIX', smbclient3, configuration, "-mSMB3"]) # Test suite for new smbclient/tar with libarchive (GSoC 13) plantestsuite("samba3.blackbox.smbclient_tar.NT1", env + "_smb1_done", -- 2.27.0 From 150780ca199c89532389e9ef17952bedf9806ac1 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 27 Nov 2020 15:33:26 +0000 Subject: [PATCH 04/13] s3/script/tests: Use tarmode share for samba3.blackbox.smbclient_tar* After this change both samba3.blackbox.smbclient_tar & samba3.blackbox.smbclient_tarmode now use the same dedicated share BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit be8dca68f89f110ef5947e0c2a7258554772cf9a) --- source3/script/tests/test_smbclient_tarmode.sh | 4 ++-- source3/selftest/tests.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source3/script/tests/test_smbclient_tarmode.sh b/source3/script/tests/test_smbclient_tarmode.sh index 298f428b041..54dd833dae3 100755 --- a/source3/script/tests/test_smbclient_tarmode.sh +++ b/source3/script/tests/test_smbclient_tarmode.sh @@ -104,7 +104,7 @@ test_tarmode_creation() { fi # Create tarfile with smbclient - if ! $SMBCLIENT //$SERVER/tmp $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 \ + if ! $SMBCLIENT //$SERVER/tarmode $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 \ $ADDARGS -c "tarmode full" -Tc "$PREFIX/tarmode.tar" "/smbclient_tar"; then echo "Couldn't create tar file with tarmode -Tc" false @@ -153,7 +153,7 @@ test_tarmode_extraction() { fi # Extract tarfile with smbclient - if ! $SMBCLIENT //$SERVER/tmp $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 \ + if ! $SMBCLIENT //$SERVER/tarmode $CONFIGURATION -U$USERNAME%$PASSWORD -I $SERVER_IP -p 139 \ $ADDARGS -c "tarmode full" -Tx "$PREFIX/tarmode.tar"; then echo "Couldn't extact tar file with tarmode -Tx" false diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 3f425563464..1fd5affdc3b 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -476,11 +476,11 @@ for env in ["fileserver"]: plantestsuite("samba3.blackbox.smbclient_tarmode.NT1", env + "_smb1_done", [os.path.join(samba3srcdir, "script/tests/test_smbclient_tarmode.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', - '$LOCAL_PATH/smbclient_tar', '$PREFIX', smbclient3, configuration, "-mNT1"]) + '$LOCAL_PATH/tarmode/smbclient_tar', '$PREFIX', smbclient3, configuration, "-mNT1"]) plantestsuite("samba3.blackbox.smbclient_tarmode.SMB3", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_tarmode.sh"), '$SERVER', '$SERVER_IP', '$USERNAME', '$PASSWORD', - '$LOCAL_PATH/smbclient_tar', '$PREFIX', smbclient3, configuration, "-mSMB3"]) + '$LOCAL_PATH/tarmode/smbclient_tar', '$PREFIX', smbclient3, configuration, "-mSMB3"]) # Test suite for new smbclient/tar with libarchive (GSoC 13) plantestsuite("samba3.blackbox.smbclient_tar.NT1", env + "_smb1_done", -- 2.27.0 From ad8f32843e635f1ba67d56a55e1f1042ad4db6ba Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 27 Nov 2020 15:52:27 +0000 Subject: [PATCH 05/13] s3/script: Use smbclient deltree to clean up smbclient_tarmode subdir Replace rm -rf of local dir (that is hosted remotely) with smbclient deltree BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit fec1f8faffd9eb1aae77e7c515e57897be34a255) --- source3/script/tests/test_smbclient_tarmode.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source3/script/tests/test_smbclient_tarmode.sh b/source3/script/tests/test_smbclient_tarmode.sh index 54dd833dae3..49680e93196 100755 --- a/source3/script/tests/test_smbclient_tarmode.sh +++ b/source3/script/tests/test_smbclient_tarmode.sh @@ -94,7 +94,7 @@ test_tarmode_creation() { # Clear temp data rm -rf -- "$PREFIX"/tarmode > /dev/null 2>&1 rm -f "$PREFIX"/tarmode.tar > /dev/null 2>&1 - rm -rf "$LOCAL_PATH" > /dev/null 2>&1 + $SMBCLIENT //$SERVER/tarmode $CONFIGURATION -U$USERNAME%$PASSWORD -c "deltree smbclient_tar" # Build the test data if ! create_test_data "$LOCAL_PATH"; then @@ -136,7 +136,7 @@ test_tarmode_extraction() { # Clear temp data rm -rf -- "$PREFIX"/tarmode > /dev/null 2>&1 rm -f "$PREFIX"/tarmode.tar > /dev/null 2>&1 - rm -rf "$LOCAL_PATH" > /dev/null 2>&1 + $SMBCLIENT //$SERVER/tarmode $CONFIGURATION -U$USERNAME%$PASSWORD -c "deltree smbclient_tar" # Build the test data if ! create_test_data "$PREFIX/tarmode"; then -- 2.27.0 From 6e5e72d0e9277d66dce67fe13c49a18787dd777a Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 30 Nov 2020 17:39:25 +0000 Subject: [PATCH 06/13] s3/script/tests: Fix samba3.blackbox.smbclient_tarmode cleanup Make sure samba3.blackbox.smbclient_tarmode removes data files not just before running the test but also after BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 4bb3bffa4b7a770d36138c45f717a9048ef82cff) --- source3/script/tests/test_smbclient_tarmode.sh | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/source3/script/tests/test_smbclient_tarmode.sh b/source3/script/tests/test_smbclient_tarmode.sh index 49680e93196..8bc5b9947cf 100755 --- a/source3/script/tests/test_smbclient_tarmode.sh +++ b/source3/script/tests/test_smbclient_tarmode.sh @@ -111,7 +111,8 @@ test_tarmode_creation() { return fi - # Extract data to verify + # Extract data to verify - this puts it into $PREFIX/smbclient_tar/ + # but we must leave it there as it's used to verify in test_tarmode_extraction() if ! tar -xf "$PREFIX/tarmode.tar" -C "$PREFIX"; then echo "Couldn't extract data from created tarfile" false @@ -125,6 +126,10 @@ test_tarmode_creation() { return fi + # Clear temp data + rm -rf -- "$PREFIX"/tarmode > /dev/null 2>&1 + rm -f "$PREFIX"/tarmode.tar > /dev/null 2>&1 + $SMBCLIENT //$SERVER/tarmode $CONFIGURATION -U$USERNAME%$PASSWORD -c "deltree smbclient_tar" true return @@ -167,6 +172,12 @@ test_tarmode_extraction() { return fi + # Clear temp data + rm -rf -- "$PREFIX"/tarmode > /dev/null 2>&1 + rm -f "$PREFIX"/tarmode.tar > /dev/null 2>&1 + $SMBCLIENT //$SERVER/tarmode $CONFIGURATION -U$USERNAME%$PASSWORD -c "deltree smbclient_tar" + # Cleanup the verification data created by test_tarmode_creation(). + rm -rf "$PREFIX"/smbclient_tar > /dev/null 2>&1 true return -- 2.27.0 From 25566865ba4f64d8d399b2ae92b9e84a1fa9632b Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 30 Nov 2020 11:15:06 +0000 Subject: [PATCH 07/13] selftest: make samba3.blackbox.smbclient_tar runnable (even manually) samba3.blackbox.smbclient_tar is marked as flapping so it seems we have missed that it has stopped working. The local path passed to script/tests/test_smbclient_tarmode.pl must point to a valid share BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 6f246658cf003f7e2f393f7b7490d9e8ae84e21c) --- source3/selftest/tests.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/source3/selftest/tests.py b/source3/selftest/tests.py index 1fd5affdc3b..27dc7587b17 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -485,14 +485,14 @@ for env in ["fileserver"]: # Test suite for new smbclient/tar with libarchive (GSoC 13) plantestsuite("samba3.blackbox.smbclient_tar.NT1", env + "_smb1_done", [os.path.join(samba3srcdir, "script/tests/test_smbclient_tarmode.pl"), - '-n', '$SERVER', '-i', '$SERVER_IP', '-s', 'tmp', - '-u', '$USERNAME', '-p', '$PASSWORD', '-l', '$LOCAL_PATH/tarmode', + '-n', '$SERVER', '-i', '$SERVER_IP', '-s', 'tarmode2', + '-u', '$USERNAME', '-p', '$PASSWORD', '-l', '$LOCAL_PATH/tarmode2', '-d', '$PREFIX', '-b', smbclient3, '--subunit', '--', configuration, '-mNT1']) plantestsuite("samba3.blackbox.smbclient_tar.SMB3", env, [os.path.join(samba3srcdir, "script/tests/test_smbclient_tarmode.pl"), - '-n', '$SERVER', '-i', '$SERVER_IP', '-s', 'tmp', - '-u', '$USERNAME', '-p', '$PASSWORD', '-l', '$LOCAL_PATH/tarmode', + '-n', '$SERVER', '-i', '$SERVER_IP', '-s', 'tarmode2', + '-u', '$USERNAME', '-p', '$PASSWORD', '-l', '$LOCAL_PATH/tarmode2', '-d', '$PREFIX', '-b', smbclient3, '--subunit', '--', configuration, '-mSMB3']) -- 2.27.0 From b9221c75c75da94b4f6a95b5dc6d1147b32e6cd6 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 30 Nov 2020 09:59:58 +0000 Subject: [PATCH 08/13] s3/script/tests: Remove make_path (for remote dir) LOCALPATH is actually the local path to the share, we should not need to create the share path (it should already exist) Note: When we remove the tree located at LOCALPATH we keep the root so the share path should always be there BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 99ffa4a98287f125e45690e87b32616f4d4254e4) --- source3/script/tests/test_smbclient_tarmode.pl | 2 -- 1 file changed, 2 deletions(-) diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl index d638ae5ac4b..4aaee3e8c9c 100755 --- a/source3/script/tests/test_smbclient_tarmode.pl +++ b/source3/script/tests/test_smbclient_tarmode.pl @@ -1,5 +1,4 @@ #!/usr/bin/perl - # Unix SMB/CIFS implementation. # Test suite for the tar backup mode of smbclient. # Copyright (C) Aurélien Aptel 2013 @@ -918,7 +917,6 @@ sub reset_remote { # remove_tree($LOCALPATH . '/'. $DIR); # make_path($LOCALPATH . '/'. $DIR); remove_tree($LOCALPATH, {keep_root => 1}); - make_path($LOCALPATH); } =head3 C -- 2.27.0 From b6a78c8384f436184c03f7906607b9f6bc8ed98a Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 30 Nov 2020 10:18:32 +0000 Subject: [PATCH 09/13] s3/script/tests: Make smb_client 'die' behaviour configurable smb_client behaviour is to die if there is an error. This is a little heavy handed and make it impossible for example to use smb_client to run a command that might fail (where such a failure isn't really an error) E.G. Calling deltree and the directory doesn't exist BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 363bfa4e1ca10e64057a6d04d6faff7c788db89d) --- .../script/tests/test_smbclient_tarmode.pl | 36 ++++++++++++++++--- 1 file changed, 31 insertions(+), 5 deletions(-) diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl index 4aaee3e8c9c..7b9e2f938d1 100755 --- a/source3/script/tests/test_smbclient_tarmode.pl +++ b/source3/script/tests/test_smbclient_tarmode.pl @@ -1118,7 +1118,9 @@ sub check_tar { return (@more + @less + @diff); # nb of errors } -=head3 C +=head3 C + +=head3 C Run smbclient with C<@args> passed as argument and return output. @@ -1129,11 +1131,12 @@ the command-line are already inserted. The output contains both the C and C. -Die if smbclient crashes or exits with an error code. +if C<$will_die> then Die if smbclient crashes or exits with an error code. +otherwise return output =cut -sub smb_client { - my (@args) = @_; +sub smb_client_cmd { + my ($will_die, @args) = @_; my $fullpath = "//$HOST/$SHARE"; my $cmd = sprintf("%s %s %s", @@ -1166,11 +1169,34 @@ sub smb_client { } if ($err) { - die "ERROR: $errstr"; + if ($will_die) { + die "ERROR: $errstr"; + } else { + say "ERROR: $errstr"; + } } return $out; } +=head3 C + +Run smbclient with C<@args> passed as argument and return output. + +Each element of C<@args> becomes one escaped argument of smbclient. + +Host, share, user, password and the additionnal arguments provided on +the command-line are already inserted. + +The output contains both the C and C. + +Die if smbclient crashes or exits with an error code. + +=cut +sub smb_client { + my (@args) = @_; + return smb_client_cmd(1, @args) +} + sub smb_cmd { return smb_client('-c', join(' ', @_)); } -- 2.27.0 From 0d4ca4d064b033f33c68c3b9869114a5fcc82be4 Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 30 Nov 2020 10:41:57 +0000 Subject: [PATCH 10/13] s3/script/tests: call smbclient deltree to remove remote files BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 6c7dc4959fd5de4382aee413b4cc711cc6f281f4) --- source3/script/tests/test_smbclient_tarmode.pl | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl index 7b9e2f938d1..c0c35b93732 100755 --- a/source3/script/tests/test_smbclient_tarmode.pl +++ b/source3/script/tests/test_smbclient_tarmode.pl @@ -303,6 +303,8 @@ sub test_creation_attr { @inc = grep { $_->attr('a') && !$_->attr_any('h', 's') } @all; smb_tar('tarmode inc nohidden nosystem', '-Tc', $TAR, $DIR); $err += check_tar($TAR, \@inc); + # adjust attr so remote files can be deleted with deltree + File::walk(sub { $_->set_attr(qw/n r s h/) }, File::tree($DIR)); $err; } @@ -398,7 +400,10 @@ sub test_creation_incremental { } else { smb_tar('', '-Tcg', $TAR, $DIR); } - return check_tar($TAR, \@files); + my $res = check_tar($TAR, \@files); + # adjust attr so remote files can be deleted with deltree + File::walk(sub { $_->set_attr(qw/n r s h/) }, File::tree($DIR)); + return $res } @@ -916,7 +921,7 @@ Remove all files in the server C<$DIR> (not root) sub reset_remote { # remove_tree($LOCALPATH . '/'. $DIR); # make_path($LOCALPATH . '/'. $DIR); - remove_tree($LOCALPATH, {keep_root => 1}); + smb_client_cmd(0, '-c', "deltree ./*"); } =head3 C -- 2.27.0 From 7781d6e1cff56e4a05a8f5fb22fb0e5fc7914d9d Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 30 Nov 2020 17:19:29 +0000 Subject: [PATCH 11/13] s3/script/tests: Ensure all remote test files are removed BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Jeremy Allison Reviewed-by: Noel Power (cherry picked from commit 16ffa17ee28edfc3bc70c66abf41b5518aeab8fe) --- source3/script/tests/test_smbclient_tarmode.pl | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/source3/script/tests/test_smbclient_tarmode.pl b/source3/script/tests/test_smbclient_tarmode.pl index c0c35b93732..bdbbd1a44a8 100755 --- a/source3/script/tests/test_smbclient_tarmode.pl +++ b/source3/script/tests/test_smbclient_tarmode.pl @@ -921,7 +921,22 @@ Remove all files in the server C<$DIR> (not root) sub reset_remote { # remove_tree($LOCALPATH . '/'. $DIR); # make_path($LOCALPATH . '/'. $DIR); + my $DIR; + my @names; + my $name; + smb_client_cmd(0, '-c', "deltree ./*"); + + # Ensure all files are gone. + + opendir(DIR,$LOCALPATH) or die "Can't open $LOCALPATH\n"; + @names = readdir(DIR) or die "Unable to read $LOCALPATH\n"; + closedir(DIR); + foreach $name (@names) { + next if ($name eq "."); # skip the current directory entry + next if ($name eq ".."); # skip the parent directory entry + die "$LOCALPATH not empty\n"; + } } =head3 C -- 2.27.0 From d7fb937d117386aeb4556a15a6185def9a35f244 Mon Sep 17 00:00:00 2001 From: Volker Lendecke Date: Tue, 1 Dec 2020 08:58:14 +0100 Subject: [PATCH 12/13] clitar: Use do_list()'s recursion in clitar.c BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Volker Lendecke Reviewed-by: Aurelien Aptel Reviewed-by: Noel Power (cherry picked from commit 20e0ce508844fec2dd0011423b10484dc7ccfdb7) --- source3/client/clitar.c | 41 ++++++++--------------------------------- 1 file changed, 8 insertions(+), 33 deletions(-) diff --git a/source3/client/clitar.c b/source3/client/clitar.c index 3fe3622aba6..4fd1f3c47d9 100644 --- a/source3/client/clitar.c +++ b/source3/client/clitar.c @@ -711,7 +711,7 @@ static int tar_create(struct tar* t) goto out_close; } DBG(5, ("tar_process do_list with mask: %s\n", mask)); - status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, false, true); + status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, true, true); if (!NT_STATUS_IS_OK(status)) { DBG(0, ("do_list fail %s\n", nt_errstr(status))); err = 1; @@ -806,7 +806,7 @@ static int tar_create_from_list(struct tar *t) DBG(5, ("cd '%s' before do_list\n", base)); client_set_cur_dir(base); } - status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, false, true); + status = do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, true, true); if (base != NULL) { client_set_cur_dir(start_dir); } @@ -837,7 +837,7 @@ static NTSTATUS get_file_callback(struct cli_state *cli, char *remote_name; char *old_dir = NULL; char *new_dir = NULL; - const char *initial_dir = client_get_cur_dir(); + const char *initial_dir = dir; bool skip = false; bool isdir; int rc; @@ -846,7 +846,7 @@ static NTSTATUS get_file_callback(struct cli_state *cli, return NT_STATUS_NO_MEMORY; } - remote_name = talloc_asprintf(ctx, "%s%s", initial_dir, finfo->name); + remote_name = talloc_asprintf(ctx, "%s\\%s", initial_dir, finfo->name); if (remote_name == NULL) { status = NT_STATUS_NO_MEMORY; goto out; @@ -884,35 +884,10 @@ static NTSTATUS get_file_callback(struct cli_state *cli, goto out; } - if (isdir) { - char *mask; - mask = talloc_asprintf(ctx, "%s*", new_dir); - if (mask == NULL) { - status = NT_STATUS_NO_MEMORY; - goto out; - } - mask = client_clean_name(ctx, mask); - if (mask == NULL) { - status = NT_STATUS_NO_MEMORY; - goto out; - } - - rc = tar_get_file(&tar_ctx, remote_name, finfo); - if (rc != 0) { - status = NT_STATUS_UNSUCCESSFUL; - goto out; - } - - client_set_cur_dir(new_dir); - do_list(mask, TAR_DO_LIST_ATTR, get_file_callback, false, true); - client_set_cur_dir(old_dir); - tar_ctx.numdir++; - } else { - rc = tar_get_file(&tar_ctx, remote_name, finfo); - if (rc != 0) { - status = NT_STATUS_UNSUCCESSFUL; - goto out; - } + rc = tar_get_file(&tar_ctx, remote_name, finfo); + if (rc != 0) { + status = NT_STATUS_UNSUCCESSFUL; + goto out; } out: -- 2.27.0 From 7cc2db0a39c450306a9389f00b1f0db4aae1159f Mon Sep 17 00:00:00 2001 From: Noel Power Date: Mon, 30 Nov 2020 09:21:50 +0000 Subject: [PATCH 13/13] selftest: Remove samba3.blackbox.smbclient_tar from flapping tests BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Noel Power Reviewed-by: Jeremy Allison (cherry picked from commit 89e2d68bb4d93dc391af97f35ff1148aec7930b0) --- selftest/flapping | 1 - 1 file changed, 1 deletion(-) diff --git a/selftest/flapping b/selftest/flapping index c9f0adbf1bd..8c3f9e8969a 100644 --- a/selftest/flapping +++ b/selftest/flapping @@ -31,6 +31,5 @@ # This test just is not reliable in finding the max search limit # ^samba4.ldap.notification.python\(.*\).__main__.LDAPNotificationTest.test_max_search -^samba3.blackbox.smbclient_tar.* # fails very, very often on sn-devel ^samba3.blackbox.smbclient_s3.*.sending a message to the remote server # flakey on sn-devel-104 and sn-devel-144 ^samba3.blackbox.smbclient_s3.*.creating a good symlink and deleting it by path # flakey on sn-devel-104 and sn-devel-144 -- 2.27.0