1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-09 08:58:35 +03:00

s3: smbd: Allow dfs_redirect() to return a TWRP token it got from a parsed pathname.

This one is subtle. If an SMB1 request has both a DFS path and a @GMT token,
the unix_convert() inside the DFS path processing will remove the @GMT
token, not allowing the subsequent unix_convert() inside filename_convert()
to see it. By returning it from dfs_redirect() we can ensure it's correctly
added to the smb_filename returned from filename_convert().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
This commit is contained in:
Jeremy Allison 2021-12-03 16:14:08 -08:00 committed by Ralph Boehme
parent a568e92e51
commit addbf4cc3b
3 changed files with 12 additions and 3 deletions

View File

@ -1871,6 +1871,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
char *last_slash = NULL;
char *orig_lcomp;
char *fname = NULL;
NTTIME twrp = 0;
NTSTATUS status;
if (ucf_flags & UCF_DFS_PATHNAME) {
@ -1879,6 +1880,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
filename_in,
ucf_flags,
!conn->sconn->using_smb2,
&twrp,
&fname);
if (!NT_STATUS_IS_OK(status)) {
DBG_DEBUG("dfs_redirect "
@ -1907,7 +1909,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
filename_in,
NULL,
NULL,
0,
twrp,
0);
if (smb_fname == NULL) {
TALLOC_FREE(fname);
@ -1915,7 +1917,7 @@ char *get_original_lcomp(TALLOC_CTX *ctx,
}
status = canonicalize_snapshot_path(smb_fname,
ucf_flags,
0);
twrp);
if (!NT_STATUS_IS_OK(status)) {
TALLOC_FREE(fname);
TALLOC_FREE(smb_fname);
@ -1975,10 +1977,12 @@ NTSTATUS filename_convert(TALLOC_CTX *ctx,
if (ucf_flags & UCF_DFS_PATHNAME) {
char *fname = NULL;
NTTIME dfs_twrp = 0;
status = dfs_redirect(ctx, conn,
name_in,
ucf_flags,
!conn->sconn->using_smb2,
&dfs_twrp,
&fname);
if (!NT_STATUS_IS_OK(status)) {
DBG_DEBUG("dfs_redirect "
@ -1989,6 +1993,9 @@ NTSTATUS filename_convert(TALLOC_CTX *ctx,
}
name_in = fname;
ucf_flags &= ~UCF_DFS_PATHNAME;
if (twrp == 0 && dfs_twrp != 0) {
twrp = dfs_twrp;
}
}
if (is_fake_file_path(name_in)) {

View File

@ -901,6 +901,7 @@ NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
const char *path_in,
uint32_t ucf_flags,
bool allow_broken_path,
NTTIME *_twrp,
char **pp_path_out)
{
const struct loadparm_substitution *lp_sub =
@ -970,7 +971,7 @@ NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
path_in,
pdp,
ucf_flags,
NULL, /* twrp. */
_twrp, /* twrp. */
NULL, /* int *consumedcntp */
NULL, /* struct referral **ppreflist */
NULL); /* size_t *preferral_count */

View File

@ -563,6 +563,7 @@ NTSTATUS dfs_redirect(TALLOC_CTX *ctx,
const char *name_in,
uint32_t ucf_flags,
bool allow_broken_path,
NTTIME *twrp,
char **pp_name_out);
struct connection_struct;
struct smb_filename;