From: Ralph Boehme Date: Fri, 28 Mar 2025 12:22:22 +0000 (+0100) Subject: smbd: convert all fsp->fh->private_options to fsp_flags X-Git-Tag: tevent-0.17.0~353 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=7089ece58ef8d78e1556cb6f3eec3a78d7051c5f;p=thirdparty%2Fsamba.git smbd: convert all fsp->fh->private_options to fsp_flags 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 Reviewed-by: Volker Lendecke Autobuild-User(master): Volker Lendecke Autobuild-Date(master): Wed Apr 9 14:39:26 UTC 2025 on atb-devel-224 --- diff --git a/source3/locking/share_mode_lock.c b/source3/locking/share_mode_lock.c index 2baf12c7e69..ce5ef40e370 100644 --- a/source3/locking/share_mode_lock.c +++ b/source3/locking/share_mode_lock.c @@ -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; diff --git a/source3/smbd/fd_handle.c b/source3/smbd/fd_handle.c index eb7fa55e22a..b0190681f7a 100644 --- a/source3/smbd/fd_handle.c +++ b/source3/smbd/fd_handle.c @@ -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; diff --git a/source3/smbd/fd_handle.h b/source3/smbd/fd_handle.h index dc0e5e43940..4d2e5093dc4 100644 --- a/source3/smbd/fd_handle.h +++ b/source3/smbd/fd_handle.h @@ -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); diff --git a/source3/smbd/open.c b/source3/smbd/open.c index 381f4eb190b..df6606f0215 100644 --- a/source3/smbd/open.c +++ b/source3/smbd/open.c @@ -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, */ diff --git a/source3/smbd/smb1_utils.c b/source3/smbd/smb1_utils.c index d5b6c9ba452..afd9b50c12c 100644 --- a/source3/smbd/smb1_utils.c +++ b/source3/smbd/smb1_utils.c @@ -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; }