]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: use fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode()
authorRalph Boehme <slow@samba.org>
Wed, 11 May 2022 16:13:13 +0000 (18:13 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 9 Dec 2022 23:11:37 +0000 (23:11 +0000)
Pair-Programmed-With: Stefan Metzmacher <metze@samba.org>
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
source3/smbd/smb1_reply.c
source3/smbd/smb1_trans2.c
source3/smbd/smb2_getinfo.c
source3/smbd/smb2_query_directory.c

index 343b7ee2b4913ebed865019b9280d9c7c6dbb0e3..d53f5902da48acb1ec4389497f23071ce83ed475 100644 (file)
@@ -659,7 +659,6 @@ void reply_getatr(struct smb_request *req)
        const char *p;
        NTSTATUS status;
        TALLOC_CTX *ctx = talloc_tos();
-       bool ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
 
        START_PROFILE(SMBgetatr);
 
@@ -685,6 +684,8 @@ void reply_getatr(struct smb_request *req)
                struct files_struct *dirfsp = NULL;
                uint32_t ucf_flags = ucf_flags_from_smb_request(req);
                NTTIME twrp = 0;
+               bool ask_sharemode;
+
                if (ucf_flags & UCF_GMT_PATHNAME) {
                        extract_snapshot_token(fname, &twrp);
                }
@@ -716,6 +717,7 @@ void reply_getatr(struct smb_request *req)
                mode = fdos_mode(smb_fname->fsp);
                size = smb_fname->st.st_ex_size;
 
+               ask_sharemode = fsp_search_ask_sharemode(smb_fname->fsp);
                if (ask_sharemode) {
                        struct timespec write_time_ts;
                        struct file_id fileid;
@@ -1029,7 +1031,6 @@ void reply_search(struct smb_request *req)
        bool mask_contains_wcard = False;
        bool allow_long_path_components = (req->flags2 & FLAGS2_LONG_PATH_COMPONENTS) ? True : False;
        TALLOC_CTX *ctx = talloc_tos();
-       bool ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
        struct smbXsrv_connection *xconn = req->xconn;
        struct smbd_server_connection *sconn = req->sconn;
        files_struct *fsp = NULL;
@@ -1226,6 +1227,7 @@ void reply_search(struct smb_request *req)
                unsigned int i;
                size_t hdr_size = ((uint8_t *)smb_buf(req->outbuf) + 3 - req->outbuf);
                size_t available_space = xconn->smb1.sessions.max_send - hdr_size;
+               bool ask_sharemode;
 
                maxentries = MIN(maxentries, available_space/DIR_STRUCT_SIZE);
 
@@ -1235,6 +1237,8 @@ void reply_search(struct smb_request *req)
                        check_descend = True;
                }
 
+               ask_sharemode = fsp_search_ask_sharemode(fsp);
+
                for (i=numentries;(i<maxentries) && !finished;i++) {
                        finished = !get_dir_entry(ctx,
                                                  fsp->dptr,
index 37c5036fb9c2d1d013911bc7f7d9bab2f2e0407e..48dd66a31f500e5043f1be365a5c1b7fc07f3e65 100644 (file)
@@ -838,7 +838,7 @@ static void call_trans2findfirst(connection_struct *conn,
        int space_remaining;
        struct ea_list *ea_list = NULL;
        NTSTATUS ntstatus = NT_STATUS_OK;
-       bool ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
+       bool ask_sharemode;
        struct smbd_server_connection *sconn = req->sconn;
        uint32_t ucf_flags = ucf_flags_from_smb_request(req);
        bool backup_priv = false;
@@ -910,11 +910,6 @@ static void call_trans2findfirst(connection_struct *conn,
                        goto out;
        }
 
-       if (req->posix_pathnames) {
-               /* Always use filesystem for UNIX mtime query. */
-               ask_sharemode = false;
-       }
-
        if (req->posix_pathnames) {
                srvstr_get_path_posix(talloc_tos(),
                                params,
@@ -1101,6 +1096,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
        space_remaining = max_data_bytes;
        out_of_space = False;
 
+       ask_sharemode = fsp_search_ask_sharemode(fsp);
+
        for (i=0;(i<maxentries) && !finished && !out_of_space;i++) {
                bool got_exact_match = False;
 
@@ -1276,7 +1273,7 @@ static void call_trans2findnext(connection_struct *conn,
        int space_remaining;
        struct ea_list *ea_list = NULL;
        NTSTATUS ntstatus = NT_STATUS_OK;
-       bool ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
+       bool ask_sharemode;
        TALLOC_CTX *ctx = talloc_tos();
        struct smbd_server_connection *sconn = req->sconn;
        bool backup_priv = false;
@@ -1363,8 +1360,6 @@ resume_key = %d resume name = %s continue=%d level = %d\n",
                        break;
                case SMB_FIND_FILE_UNIX:
                case SMB_FIND_FILE_UNIX_INFO2:
-                       /* Always use filesystem for UNIX mtime query. */
-                       ask_sharemode = false;
                        if (!lp_smb1_unix_extensions()) {
                                reply_nterror(req, NT_STATUS_INVALID_LEVEL);
                                return;
@@ -1523,6 +1518,8 @@ total_data=%u (should be %u)\n", (unsigned int)total_data, (unsigned int)IVAL(pd
                finished = !dptr_SearchDir(fsp->dptr, resume_name, &current_pos, &st);
        } /* end if resume_name && !continue_bit */
 
+       ask_sharemode = fsp_search_ask_sharemode(fsp);
+
        for (i=0;(i<(int)maxentries) && !finished && !out_of_space ;i++) {
                bool got_exact_match = False;
 
@@ -2032,7 +2029,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                                return;
                        }
 
-                       if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+                       if (fsp_getinfo_ask_sharemode(fsp)) {
                                fileid = vfs_file_id_from_sbuf(
                                        conn, &smb_fname->st);
                                get_file_infos(fileid, fsp->name_hash,
@@ -2050,7 +2047,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                                reply_nterror(req, status);
                                return;
                        }
-                       if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+                       if (fsp_getinfo_ask_sharemode(fsp)) {
                                fileid = vfs_file_id_from_sbuf(
                                        conn, &smb_fname->st);
                                get_file_infos(fileid, fsp->name_hash,
@@ -2206,7 +2203,7 @@ static void call_trans2qfilepathinfo(connection_struct *conn,
                        return;
                }
 
-               if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+               if (fsp_getinfo_ask_sharemode(fsp)) {
                        fileid = vfs_file_id_from_sbuf(conn, &smb_fname->st);
                        get_file_infos(fileid, name_hash, &delete_pending,
                                       &write_time_ts);
index 4865565df1804279a9593ad963ddb4aacca751f6..9d2eaf4e1df2b4ac5e7cabd7112fb6fdff3c1357 100644 (file)
@@ -387,7 +387,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
                                return tevent_req_post(req, ev);
                        }
 
-                       if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+                       if (fsp_getinfo_ask_sharemode(fsp)) {
                                fileid = vfs_file_id_from_sbuf(
                                        conn, &fsp->fsp_name->st);
                                get_file_infos(fileid, fsp->name_hash,
@@ -407,7 +407,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
                                tevent_req_nterror(req, status);
                                return tevent_req_post(req, ev);
                        }
-                       if (lp_smbd_getinfo_ask_sharemode(SNUM(conn))) {
+                       if (fsp_getinfo_ask_sharemode(fsp)) {
                                fileid = vfs_file_id_from_sbuf(
                                        conn, &fsp->fsp_name->st);
                                get_file_infos(fileid, fsp->name_hash,
index bdf0c892c7446383b448551b3fb3cd5c33ba779a..2d58741738cc90bb37f8cd19b64ddb1a6242c3b4 100644 (file)
@@ -484,7 +484,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
         * handling in future.
         */
        if (state->info_level != SMB_FIND_FILE_NAMES_INFO) {
-               state->ask_sharemode = lp_smbd_search_ask_sharemode(SNUM(conn));
+               state->ask_sharemode = fsp_search_ask_sharemode(fsp);
 
                state->async_dosmode = lp_smbd_async_dosmode(SNUM(conn));
        }