s3: smbd: Remove the ucf_flags parameter from extract_snapshot_token().
authorJeremy Allison <jra@samba.org>
Thu, 4 Aug 2022 17:02:15 +0000 (10:02 -0700)
committerVolker Lendecke <vl@samba.org>
Fri, 5 Aug 2022 09:24:30 +0000 (09:24 +0000)
Now we always call check_path_syntaxXXX(), even on DFS names
we no longer need this. It was a BAD change, and I should feel BAD :-).

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
source3/smbd/filename.c
source3/smbd/proto.h
source3/smbd/smb1_nttrans.c
source3/smbd/smb1_reply.c
source3/smbd/smb1_trans2.c
source3/smbd/smb2_trans2.c

index d53046bf394f7ac370cbeeab4a36828c9b9e47eb..7380131a274942f2561c610cd1349ee6138f954d 100644 (file)
@@ -300,28 +300,14 @@ static bool find_snapshot_token(
        return true;
 }
 
-bool extract_snapshot_token(char *fname, uint32_t ucf_flags, NTTIME *twrp)
+bool extract_snapshot_token(char *fname, NTTIME *twrp)
 {
        const char *start = NULL;
        const char *next = NULL;
        size_t remaining;
        bool found;
-       bool posix_path = (ucf_flags & UCF_POSIX_PATHNAMES);
-       bool msdfs_path = (ucf_flags & UCF_DFS_PATHNAME);
 
-       if (msdfs_path && !posix_path) {
-               /*
-                * A raw (non-POSIX) MSDFS path looks like \server\share\path.
-                * find_snapshot_token only looks for '/' separators.
-                * Convert the separator characters in place.
-                */
-               string_replace(fname, '\\', '/');
-       }
        found = find_snapshot_token(fname, &start, &next, twrp);
-       if (msdfs_path && !posix_path) {
-               /* Put the original separators back. */
-               string_replace(fname, '/', '\\');
-       }
        if (!found) {
                return false;
        }
@@ -360,7 +346,7 @@ NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
                return NT_STATUS_OK;
        }
 
-       found = extract_snapshot_token(smb_fname->base_name, ucf_flags, &twrp);
+       found = extract_snapshot_token(smb_fname->base_name, &twrp);
        if (!found) {
                return NT_STATUS_OK;
        }
@@ -1941,7 +1927,7 @@ NTSTATUS filename_convert_smb1_search_path(TALLOC_CTX *ctx,
        DBG_DEBUG("name_in: %s\n", name_in);
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(name_in, ucf_flags, &twrp);
+               extract_snapshot_token(name_in, &twrp);
                ucf_flags &= ~UCF_GMT_PATHNAME;
        }
 
index 7d5b3f61bbc9801ea68bb26460a64ed50d2af854..daef19f13f7da7f7bfcb98e18c3f0fcaf54b9463 100644 (file)
@@ -356,7 +356,7 @@ NTSTATUS unix_convert(TALLOC_CTX *ctx,
                      NTTIME twrp,
                      struct smb_filename **smb_fname,
                      uint32_t ucf_flags);
-bool extract_snapshot_token(char *fname, uint32_t ucf_flags, NTTIME *twrp);
+bool extract_snapshot_token(char *fname, NTTIME *twrp);
 NTSTATUS canonicalize_snapshot_path(struct smb_filename *smb_fname,
                                    uint32_t ucf_flags,
                                    NTTIME twrp);
index 05f341ae50526fe00e787ef3d3ef0aa70e88ba5e..4a0cfcc113362d930815fd7df7aa96a7b226549b 100644 (file)
@@ -626,7 +626,7 @@ void reply_ntcreate_and_X(struct smb_request *req)
 
        ucf_flags = filename_create_ucf_flags(req, create_disposition);
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(fname, ucf_flags, &twrp);
+               extract_snapshot_token(fname, &twrp);
        }
        status = filename_convert_dirfsp(
                ctx, conn, fname, ucf_flags, twrp, &dirfsp, &smb_fname);
