From: Ralph Boehme Date: Wed, 11 May 2022 16:13:13 +0000 (+0200) Subject: smbd: use fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode() X-Git-Tag: talloc-2.4.0~382 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=f0e0fc17d3a455b7c5c5170b582d2d8ff53670bb;p=thirdparty%2Fsamba.git smbd: use fsp_search_ask_sharemode() and fsp_getinfo_ask_sharemode() Pair-Programmed-With: Stefan Metzmacher Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison --- diff --git a/source3/smbd/smb1_reply.c b/source3/smbd/smb1_reply.c index 343b7ee2b49..d53f5902da4 100644 --- a/source3/smbd/smb1_reply.c +++ b/source3/smbd/smb1_reply.c @@ -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;(idptr, diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index 37c5036fb9c..48dd66a31f5 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -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;(isconn; 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, ¤t_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); diff --git a/source3/smbd/smb2_getinfo.c b/source3/smbd/smb2_getinfo.c index 4865565df18..9d2eaf4e1df 100644 --- a/source3/smbd/smb2_getinfo.c +++ b/source3/smbd/smb2_getinfo.c @@ -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, diff --git a/source3/smbd/smb2_query_directory.c b/source3/smbd/smb2_query_directory.c index bdf0c892c74..2d58741738c 100644 --- a/source3/smbd/smb2_query_directory.c +++ b/source3/smbd/smb2_query_directory.c @@ -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)); }