From: Volker Lendecke Date: Thu, 29 Dec 2022 09:59:45 +0000 (+0100) Subject: smbd: Move handling smb_set_posix_lock() to smb1_trans2.c X-Git-Tag: talloc-2.4.0~96 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=765f9bcf6669b20bd98b146b3a5f39ba160ac9ea;p=thirdparty%2Fsamba.git smbd: Move handling smb_set_posix_lock() to smb1_trans2.c Most of this is direct cut&paste without reformatting. Don't pass SMB_SET_POSIX_LOCK through smbd_do_setfilepathinfo(), directly handle it in call_trans2setfileinfo() where we know we have a fsp. Signed-off-by: Volker Lendecke Reviewed-by: Ralph Boehme --- diff --git a/source3/smbd/smb1_trans2.c b/source3/smbd/smb1_trans2.c index 8301ffbfba0..4a56e9f2407 100644 --- a/source3/smbd/smb1_trans2.c +++ b/source3/smbd/smb1_trans2.c @@ -280,11 +280,11 @@ static void send_trans2_replies(connection_struct *conn, static void smb_set_posix_lock_done(struct tevent_req *subreq); -NTSTATUS smb_set_posix_lock(connection_struct *conn, - struct smb_request *req, - const char *pdata, - int total_data, - files_struct *fsp) +static NTSTATUS smb_set_posix_lock(connection_struct *conn, + struct smb_request *req, + const char *pdata, + int total_data, + files_struct *fsp) { struct tevent_req *subreq = NULL; struct smbd_lock_element *lck = NULL; @@ -296,6 +296,10 @@ NTSTATUS smb_set_posix_lock(connection_struct *conn, NTSTATUS status = NT_STATUS_OK; + if (!CAN_WRITE(conn)) { + return NT_STATUS_DOS(ERRSRV, ERRaccess); + } + if (fsp == NULL || fsp->fsp_flags.is_pathref || fsp_get_io_fd(fsp) == -1) @@ -3405,6 +3409,7 @@ static void call_trans2setfileinfo( struct files_struct *fsp = NULL; char *params = *pparams; int data_return_size = 0; + bool info_level_handled; NTSTATUS status; int ret; @@ -3497,6 +3502,32 @@ static void call_trans2setfileinfo( } } + info_level_handled = true; /* Untouched in switch cases below */ + + switch (info_level) { + + default: + info_level_handled = false; + break; + + case SMB_SET_POSIX_LOCK: + status = smb_set_posix_lock( + conn, req, *ppdata, total_data, fsp); + break; + } + + if (info_level_handled) { + handle_trans2setfilepathinfo_result( + conn, + req, + info_level, + status, + *ppdata, + data_return_size, + max_data_bytes); + return; + } + status = smbd_do_setfilepathinfo( conn, req, diff --git a/source3/smbd/smb1_trans2.h b/source3/smbd/smb1_trans2.h index d624f19eaec..4b8b4b10289 100644 --- a/source3/smbd/smb1_trans2.h +++ b/source3/smbd/smb1_trans2.h @@ -23,10 +23,5 @@ along with this program. If not, see . */ -NTSTATUS smb_set_posix_lock(connection_struct *conn, - struct smb_request *req, - const char *pdata, - int total_data, - files_struct *fsp); void reply_trans2(struct smb_request *req); void reply_transs2(struct smb_request *req); diff --git a/source3/smbd/smb2_trans2.c b/source3/smbd/smb2_trans2.c index d4a71254605..62676b376e5 100644 --- a/source3/smbd/smb2_trans2.c +++ b/source3/smbd/smb2_trans2.c @@ -6231,18 +6231,6 @@ static NTSTATUS smbd_do_posix_setfilepathinfo(struct connection_struct *conn, } #endif -#if defined(WITH_SMB1SERVER) - case SMB_SET_POSIX_LOCK: - { - if (fsp == NULL) { - return NT_STATUS_INVALID_LEVEL; - } - status = smb_set_posix_lock(conn, req, - pdata, total_data, fsp); - break; - } -#endif - default: return NT_STATUS_INVALID_LEVEL; }