]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3: smbd: Allow dfs_redirect() to return a TWRP token it got from a parsed pathname.
authorJeremy Allison <jra@samba.org>
Sat, 4 Dec 2021 00:14:08 +0000 (16:14 -0800)
committerRalph Boehme <slow@samba.org>
Sat, 11 Dec 2021 07:17:28 +0000 (07:17 +0000)
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>
source3/smbd/filename.c
source3/smbd/msdfs.c
source3/smbd/proto.h

index e10e3da10d16207f5d3ab0b0359e065c1fd0ebc2..2dab7f1b9b9ff93fedc45bf46af6b379fceb0897 100644 (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)) {
index 86ca79a994b3dd0aa25606ab68893d6f5c712b3b..0763659201647a832b35a277e86eb063e0e92ba4 100644 (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 */
index 239df9879ea6b54d09afd802f835ed8426c6c8b9..52d0390b86a70e374e7929635341cb1087013959 100644 (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;