From: Noel Power Date: Fri, 24 Jul 2020 14:32:11 +0000 (+0100) Subject: s3/utils: restore client share connection after call to sec_desc_parse X-Git-Tag: talloc-2.3.2~666 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5b04affc73f75d6b3e85eafb3fed0fe29c9c03db;p=thirdparty%2Fsamba.git 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 --- 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);