1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-10 01:18:15 +03:00

smbd: convert fsp->posix_flags to fsp->fsp_flags.posix_open

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): Fri Oct 25 11:50:01 UTC 2024 on atb-devel-224
This commit is contained in:
Ralph Boehme 2024-10-04 19:22:39 +02:00 committed by Volker Lendecke
parent 149f77b63e
commit 2065f00656
17 changed files with 30 additions and 36 deletions

View File

@ -384,6 +384,9 @@
* Change to Version 50 - will ship with 4.22
* Version 50 - Change SMB_VFS_RENAMEAT() add vfs_rename_how
* Version 50 - Add VFS_RENAME_HOW_NO_REPLACE to vfs_rename_how
* Version 50 - Remove FSP_POSIX_FLAGS_PATHNAMES, remove FSP_POSIX_FLAGS_RENAME
* and convert struct files_struct.posix_flags to
* struct files_struct.fsp_flags.posix_open
*/
#define SMB_VFS_INTERFACE_VERSION 50
@ -458,6 +461,7 @@ typedef struct files_struct {
bool lock_failure_seen : 1;
bool encryption_required : 1;
bool fstat_before_close : 1;
bool posix_open : 1;
} fsp_flags;
struct tevent_timer *update_write_time_event;
@ -684,11 +688,6 @@ typedef struct files_struct {
* In any other case use fsp_get_io_fd().
*/
#define FSP_POSIX_FLAGS_OPEN 0x01
#define FSP_POSIX_FLAGS_ALL \
FSP_POSIX_FLAGS_OPEN
struct vuid_cache_entry {
struct auth_session_info *session_info;
struct name_compare_entry *hide_list;
@ -886,12 +885,7 @@ struct smb_filename {
struct fsp_smb_fname_link *fsp_link;
};
/*
* smb_filename flags. Define in terms of the FSP_POSIX_FLAGS_XX
* to keep the numeric values consistent.
*/
#define SMB_FILENAME_POSIX_PATH FSP_POSIX_FLAGS_OPEN
#define SMB_FILENAME_POSIX_PATH 0x01
enum vfs_translate_direction {
vfs_translate_to_unix = 0,

View File

@ -2022,7 +2022,7 @@ bool set_share_mode(struct share_mode_lock *lck,
.time.tv_usec = fsp->open_time.tv_usec,
.share_file_id = fh_get_gen_id(fsp->fh),
.uid = (uint32_t)uid,
.flags = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ?
.flags = fsp->fsp_flags.posix_open ?
SHARE_MODE_FLAG_POSIX_OPEN : 0,
.name_hash = fsp->name_hash,
};

View File

@ -1172,7 +1172,7 @@ int unlink_acl_common(struct vfs_handle_struct *handle,
int fchmod_acl_module_common(struct vfs_handle_struct *handle,
struct files_struct *fsp, mode_t mode)
{
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN
if (fsp->fsp_flags.posix_open
|| fsp->fsp_name->flags & SMB_FILENAME_POSIX_PATH) {
/* Only allow this on POSIX opens. */
return SMB_VFS_NEXT_FCHMOD(handle, fsp, mode);

View File

@ -4686,7 +4686,7 @@ enum brl_flavour lp_posix_cifsu_locktype(files_struct *fsp)
if (posix_default_lock_was_set) {
return posix_cifsx_locktype;
} else {
return (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ?
return fsp->fsp_flags.posix_open ?
POSIX_LOCK : WINDOWS_LOCK;
}
}

View File

@ -1133,7 +1133,7 @@ static NTSTATUS OpenDir_fsp(
goto fail;
}
dir_hnd->fsp = fsp;
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
if (fsp->fsp_flags.posix_open) {
dir_hnd->case_sensitive = true;
} else {
dir_hnd->case_sensitive = conn->case_sensitive;

View File

@ -947,7 +947,7 @@ int file_set_dosmode(connection_struct *conn,
return -1;
}
if ((smb_fname->fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) &&
if (smb_fname->fsp->fsp_flags.posix_open &&
!lp_store_dos_attributes(SNUM(conn)))
{
return 0;

View File

@ -148,7 +148,7 @@ void trigger_write_time_update(struct files_struct *fsp)
{
int delay;
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
if (fsp->fsp_flags.posix_open) {
/* Don't use delayed writes on POSIX files. */
return;
}
@ -195,7 +195,7 @@ void trigger_write_time_update_immediate(struct files_struct *fsp)
init_smb_file_time(&ft);
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
if (fsp->fsp_flags.posix_open) {
/* Don't use delayed writes on POSIX files. */
return;
}

View File

@ -2625,7 +2625,7 @@ static bool fsp_generic_ask_sharemode(struct files_struct *fsp)
return false;
}
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
if (fsp->fsp_flags.posix_open) {
/* Always use filesystem for UNIX mtime query. */
return false;
}

View File

@ -866,7 +866,7 @@ NTSTATUS fd_openat(const struct files_struct *dirfsp,
* client should be doing this.
*/
if ((fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) || !lp_follow_symlinks(SNUM(conn))) {
if (fsp->fsp_flags.posix_open || !lp_follow_symlinks(SNUM(conn))) {
how.flags |= O_NOFOLLOW;
}
@ -1270,7 +1270,7 @@ static NTSTATUS open_file(
SEC_FLAG_SYSTEM_SECURITY;
bool creating = !file_existed && (how.flags & O_CREAT);
bool open_fd = false;
bool posix_open = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN);
bool posix_open = fsp->fsp_flags.posix_open;
/*
* Catch early an attempt to open an existing
@ -4223,7 +4223,7 @@ static NTSTATUS open_file_ntcreate(connection_struct *conn,
* requested access_mask after
* the open is done. */
if (posix_open) {
fsp->posix_flags |= FSP_POSIX_FLAGS_ALL;
fsp->fsp_flags.posix_open = true;
}
if ((create_options & FILE_DELETE_ON_CLOSE) && (flags & O_CREAT) &&
@ -5349,7 +5349,7 @@ static NTSTATUS open_directory(connection_struct *conn,
fsp->sent_oplock_break = NO_BREAK_SENT;
fsp->fsp_flags.is_directory = true;
if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
fsp->posix_flags |= FSP_POSIX_FLAGS_ALL;
fsp->fsp_flags.posix_open = true;
}
/* Don't store old timestamps for directory

View File

@ -1508,7 +1508,7 @@ static void call_trans2findnext(connection_struct *conn,
*/
if(!continue_bit && resume_name && *resume_name) {
bool posix_open = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN);
bool posix_open = fsp->fsp_flags.posix_open;
char *last_name_sent = NULL;
bool sequential;

View File

@ -339,7 +339,7 @@ static struct tevent_req *smbd_smb2_getinfo_send(TALLOC_CTX *mem_ctx,
break;
case SMB2_FILE_POSIX_INFORMATION:
if (!(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN)) {
if (!fsp->fsp_flags.posix_open) {
tevent_req_nterror(req, NT_STATUS_INVALID_LEVEL);
return tevent_req_post(req, ev);
}

View File

@ -381,7 +381,7 @@ static struct tevent_req *smbd_smb2_lock_send(TALLOC_CTX *mem_ctx,
for (i=0; i<in_lock_count; i++) {
bool invalid = false;
bool posix_handle =(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN);
bool posix_handle = fsp->fsp_flags.posix_open;
switch (in_locks[i].flags) {
case SMB2_LOCK_FLAG_SHARED:

View File

@ -189,7 +189,7 @@ static bool check_smb2_posix_chmod_ace(const struct files_struct *fsp,
return false;
}
if (!(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN)) {
if (!fsp->fsp_flags.posix_open) {
return false;
}

View File

@ -273,7 +273,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
char *p;
bool stop = false;
bool ok;
bool posix_dir_handle = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN);
bool posix_dir_handle = fsp->fsp_flags.posix_open;
req = tevent_req_create(mem_ctx, &state,
struct smbd_smb2_query_directory_state);
@ -368,7 +368,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
break;
case SMB2_FIND_POSIX_INFORMATION:
if (!(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN)) {
if (!fsp->fsp_flags.posix_open) {
tevent_req_nterror(req, NT_STATUS_INVALID_LEVEL);
return tevent_req_post(req, ev);
}

View File

@ -1409,9 +1409,9 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
uint32_t access_mask = SEC_DIR_ADD_FILE;
bool dst_exists, old_is_stream, new_is_stream;
int ret;
bool case_sensitive = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ?
bool case_sensitive = fsp->fsp_flags.posix_open ?
true : conn->case_sensitive;
bool case_preserve = (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) ?
bool case_preserve = fsp->fsp_flags.posix_open ?
true : conn->case_preserve;
struct vfs_rename_how rhow = { .flags = 0, };
@ -1470,7 +1470,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
* can check them separately.
*/
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
if (fsp->fsp_flags.posix_open) {
/* POSIX - no stream component. */
orig_lcomp_path = talloc_strdup(ctx,
dst_original_lcomp);

View File

@ -1960,7 +1960,7 @@ static bool fsinfo_unix_valid_level(connection_struct *conn,
uint16_t info_level)
{
if (conn_using_smb2(conn->sconn) &&
(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) &&
fsp->fsp_flags.posix_open &&
info_level == SMB2_FS_POSIX_INFORMATION_INTERNAL)
{
return true;
@ -3006,7 +3006,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
}
if (conn_using_smb2(conn->sconn) &&
(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN))
fsp->fsp_flags.posix_open)
{
DBG_DEBUG("SMB2 posix open\n");
ok = true;
@ -3677,7 +3677,7 @@ NTSTATUS smbd_do_qfilepathinfo(connection_struct *conn,
if (fsp == NULL) {
return NT_STATUS_INVALID_HANDLE;
}
if (!(fsp->posix_flags & FSP_POSIX_FLAGS_OPEN)) {
if (!fsp->fsp_flags.posix_open) {
return NT_STATUS_INVALID_LEVEL;
}

View File

@ -1172,7 +1172,7 @@ NTSTATUS vfs_stat_fsp(files_struct *fsp)
}
if (fsp_get_pathref_fd(fsp) == -1) {
if (fsp->posix_flags & FSP_POSIX_FLAGS_OPEN) {
if (fsp->fsp_flags.posix_open) {
ret = SMB_VFS_LSTAT(fsp->conn, fsp->fsp_name);
} else {
ret = SMB_VFS_STAT(fsp->conn, fsp->fsp_name);