1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

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 <noel.power@suse.com>
Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
Noel Power 2020-07-24 15:32:11 +01:00 committed by Jeremy Allison
parent 28719f3edc
commit 5b04affc73

View File

@ -1417,6 +1417,7 @@ static int inheritance_cacl_set(char *filename,
bool isdirectory = false; bool isdirectory = false;
uint16_t attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM uint16_t attribute = FILE_ATTRIBUTE_DIRECTORY | FILE_ATTRIBUTE_SYSTEM
| FILE_ATTRIBUTE_HIDDEN; | FILE_ATTRIBUTE_HIDDEN;
char *save_share = NULL;
ctx = talloc_init("inherit_set"); ctx = talloc_init("inherit_set");
if (ctx == NULL) { if (ctx == NULL) {
d_printf("out of memory\n"); 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 * prepare for automatic propagation of the acl passed on the
* cmdline. * cmdline.
*/ */
save_share = talloc_strdup(ctx, cli->share);
if (save_share == NULL) {
result = EXIT_FAILED;
goto out;
}
ntstatus = prepare_inheritance_propagation(ctx, filename, ntstatus = prepare_inheritance_propagation(ctx, filename,
cbstate); cbstate);
if (!NT_STATUS_IS_OK(ntstatus)) { if (!NT_STATUS_IS_OK(ntstatus)) {
@ -1483,6 +1490,26 @@ static int inheritance_cacl_set(char *filename,
result = EXIT_FAILED; result = EXIT_FAILED;
goto out; 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, result = cacl_set_from_sd(cli, filename, cbstate->aclsd,
cbstate->mode, cbstate->numeric); cbstate->mode, cbstate->numeric);