From 5b04affc73f75d6b3e85eafb3fed0fe29c9c03db Mon Sep 17 00:00:00 2001 From: Noel Power Date: Fri, 24 Jul 2020 15:32:11 +0100 Subject: [PATCH] s3/utils: restore client share connection after call to sec_desc_parse This normally isn't a problem *except* for when the share is a dfs root (which results in cli_resolve_patch creating an incorrect path) Signed-off-by: Noel Power Reviewed-by: Jeremy Allison --- source3/utils/smbcacls.c | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index d2becb32948..34c552b4490 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -1417,6 +1417,7 @@ static int inheritance_cacl_set(char *filename, bool isdirectory = false; uint16_t attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM | FILE_ATTRIBUTE_HIDDEN; + char *save_share = NULL; ctx = talloc_init("inherit_set"); if (ctx == NULL) { d_printf("out of memory\n"); @@ -1475,6 +1476,12 @@ static int inheritance_cacl_set(char *filename, * prepare for automatic propagation of the acl passed on the * cmdline. */ + save_share = talloc_strdup(ctx, cli->share); + if (save_share == NULL) { + result = EXIT_FAILED; + goto out; + } + ntstatus = prepare_inheritance_propagation(ctx, filename, cbstate); if (!NT_STATUS_IS_OK(ntstatus)) { @@ -1483,6 +1490,26 @@ static int inheritance_cacl_set(char *filename, result = EXIT_FAILED; goto out; } + + /* + * sec_desc_parse ends up calling a bunch of functions one of which + * connects to IPC$ (which overwrites cli->share) + * we need a new connection to the share here. + * Note: This only is an issue when the share is a msdfs root + * because the presence of cli->share gets expanded out + * later on by cli_resolve_path (when it is constructing a path) + */ + ntstatus = cli_tree_connect_creds(cli, + save_share, + "?????", + get_cmdline_auth_info_creds(cbstate->auth_info)); + + if (!NT_STATUS_IS_OK(ntstatus)) { + d_printf("error: %s processing %s\n", + nt_errstr(ntstatus), filename); + result = EXIT_FAILED; + goto out; + } result = cacl_set_from_sd(cli, filename, cbstate->aclsd, cbstate->mode, cbstate->numeric); -- 2.34.1