]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
smbd: convert all fsp->fh->private_options to fsp_flags
authorRalph Boehme <slow@samba.org>
Fri, 28 Mar 2025 12:22:22 +0000 (13:22 +0100)
committerVolker Lendecke <vl@samba.org>
Wed, 9 Apr 2025 14:39:26 +0000 (14:39 +0000)
Use fsp_apply_private_ntcreatex_flags() to store the private_flags as fsp_flags
and convert all users to check the fsp_flags.

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
Autobuild-User(master): Volker Lendecke <vl@samba.org>
Autobuild-Date(master): Wed Apr  9 14:39:26 UTC 2025 on atb-devel-224

source3/locking/share_mode_lock.c
source3/smbd/fd_handle.c
source3/smbd/fd_handle.h
source3/smbd/open.c
source3/smbd/smb1_utils.c

index 2baf12c7e69ca16de5b4581902d26ed23e787884..ce5ef40e370a15bc152fe64eb667bcb72b5ab8a1 100644 (file)
@@ -3516,18 +3516,17 @@ NTSTATUS _share_mode_entry_prepare_unlock(
 uint16_t fsp_get_share_entry_flags(const struct files_struct *fsp)
 {
        uint16_t flags = 0;
-       uint32_t private_options = fh_get_private_options(fsp->fh);
 
        if (fsp->fsp_flags.posix_open) {
                flags |= SHARE_ENTRY_FLAG_POSIX_OPEN;
        }
-       if (private_options & NTCREATEX_FLAG_STREAM_BASEOPEN) {
+       if (fsp->fsp_flags.ntcreatex_stream_baseopen) {
                flags |= SHARE_ENTRY_FLAG_STREAM_BASEOPEN;
        }
-       if (private_options & NTCREATEX_FLAG_DENY_DOS) {
+       if (fsp->fsp_flags.ntcreatex_deny_dos) {
                flags |= SHARE_ENTRY_FLAG_DENY_DOS;
        }
-       if (private_options & NTCREATEX_FLAG_DENY_FCB) {
+       if (fsp->fsp_flags.ntcreatex_deny_fcb) {
                flags |= SHARE_ENTRY_FLAG_DENY_FCB;
        }
        return flags;
index eb7fa55e22a81b41c2c1730851412ef35757cd20..b0190681f7a3efed9b4e9019e5b227f6864de0b0 100644 (file)
@@ -25,12 +25,6 @@ struct fd_handle {
        int fd;
        uint64_t position_information;
        off_t pos;
-       /*
-        * NT Create options, but we only look at
-        * NTCREATEX_FLAG_DENY_DOS and
-        * NTCREATEX_FLAG_DENY_FCB.
-        */
-       uint32_t private_options;
        uint64_t gen_id;
 };
 
@@ -85,16 +79,6 @@ void fh_set_pos(struct fd_handle *fh, off_t pos)
        fh->pos = pos;
 }
 
-uint32_t fh_get_private_options(struct fd_handle *fh)
-{
-       return fh->private_options;
-}
-
-void fh_set_private_options(struct fd_handle *fh, uint32_t private_options)
-{
-       fh->private_options = private_options;
-}
-
 uint64_t fh_get_gen_id(struct fd_handle *fh)
 {
        return fh->gen_id;
index dc0e5e43940d11ba2e06199a1697902169db80e7..4d2e5093dc4da6e545d7f29e628fbd3c69a798a7 100644 (file)
@@ -36,9 +36,6 @@ void fh_set_position_information(struct fd_handle *fh, uint64_t posinfo);
 off_t fh_get_pos(struct fd_handle *fh);
 void fh_set_pos(struct fd_handle *fh, off_t pos);
 
-uint32_t fh_get_private_options(struct fd_handle *fh);
-void fh_set_private_options(struct fd_handle *fh, uint32_t private_options);
-
 uint64_t fh_get_gen_id(struct fd_handle *fh);
 void fh_set_gen_id(struct fd_handle *fh, uint64_t gen_id);
 
index 381f4eb190bb76fcd04bc97e5fedf28af0f69fc4..df6606f021529d0e8b8c48c58a611e8d9b6d9584 100644 (file)
@@ -3917,7 +3917,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
                 */
                fsp->file_id = vfs_file_id_from_sbuf(conn, &smb_fname->st);
        }
-       fh_set_private_options(fsp->fh, private_flags);
+       fsp_apply_private_ntcreatex_flags(fsp, private_flags);
        fsp->access_mask = open_access_mask; /* We change this to the
                                              * requested access_mask after
                                              * the open is done. */
@@ -5069,7 +5069,7 @@ static NTSTATUS open_directory(connection_struct *conn,
        fsp->fsp_flags.can_read = false;
        fsp->fsp_flags.can_write = false;
 
-       fh_set_private_options(fsp->fh, 0);
+       fsp_apply_private_ntcreatex_flags(fsp, 0);
        /*
         * According to Samba4, SEC_FILE_READ_ATTRIBUTE is always granted,
         */
index d5b6c9ba4526c636d7b5d685060d322c565dc8c4..afd9b50c12c5a22a9ae809ba336496fbcb16883a 100644 (file)
@@ -57,21 +57,22 @@ struct files_struct *fcb_or_dos_open(
 
                DBG_DEBUG("Checking file %s, fd = %d, vuid = %"PRIu64", "
                          "file_pid = %"PRIu16", "
-                         "private_options = 0x%"PRIx32", "
+                         "ntcreatex_deny_dos: %s, "
+                         "ntcreatex_deny_fcb: %s, "
                          "access_mask = 0x%"PRIx32"\n",
                          fsp_str_dbg(fsp),
                          fsp_get_pathref_fd(fsp),
                          fsp->vuid,
                          fsp->file_pid,
-                         fh_get_private_options(fsp->fh),
+                         fsp->fsp_flags.ntcreatex_deny_dos ? "yes":"no",
+                         fsp->fsp_flags.ntcreatex_deny_fcb ? "yes":"no",
                          fsp->access_mask);
 
                if (fsp_get_pathref_fd(fsp) != -1 &&
                    fsp->vuid == req->vuid &&
                    fsp->file_pid == req->smbpid &&
-                   (fh_get_private_options(fsp->fh) &
-                    (NTCREATEX_FLAG_DENY_DOS |
-                     NTCREATEX_FLAG_DENY_FCB)) &&
+                   (fsp->fsp_flags.ntcreatex_deny_dos |
+                    fsp->fsp_flags.ntcreatex_deny_fcb) &&
                    (fsp->access_mask & FILE_WRITE_DATA) &&
                    strequal(fsp->fsp_name->base_name, smb_fname->base_name) &&
                    strequal(fsp->fsp_name->stream_name,
@@ -87,7 +88,7 @@ struct files_struct *fcb_or_dos_open(
 
        /* quite an insane set of semantics ... */
        if (is_executable(smb_fname->base_name) &&
-           (fh_get_private_options(fsp->fh) & NTCREATEX_FLAG_DENY_DOS)) {
+           fsp->fsp_flags.ntcreatex_deny_dos) {
                DBG_DEBUG("file fail due to is_executable.\n");
                return NULL;
        }