From: Noel Power Date: Thu, 16 Jun 2022 16:17:45 +0000 (+0100) Subject: s3/client: fix dfs deltree, resolve dfs path X-Git-Tag: tevent-0.13.0~367 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=81fdcf95ae92a02f83501753dec0f29ddd555eeb;p=thirdparty%2Fsamba.git 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 Reviewed-by: Jeremy Allison Autobuild-User(master): Jeremy Allison Autobuild-Date(master): Fri Jun 17 17:12:07 UTC 2022 on sn-devel-184 --- 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/smbclient-smb3 b/selftest/knownfail.d/smbclient-smb3 index f6ca529c61d..119e93e479a 100644 --- a/selftest/knownfail.d/smbclient-smb3 +++ b/selftest/knownfail.d/smbclient-smb3 @@ -1,5 +1,4 @@ ^samba3.blackbox.smbclient_s3.SMB3.*.creating.a.bad.symlink.and.deleting.it -^samba3.blackbox.smbclient_s3.SMB3.*.deltree on MS-DFS share ^samba3.blackbox.acl_xattr.SMB3.nt_affects_posix ^samba3.blackbox.acl_xattr.SMB3.nt_affects_chown ^samba3.blackbox.acl_xattr.SMB3.nt_affects_chgrp diff --git a/source3/client/client.c b/source3/client/client.c index 2b93cd36704..651da5fbf7a 100644 --- a/source3/client/client.c +++ b/source3/client/client.c @@ -2439,20 +2439,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); } @@ -2561,14 +2578,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); }