The branch, v4-15-test has been updated via c7b633f3172 s3/client: fix dfs deltree, resolve dfs path via 25fa2c75304 Add test smbclient 'delree' of dir (on DFS share) via afb66509398 s3/client: fix dfs delete, resolve dfs path via 468736e7546 Add test smbclient 'del' of file (on DFS share) via 4442b27ee48 Add new dfs node msdfs-share pointing to new msdfs-share2 from a1bb535cfb3 cmdline_s4: re-initialise logging once loadparm is ready
https://git.samba.org/?p=samba.git;a=shortlog;h=v4-15-test - Log ----------------------------------------------------------------- commit c7b633f3172f3db5d17e5a30b8987b1b6963bc96 Author: Noel Power <noel.po...@suse.com> Date: Thu Jun 16 17:17:45 2022 +0100 s3/client: fix dfs deltree, resolve dfs path since 4cc4938a2866738aaff4dc91550bb7a5ad05d7fb do_list seems to deal with non dfs root path, hence we need to resolve the path before calling cli_unlink. Also remove the knownfail We additionally have to also remove the fallback to remove 'file3' int the smbcacls_dfs_propagate_inherit.teardown as the deltree that happens in the baseclass now succeeds. BUG: https://bugzilla.samba.org/show_bug.cgi?id=15100 Signed-off-by: Noel Power <noel.po...@suse.com> Reviewed-by: Jeremy Allison <j...@samba.org> Autobuild-User(master): Jeremy Allison <j...@samba.org> Autobuild-Date(master): Fri Jun 17 17:12:07 UTC 2022 on sn-devel-184 (cherry picked from commit 81fdcf95ae92a02f83501753dec0f29ddd555eeb) Autobuild-User(v4-15-test): Jule Anger <jan...@samba.org> Autobuild-Date(v4-15-test): Mon Jun 20 09:50:34 UTC 2022 on sn-devel-184 commit 25fa2c753040ea2af403cecf65373844b83c2814 Author: Noel Power <noel.po...@suse.com> Date: Fri Jun 17 10:58:48 2022 +0100 Add test smbclient 'delree' of dir (on DFS share) deltree of a file on a DFS share results in NT_STATUS_OBJECT_PATH_NOT_FOUND Addionally add a knownfail for this (to be removed in subsequent patch to fix bug) We also need to add a knownfail (which will not be removed) for the new test which will fail in smb1 envs BUG: https://bugzilla.samba.org/show_bug.cgi?id=15100 Signed-off-by: Noel Power <noel.po...@suse.com> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 23a5a05db03a8f14ab701005a8bec9a3eeff3d77) commit afb6650939862fdabe15739181cf5d2418a53bb7 Author: Noel Power <noel.po...@suse.com> Date: Thu Jun 16 15:12:05 2022 +0100 s3/client: fix dfs delete, resolve dfs path since 4cc4938a2866738aaff4dc91550bb7a5ad05d7fb do_list seems to deal with non dfs root path, hence we need to resolve the path before calling cli_unlink. Also remove the knownfail BUG: https://bugzilla.samba.org/show_bug.cgi?id=15100 Signed-off-by: Noel Power <noel.po...@suse.com> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 7c4cb4982330cd2eda53950e977179920b1e3b04) commit 468736e75468a321620e916d13c1bfef09430fb1 Author: Noel Power <noel.po...@suse.com> Date: Fri Jun 17 10:25:49 2022 +0100 Add test smbclient 'del' of file (on DFS share) del of a file on a DFS share results in NT_STATUS_OBJECT_PATH_NOT_FOUND Addionally add a knownfail (will be removed in following patch to fix the bug) We also need to add a knownfail (which will not be removed) for the new test which will fail in smb1 envs BUG: https://bugzilla.samba.org/show_bug.cgi?id=15100 Signed-off-by: Noel Power <noel.po...@suse.com> Reviewed-by: Jeremy Allison <j...@samba.org> (back-ported from commit db1b4df0ab3b18821da3c2dbe6d6058f0c3019b8) commit 4442b27ee48f8379edcdb54f284ade9cd14e1bc2 Author: Noel Power <noel.po...@suse.com> Date: Fri Jun 17 10:15:42 2022 +0100 Add new dfs node msdfs-share pointing to new msdfs-share2 Also add another node within msdfs-share2 pointing to normal share This patch is in preperation for creating a test for 'del' & 'deltree' on DFS shares. The extra redirection is necessary to reproduce the bug BUG: https://bugzilla.samba.org/show_bug.cgi?id=15100 Signed-off-by: Noel Power <noel.po...@suse.com> Reviewed-by: Jeremy Allison <j...@samba.org> (cherry picked from commit 39672a9676bff53d3ccc0ad7c1fa65a95cbceaab) ----------------------------------------------------------------------- Summary of changes: .../blackbox/smbcacls_dfs_propagate_inherit.py | 8 -- selftest/knownfail.d/smb1-tests | 2 + selftest/target/Samba3.pm | 9 ++ source3/client/client.c | 63 +++++++++++--- source3/script/tests/test_smbclient_s3.sh | 95 ++++++++++++++++++++++ 5 files changed, 158 insertions(+), 19 deletions(-) Changeset truncated at 500 lines: diff --git a/python/samba/tests/blackbox/smbcacls_dfs_propagate_inherit.py b/python/samba/tests/blackbox/smbcacls_dfs_propagate_inherit.py index 36c29c8ccca..42680df0d06 100644 --- a/python/samba/tests/blackbox/smbcacls_dfs_propagate_inherit.py +++ b/python/samba/tests/blackbox/smbcacls_dfs_propagate_inherit.py @@ -85,11 +85,3 @@ class DfsInheritanceSmbCaclsTests(InheritanceSmbCaclsTests): def tearDown(self): super(DfsInheritanceSmbCaclsTests, self).tearDown() - # for dfs tests inevitably we fallback to remove the local files in - # the base class, the base class however doesn't know about the - # target dfs share (or its contents) so we have to assume we need to - # remove the file on the dfs share - smbclient_args = self.build_test_cmd("smbclient", ["//%s/%s" % (self.server, self.dfs_target_share), "-c", "rm file-3"]) - self.check_output(smbclient_args) - - diff --git a/selftest/knownfail.d/smb1-tests b/selftest/knownfail.d/smb1-tests index 03d299ad7c7..b5263f28016 100644 --- a/selftest/knownfail.d/smb1-tests +++ b/selftest/knownfail.d/smb1-tests @@ -10,6 +10,8 @@ ^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.interactive smbclient -l prompts on stdout\((ad_member|nt4_member)\) ^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.creating a bad symlink and deleting it\((ad_member|nt4_member)\) ^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.Accessing an MS-DFS link\((ad_member|nt4_member)\) +^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.del on MS-DFS share\((ad_member|nt4_member)\) +^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.deltree on MS-DFS share\((ad_member|nt4_member)\) ^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.Ensure archive bit is set correctly on file/dir rename\((ad_member|nt4_member)\) ^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.ccache access works for smbclient\((ad_member|nt4_member)\) ^samba3.blackbox.smbclient_s3.NT1.(plain|sign).member_creds.using an authentication file\((ad_member|nt4_member)\) diff --git a/selftest/target/Samba3.pm b/selftest/target/Samba3.pm index ba0ebb58b2f..e578791a2ee 100755 --- a/selftest/target/Samba3.pm +++ b/selftest/target/Samba3.pm @@ -2374,6 +2374,9 @@ sub provision($$) my $msdfs_shrdir="$shrdir/msdfsshare"; push(@dirs,$msdfs_shrdir); + my $msdfs_shrdir2="$shrdir/msdfsshare2"; + push(@dirs,$msdfs_shrdir2); + my $msdfs_deeppath="$msdfs_shrdir/deeppath"; push(@dirs,$msdfs_deeppath); @@ -2467,6 +2470,8 @@ sub provision($$) symlink "msdfs:$server_ip\\smbcacls_sharedir_dfs,$server_ipv6\\smbcacls_sharedir_dfs", "$msdfs_shrdir/smbcacls_sharedir_dfs"; + symlink "msdfs:$server_ip\\msdfs-share2,$server_ipv6\\msdfs-share2", "$msdfs_shrdir/dfshop1"; + symlink "msdfs:$server_ip\\tmp,$server_ipv6\\tmp", "$msdfs_shrdir2/dfshop2"; ## ## create bad names in $badnames_shrdir ## @@ -2790,6 +2795,10 @@ sub provision($$) msdfs root = yes msdfs shuffle referrals = yes guest ok = yes +[msdfs-share2] + path = $msdfs_shrdir2 + msdfs root = yes + guest ok = yes [hideunread] copy = tmp hide unreadable = yes diff --git a/source3/client/client.c b/source3/client/client.c index 5ad6ee7b844..f3c94de5bce 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2378,6 +2378,9 @@ static NTSTATUS do_del(struct cli_state *cli_state, struct file_info *finfo, { TALLOC_CTX *ctx = talloc_tos(); char *mask = NULL; + struct cli_state *targetcli = NULL; + char *targetname = NULL; + struct cli_credentials *creds = samba_cmdline_get_creds(); NTSTATUS status; mask = talloc_asprintf(ctx, @@ -2394,7 +2397,15 @@ static NTSTATUS do_del(struct cli_state *cli_state, struct file_info *finfo, return NT_STATUS_OK; } - status = cli_unlink(cli_state, mask, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); + status = cli_resolve_path(ctx, "", + creds, + cli, mask, &targetcli, &targetname); + if (!NT_STATUS_IS_OK(status)) { + goto out; + } + + status = cli_unlink(targetcli, targetname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); +out: if (!NT_STATUS_IS_OK(status)) { d_printf("%s deleting remote file %s\n", nt_errstr(status), mask); @@ -2452,20 +2463,37 @@ static NTSTATUS delete_remote_files_list(struct cli_state *cli_state, { NTSTATUS status = NT_STATUS_OK; struct file_list *deltree_list_iter = NULL; + char *targetname = NULL; + struct cli_state *targetcli = NULL; + struct cli_credentials *creds = samba_cmdline_get_creds(); + TALLOC_CTX *ctx = talloc_tos(); for (deltree_list_iter = flist; deltree_list_iter != NULL; deltree_list_iter = deltree_list_iter->next) { + status = cli_resolve_path(ctx, + "", + creds, + cli_state, + deltree_list_iter->file_path, + &targetcli, + &targetname); + if (!NT_STATUS_IS_OK(status)) { + d_printf("delete_remote_files %s: %s\n", + deltree_list_iter->file_path, + nt_errstr(status)); + return status; + } if (CLI_DIRSEP_CHAR == '/') { /* POSIX. */ - status = cli_posix_unlink(cli_state, - deltree_list_iter->file_path); + status = cli_posix_unlink(targetcli, + targetname); } else if (deltree_list_iter->isdir) { - status = cli_rmdir(cli_state, - deltree_list_iter->file_path); + status = cli_rmdir(targetcli, + targetname); } else { - status = cli_unlink(cli_state, - deltree_list_iter->file_path, + status = cli_unlink(targetcli, + targetname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); } @@ -2574,14 +2602,27 @@ static int cmd_deltree(void) deltree_list_iter = deltree_list_iter->next) { if (deltree_list_iter->isdir == false) { + char *targetname = NULL; + struct cli_state *targetcli = NULL; + struct cli_credentials *creds = samba_cmdline_get_creds(); + status = cli_resolve_path(ctx, + "", + creds, + cli, + deltree_list_iter->file_path, + &targetcli, + &targetname); + if (!NT_STATUS_IS_OK(status)) { + goto err; + } /* Just a regular file. */ if (CLI_DIRSEP_CHAR == '/') { /* POSIX. */ - status = cli_posix_unlink(cli, - deltree_list_iter->file_path); + status = cli_posix_unlink(targetcli, + targetname); } else { - status = cli_unlink(cli, - deltree_list_iter->file_path, + status = cli_unlink(targetcli, + targetname, FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN); } diff --git a/source3/script/tests/test_smbclient_s3.sh b/source3/script/tests/test_smbclient_s3.sh index 4d03b97f476..caf5b3f64d7 100755 --- a/source3/script/tests/test_smbclient_s3.sh +++ b/source3/script/tests/test_smbclient_s3.sh @@ -528,6 +528,93 @@ EOF return 0 } +test_msdfs_del() +{ + tmpfile="$PREFIX/smbclient.in.$$" + filename_src="src.$$" + filename_src_path="$PREFIX/$filename_src" + rm -f "$filename_src_path" + touch "$filename_src_path" + + cat > $tmpfile <<EOF +lcd $PREFIX +cd dfshop1 +cd dfshop2 +put $filename_src +del $filename_src +quit +EOF + + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + rm -f "$tmpfile" + rm -f "$filename_src_path" + + if [ $ret != 0 ] ; then + echo "$out" + echo "failed deleteing $filename_src with error $ret" + return 1 + fi + + echo "$out" | grep "NT_STATUS" >/dev/null 2>&1 + + ret="$?" + if [ "$ret" -eq 0 ] ; then + echo "$out" + echo "del $filename_src NT_STATUS_ error" + return 1 + fi + return 0 +} + +test_msdfs_deltree() +{ + tmpfile="$PREFIX/smbclient.in.$$" + dirname_src="foodir.$$" + filename_src="src.$$" + filename_src_path="$PREFIX/$filename_src" + dirname_src_path="$PREFIX/$dirname" + rm -f "$filename_src_path" + touch "$filename_src_path" + + cat > $tmpfile <<EOF +lcd $PREFIX +cd dfshop1 +cd dfshop2 +mkdir $dirname_src +cd $dirname_src +put $filename_src +cd .. +deltree $dirname_src +quit +EOF + + cmd='CLI_FORCE_INTERACTIVE=yes $SMBCLIENT "$@" -U$USERNAME%$PASSWORD //$SERVER/msdfs-share -I $SERVER_IP $ADDARGS < $tmpfile 2>&1' + eval echo "$cmd" + out=`eval $cmd` + ret=$? + rm -f "$tmpfile" + rm -f "$filename_src_path" + rm -f "$dirname_src_path" + + if [ $ret != 0 ] ; then + echo "$out" + echo "deltree failed deleting dir $dirname_src with error $ret" + return 1 + fi + + echo "$out" | grep "NT_STATUS" >/dev/null 2>&1 + + ret="$?" + if [ "$ret" -eq 0 ] ; then + echo "$out" + echo "deltree $dirname_src NT_STATUS_ error" + return 1 + fi + return 0 +} # Archive bits are correctly set on file/dir creation and rename. test_rename_archive_bit() @@ -2125,6 +2212,14 @@ testit "Hardlink on MS-DFS share" \ test_msdfs_hardlink || \ failed=`expr $failed + 1` +testit "del on MS-DFS share" \ + test_msdfs_del || \ + failed=`expr $failed + 1` + +testit "deltree on MS-DFS share" \ + test_msdfs_deltree || \ + failed=`expr $failed + 1` + testit "Ensure archive bit is set correctly on file/dir rename" \ test_rename_archive_bit || \ failed=`expr $failed + 1` -- Samba Shared Repository