From 48d3c25d941bef64f38d3779f842c48e44a27dc7 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 --- 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 eb46735f5943161012d5e6d154925e1e66bf77cf 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 --- selftest/target/Samba3.pm | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index 5623e2a149f..8b1d809c941 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -1369,6 +1369,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); @@ -1397,6 +1400,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 d2a5dcc0ca5cffa7967bc3cca92452597be8658a 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 --- 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 6cfb98e2bb6..8a5d69132e6 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -483,11 +483,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 aeaa64cc128af1b045bc5efcf74ea2687efb4d9f 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 --- 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 8a5d69132e6..5e90fab1692 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -483,11 +483,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 e5fc63a7fe106b02e0f4abdf1e2a8d9b3419c210 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 --- 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 b6255462e4dd5ada9fd2e0f686d804f620c51be4 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 --- 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 d0e4bb2b246690c62530ef30b2378a0500d5ebfc 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 --- 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 5e90fab1692..74bf3abb95f 100755 --- a/source3/selftest/tests.py +++ b/source3/selftest/tests.py @@ -492,14 +492,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 087dfc4aee0727aa3bd6e75e7d0f326cbcd275ec 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 --- 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 4e0759b7b38446d255f8f2945effc3624d826a99 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 --- .../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 87620dc5c170c721f2c64babf266176d45745566 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 --- 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 40d3add8377570ec6be18636ad5d5ab8c5171cdb 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 --- 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 2e1919bfdefb34a42972ee98b5861a73e2e9fe5c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Thu, 26 Nov 2020 15:10:32 +0000 Subject: [PATCH 12/13] s3/client: Allow do_list() to be called recursively. clitar.c does this. Add a push/pop stack for all of the elements of the do_list state. Leave a static global pointer 'do_list_stack_head'- this points to the top of the stack and is the current do_list state. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14581 Signed-off-by: Jeremy Allison --- source3/client/client.c | 85 ++++++++++++++++++++++++++++------------- 1 file changed, 58 insertions(+), 27 deletions(-) diff --git a/source3/client/client.c b/source3/client/client.c index e2fdacd1251..176d0909a80 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -680,25 +680,52 @@ struct do_list_queue { struct do_list_queue_entry *list; }; -static bool do_list_recurse; -static bool do_list_dirs; -static struct do_list_queue *queue = NULL; -static NTSTATUS (*do_list_fn)(struct cli_state *cli_state, struct file_info *, +/* + * Current state of a do_list() in process. As + * do_list() can be called recursively from inside do_list() + * in the tar code, we need to keep a stack of + * do_list internal states in progress. Push to + * the front of the queue on entry to do_list(). + * Pop from the front of the queue on exit from do_list(). + */ + +struct do_list_stack { + struct do_list_stack *prev, *next; + bool do_list_recurse; + bool do_list_dirs; + struct do_list_queue *queue; + NTSTATUS (*do_list_fn)(struct cli_state *cli_state, struct file_info *, const char *dir); +}; + +static struct do_list_stack *do_list_stack_head; /**************************************************************************** - Functions for do_list_queue. + Functions for do_list_stacks. ****************************************************************************/ -static void reset_do_list_queue(void) +static void pop_do_list_stack(void) { - TALLOC_FREE(queue); + struct do_list_stack *stack_entry = do_list_stack_head; + DLIST_REMOVE(do_list_stack_head, do_list_stack_head); + TALLOC_FREE(stack_entry); } -static void init_do_list_queue(void) +static NTSTATUS push_do_list_stack(void) { - TALLOC_FREE(queue); - queue = talloc_zero(NULL, struct do_list_queue); + struct do_list_stack *stack_entry = + talloc_zero(NULL, struct do_list_stack); + + if (stack_entry == NULL) { + return NT_STATUS_NO_MEMORY; + } + stack_entry->queue = talloc_zero(stack_entry, struct do_list_queue); + if (stack_entry->queue == NULL) { + TALLOC_FREE(stack_entry); + return NT_STATUS_NO_MEMORY; + } + DLIST_ADD(do_list_stack_head, stack_entry); + return NT_STATUS_OK; } static void add_to_do_list_queue(const char *entry) @@ -710,7 +737,7 @@ static void add_to_do_list_queue(const char *entry) entry_len += entry_str_len; SMB_ASSERT(entry_len >= entry_str_len); - e = talloc_size(queue, entry_len); + e = talloc_size(do_list_stack_head->queue, entry_len); if (e == NULL) { d_printf("talloc failed for entry %s\n", entry); return; @@ -718,24 +745,25 @@ static void add_to_do_list_queue(const char *entry) talloc_set_name_const(e, "struct do_list_queue_entry"); memcpy(e->name, entry, entry_str_len); - DLIST_ADD_END(queue->list, e); + DLIST_ADD_END(do_list_stack_head->queue->list, e); } static char *do_list_queue_head(void) { - return queue->list->name; + return do_list_stack_head->queue->list->name; } static void remove_do_list_queue_head(void) { - struct do_list_queue_entry *e = queue->list; - DLIST_REMOVE(queue->list, e); + struct do_list_queue_entry *e = do_list_stack_head->queue->list; + DLIST_REMOVE(do_list_stack_head->queue->list, e); TALLOC_FREE(e); } static int do_list_queue_empty(void) { - return (queue == NULL) || (queue->list == NULL); + return (do_list_stack_head->queue == NULL) || + (do_list_stack_head->queue->list == NULL); } /**************************************************************************** @@ -770,20 +798,20 @@ static NTSTATUS do_list_helper( if (!(f->attr & FILE_ATTRIBUTE_DIRECTORY)) { if (do_this_one(f)) { - status = do_list_fn(state->cli, f, dir); + status = do_list_stack_head->do_list_fn(state->cli, f, dir); } TALLOC_FREE(dir); return status; } - if (do_list_dirs && do_this_one(f)) { - status = do_list_fn(state->cli, f, dir); + if (do_list_stack_head->do_list_dirs && do_this_one(f)) { + status = do_list_stack_head->do_list_fn(state->cli, f, dir); if (!NT_STATUS_IS_OK(status)) { return status; } } - if (!do_list_recurse || + if (!do_list_stack_head->do_list_recurse || (f->name == NULL) || ISDOT(f->name) || ISDOTDOT(f->name)) { @@ -837,13 +865,16 @@ NTSTATUS do_list(const char *mask, exit(1); } - in_do_list = 1; + ret_status = push_do_list_stack(); + if (!NT_STATUS_IS_OK(ret_status)) { + return ret_status; + } + in_do_list++; - do_list_recurse = rec; - do_list_dirs = dirs; - do_list_fn = fn; + do_list_stack_head->do_list_recurse = rec; + do_list_stack_head->do_list_dirs = dirs; + do_list_stack_head->do_list_fn = fn; - init_do_list_queue(); add_to_do_list_queue(mask); while (!do_list_queue_empty()) { @@ -904,8 +935,8 @@ NTSTATUS do_list(const char *mask, TALLOC_FREE(targetpath); } - in_do_list = 0; - reset_do_list_queue(); + in_do_list--; + pop_do_list_stack(); return ret_status; } -- 2.27.0 From 3147bb07c0b0d389328a5dcbae996a8d5c15f065 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 --- 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