From: Noel Power Date: Fri, 24 Jul 2020 13:50:57 +0000 (+0100) Subject: s3/utils: If dfs path is an ordinary path then really just return it X-Git-Tag: talloc-2.3.2~667 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=28719f3edc9dc3ba13c3cd5382b4fb04a30af260;p=thirdparty%2Fsamba.git s3/utils: If dfs path is an ordinary path then really just return it In cli_resolve_path if the share was a root dfs share then any self hosted dfs paths end up not being returned as is but being decorated with fileserver and share. This file path is not suitable for passing to cli_list so we adjust it here. Signed-off-by: Noel Power Reviewed-by: Jeremy Allison --- diff --git a/source3/utils/smbcacls.c b/source3/utils/smbcacls.c index b78f120b2eb..d2becb32948 100644 --- a/source3/utils/smbcacls.c +++ b/source3/utils/smbcacls.c @@ -60,6 +60,50 @@ struct cacl_callback_state { bool numeric; }; +/* + * if this dfs link is local to this share then we need to + * adjust targetpath. A local dfs link is prepended with + * '/$SERVER/$SHARE/path_from_args' The 'full' path is not + * suitable for passing to cli_list (and will fail) + */ +static NTSTATUS local_cli_resolve_path(TALLOC_CTX* ctx, + const char *mountpt, + const struct user_auth_info *dfs_auth_info, + struct cli_state *rootcli, + const char *path, + struct cli_state **targetcli, + char **pp_targetpath) +{ + size_t searchlen = 0; + char *search = NULL; + NTSTATUS status; + + status = cli_resolve_path(ctx, + mountpt, + dfs_auth_info, + rootcli, + path, + targetcli, + pp_targetpath); + if (!NT_STATUS_IS_OK(status)) { + return status; + } + + search = talloc_asprintf(ctx, "\\%s\\%s", + rootcli->server_domain, + rootcli->share); + if (search == NULL) { + return NT_STATUS_NO_MEMORY; + } + + searchlen = strlen(search); + + if (strncmp(*pp_targetpath, search, searchlen) == 0) { + *pp_targetpath += searchlen; + } + return status; +} + static NTSTATUS cli_lsa_lookup_domain_sid(struct cli_state *cli, struct dom_sid *sid) { @@ -1262,7 +1306,7 @@ static NTSTATUS cacl_set_cb(const char *mntpoint, struct file_info *f, } /* check for dfs */ - status = cli_resolve_path(dirctx, "", auth_info, cli, + status = local_cli_resolve_path(dirctx, "", auth_info, cli, mask2, &targetcli, &targetpath); if (!NT_STATUS_IS_OK(status)) { goto out; @@ -1771,7 +1815,7 @@ int main(int argc, char *argv[]) } } - status = cli_resolve_path(frame, + status = local_cli_resolve_path(frame, "", popt_get_cmdline_auth_info(), cli,