@@ -1081,7 +1081,7 @@ static void call_nt_transact_create(connection_struct *conn,
 
        ucf_flags = filename_create_ucf_flags(req, create_disposition);
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(fname, ucf_flags, &twrp);
+               extract_snapshot_token(fname, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -1468,7 +1468,7 @@ void reply_ntrename(struct smb_request *req)
        }
 
        if (ucf_flags_src & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(oldname, ucf_flags_src, &src_twrp);
+               extract_snapshot_token(oldname, &src_twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -1510,7 +1510,6 @@ void reply_ntrename(struct smb_request *req)
        } else {
                if (ucf_flags_dst & UCF_GMT_PATHNAME) {
                        extract_snapshot_token(newname,
-                                              ucf_flags_dst,
                                               &dst_twrp);
                }
                status = filename_convert_dirfsp(ctx,
index 79addb4120d79dac323f1cea5622bab0a21a6c77..343b7ee2b4913ebed865019b9280d9c7c6dbb0e3 100644 (file)
@@ -581,7 +581,7 @@ void reply_checkpath(struct smb_request *req)
        DEBUG(3,("reply_checkpath %s mode=%d\n", name, (int)SVAL(req->vwv+0, 0)));
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(name, ucf_flags, &twrp);
+               extract_snapshot_token(name, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -686,7 +686,7 @@ void reply_getatr(struct smb_request *req)
                uint32_t ucf_flags = ucf_flags_from_smb_request(req);
                NTTIME twrp = 0;
                if (ucf_flags & UCF_GMT_PATHNAME) {
-                       extract_snapshot_token(fname, ucf_flags, &twrp);
+                       extract_snapshot_token(fname, &twrp);
                }
                status = filename_convert_dirfsp(ctx,
                                                 conn,
@@ -794,7 +794,7 @@ void reply_setatr(struct smb_request *req)
        }
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(fname, ucf_flags, &twrp);
+               extract_snapshot_token(fname, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -1470,7 +1470,7 @@ void reply_open(struct smb_request *req)
        ucf_flags = filename_create_ucf_flags(req, create_disposition);
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(fname, ucf_flags, &twrp);
+               extract_snapshot_token(fname, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -1666,7 +1666,7 @@ void reply_open_and_X(struct smb_request *req)
        ucf_flags = filename_create_ucf_flags(req, create_disposition);
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(fname, ucf_flags, &twrp);
+               extract_snapshot_token(fname, &twrp);
        }
 
        status = filename_convert_dirfsp(ctx,
@@ -2098,7 +2098,7 @@ void reply_mknew(struct smb_request *req)
 
        ucf_flags = filename_create_ucf_flags(req, create_disposition);
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(fname, ucf_flags, &twrp);
+               extract_snapshot_token(fname, &twrp);
        }
 
        status = filename_convert_dirfsp(ctx,
@@ -2248,7 +2248,7 @@ void reply_ctemp(struct smb_request *req)
 
                ucf_flags = filename_create_ucf_flags(req, FILE_CREATE);
                if (ucf_flags & UCF_GMT_PATHNAME) {
-                       extract_snapshot_token(fname, ucf_flags, &twrp);
+                       extract_snapshot_token(fname, &twrp);
                }
                status = filename_convert_dirfsp(ctx,
                                                 conn,
@@ -2395,7 +2395,7 @@ void reply_unlink(struct smb_request *req)
        }
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(name, ucf_flags, &twrp);
+               extract_snapshot_token(name, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -5835,7 +5835,7 @@ void reply_mkdir(struct smb_request *req)
 
        ucf_flags = filename_create_ucf_flags(req, FILE_CREATE);
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(directory, ucf_flags, &twrp);
+               extract_snapshot_token(directory, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -5911,7 +5911,7 @@ void reply_rmdir(struct smb_request *req)
        }
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(directory, ucf_flags, &twrp);
+               extract_snapshot_token(directory, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -6056,7 +6056,7 @@ void reply_mv(struct smb_request *req)
         }
 
        if (src_ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(name, src_ucf_flags, &src_twrp);
+               extract_snapshot_token(name, &src_twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -6077,7 +6077,7 @@ void reply_mv(struct smb_request *req)
        }
 
        if (dst_ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(newname, dst_ucf_flags, &dst_twrp);
+               extract_snapshot_token(newname, &dst_twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
index a158456df491d4c949c8ac6a362698fea9d3fc78..4b3c7815c031fa11b8506c7218434ebfa9580408 100644 (file)
@@ -586,7 +586,7 @@ static void call_trans2open(connection_struct *conn,
                (unsigned int)open_ofun, open_size));
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(fname, ucf_flags, &twrp);
+               extract_snapshot_token(fname, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -2111,7 +2111,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                }
 
                if (ucf_flags & UCF_GMT_PATHNAME) {
-                       extract_snapshot_token(fname, ucf_flags, &twrp);
+                       extract_snapshot_token(fname, &twrp);
                }
                status = filename_convert_dirfsp(req,
                                                 conn,
@@ -2510,7 +2510,7 @@ static void call_trans2setfilepathinfo(connection_struct *conn,
                }
 
                if (ucf_flags & UCF_GMT_PATHNAME) {
-                       extract_snapshot_token(fname, ucf_flags, &twrp);
+                       extract_snapshot_token(fname, &twrp);
                }
                status = filename_convert_dirfsp(req,
                                                 conn,
@@ -2687,7 +2687,7 @@ static void call_trans2mkdir(connection_struct *conn, struct smb_request *req,
        DEBUG(3,("call_trans2mkdir : name = %s\n", directory));
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(directory, ucf_flags, &twrp);
+               extract_snapshot_token(directory, &twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
index 5834f2b146744d6ebb5ce544757e5bb40a483517..d0f30a782bf9eab3b18f23dc0d618fb4f8562406 100644 (file)
@@ -4914,7 +4914,7 @@ static NTSTATUS smb_set_file_unix_hlink(connection_struct *conn,
                smb_fname_str_dbg(smb_fname_new), oldname));
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(oldname, ucf_flags, &old_twrp);
+               extract_snapshot_token(oldname, &old_twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -5014,7 +5014,7 @@ static NTSTATUS smb2_file_rename_information(connection_struct *conn,
                }
        } else {
                if (ucf_flags & UCF_GMT_PATHNAME) {
-                       extract_snapshot_token(newname, ucf_flags, &dst_twrp);
+                       extract_snapshot_token(newname, &dst_twrp);
                }
                status = filename_convert_dirfsp(ctx,
                                                 conn,
@@ -5118,7 +5118,7 @@ static NTSTATUS smb_file_link_information(connection_struct *conn,
                                newname));
 
        if (ucf_flags & UCF_GMT_PATHNAME) {
-               extract_snapshot_token(newname, ucf_flags, &dst_twrp);
+               extract_snapshot_token(newname, &dst_twrp);
        }
        status = filename_convert_dirfsp(ctx,
                                         conn,
@@ -5290,7 +5290,7 @@ static NTSTATUS smb_file_rename_information(connection_struct *conn,
                }
 
                if (ucf_flags & UCF_GMT_PATHNAME) {
-                       extract_snapshot_token(base_name, ucf_flags, &dst_twrp);
+                       extract_snapshot_token(base_name, &dst_twrp);
                }
                status = filename_convert_dirfsp(ctx,
                                         conn,