]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: Move handling smb_set_posix_lock() to smb1_trans2.c
authorVolker Lendecke <vl@samba.org>
Thu, 29 Dec 2022 09:59:45 +0000 (10:59 +0100)
committerRalph Boehme <slow@samba.org>
Wed, 4 Jan 2023 08:54:32 +0000 (08:54 +0000)
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 <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/smbd/smb1_trans2.c
source3/smbd/smb1_trans2.h
source3/smbd/smb2_trans2.c

index 8301ffbfba029962430a1262faf84d5a49405900..4a56e9f240786afe094abb468ffb7398813f69dd 100644 (file)
@@ -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,
index d624f19eaeca8734744fd50ae53fa9df285e5276..4b8b4b10289b25350de62a584f0ee917552917a9 100644 (file)
    along with this program.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-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);
index d4a7125460520a1d4591489bb9c89f1b4ce9471e..62676b376e5893f98377f3cb8c19866f3ed2d7fb 100644 (file)
@@ -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;
        }