]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: split out smb_check_file_disposition_info()
authorRalph Boehme <slow@samba.org>
Fri, 11 Oct 2024 13:30:46 +0000 (15:30 +0200)
committerRalph Boehme <slow@samba.org>
Tue, 5 Nov 2024 14:39:30 +0000 (14:39 +0000)
BUG: https://bugzilla.samba.org/show_bug.cgi?id=13458
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15608

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source3/smbd/proto.h
source3/smbd/smb2_trans2.c

index 8ff937a8e4fa7c8189cc571827618f4f8246cfd9..8437b4d140e8792db1540da61b81fed539b72fb7 100644 (file)
@@ -1043,6 +1043,10 @@ char *store_file_unix_basic_info2(connection_struct *conn,
                                  char *pdata,
                                  files_struct *fsp,
                                  const SMB_STRUCT_STAT *psbuf);
+NTSTATUS smb_check_file_disposition_info(struct files_struct *fsp,
+                                        const char *data,
+                                        int total_data,
+                                        bool *_delete_on_close);
 NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
                                       const char *pdata,
                                       int total_data,
index 885776a72beaa9d0d968f68c6e7dd7555e38d203..7e5dd9efe1d7d0320eaf865daa398769e226c30b 100644 (file)
@@ -4170,15 +4170,14 @@ static NTSTATUS smb_set_file_full_ea_info(connection_struct *conn,
  Deal with SMB_SET_FILE_DISPOSITION_INFO.
 ****************************************************************************/
 
-NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
-                                      const char *pdata,
-                                      int total_data,
-                                      files_struct *fsp,
-                                      struct smb_filename *smb_fname)
+NTSTATUS smb_check_file_disposition_info(struct files_struct *fsp,
+                                        const char *data,
+                                        int total_data,
+                                        bool *_delete_on_close)
 {
-       NTSTATUS status = NT_STATUS_OK;
        bool delete_on_close;
        uint32_t dosmode = 0;
+       NTSTATUS status;
 
        if (total_data < 1) {
                return NT_STATUS_INVALID_PARAMETER;
@@ -4188,20 +4187,43 @@ NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
                return NT_STATUS_INVALID_HANDLE;
        }
 
-       delete_on_close = (CVAL(pdata,0) ? True : False);
+       delete_on_close = (PULL_LE_U8(data, 0) ? true : false);
+       *_delete_on_close = delete_on_close;
+
        dosmode = fdos_mode(fsp);
 
-       DEBUG(10,("smb_set_file_disposition_info: file %s, dosmode = %u, "
-               "delete_on_close = %u\n",
-               smb_fname_str_dbg(smb_fname),
-               (unsigned int)dosmode,
-               (unsigned int)delete_on_close ));
+       DBG_DEBUG("file [%s] dosmode = %u, delete_on_close = %s\n",
+                 fsp_str_dbg(fsp),
+                 (unsigned int)dosmode,
+                 delete_on_close ? "yes" : "no");
 
-       if (delete_on_close) {
-               status = can_set_delete_on_close(fsp, dosmode);
-               if (!NT_STATUS_IS_OK(status)) {
-                       return status;
-               }
+       if (!delete_on_close) {
+               return NT_STATUS_OK;
+       }
+
+       status = can_set_delete_on_close(fsp, dosmode);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
+       }
+
+       return NT_STATUS_OK;
+}
+
+NTSTATUS smb_set_file_disposition_info(connection_struct *conn,
+                                      const char *pdata,
+                                      int total_data,
+                                      files_struct *fsp,
+                                      struct smb_filename *smb_fname)
+{
+       NTSTATUS status;
+       bool delete_on_close;
+
+       status = smb_check_file_disposition_info(fsp,
+                                                pdata,
+                                                total_data,
+                                                &delete_on_close);
+       if (!NT_STATUS_IS_OK(status)) {
+               return status;
        }
 
        /* The set is across all open files on this dev/inode pair. */