smbd: move files_struct.is_directory to a bitfield
authorRalph Boehme <slow@samba.org>
Thu, 2 Apr 2020 16:21:11 +0000 (18:21 +0200)
committerJeremy Allison <jra@samba.org>
Fri, 3 Apr 2020 19:05:44 +0000 (19:05 +0000)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
26 files changed:
source3/include/vfs.h
source3/locking/locking.c
source3/modules/offload_token.c
source3/modules/vfs_afsacl.c
source3/modules/vfs_ceph_snapshots.c
source3/modules/vfs_default.c
source3/modules/vfs_fruit.c
source3/modules/vfs_virusfilter.c
source3/printing/printspoolss.c
source3/smbd/close.c
source3/smbd/dir.c
source3/smbd/dosmode.c
source3/smbd/durable.c
source3/smbd/file_access.c
source3/smbd/files.c
source3/smbd/nttrans.c
source3/smbd/open.c
source3/smbd/posix_acls.c
source3/smbd/pysmbd.c
source3/smbd/reply.c
source3/smbd/smb2_flush.c
source3/smbd/smb2_notify.c
source3/smbd/smb2_query_directory.c
source3/smbd/smb2_read.c
source3/smbd/trans2.c
source3/torture/cmd_vfs.c

index 74d9aa17e4304abe9591aa58a3642ed9915e6a7c..a09e189cede11abf6703c609d1416951efaa93b1 100644 (file)
@@ -366,6 +366,7 @@ typedef struct files_struct {
                bool can_read : 1;
                bool can_write : 1;
                bool modified : 1;
                bool can_read : 1;
                bool can_write : 1;
                bool modified : 1;
+               bool is_directory : 1;
        } fsp_flags;
 
        struct tevent_timer *update_write_time_event;
        } fsp_flags;
 
        struct tevent_timer *update_write_time_event;
@@ -386,7 +387,6 @@ typedef struct files_struct {
        struct lock_struct last_lock_failure;
        int current_lock_count; /* Count the number of outstanding locks and pending locks. */
 
        struct lock_struct last_lock_failure;
        int current_lock_count; /* Count the number of outstanding locks and pending locks. */
 
-       bool is_directory;
        bool aio_write_behind;
        bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
        bool delete_on_close;
        bool aio_write_behind;
        bool initial_delete_on_close; /* Only set at NTCreateX if file was created. */
        bool delete_on_close;
index 7d71e436f4a949702b60a224e5f17a991e2005af..c2ccd669c718c45c8d1f0dd6016540779a6a44ac 100644 (file)
@@ -179,7 +179,9 @@ NTSTATUS query_lock(files_struct *fsp,
        struct byte_range_lock *br_lck = NULL;
 
        if (!fsp->fsp_flags.can_lock) {
        struct byte_range_lock *br_lck = NULL;
 
        if (!fsp->fsp_flags.can_lock) {
-               return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE;
+               return fsp->fsp_flags.is_directory ?
+                       NT_STATUS_INVALID_DEVICE_REQUEST :
+                       NT_STATUS_INVALID_HANDLE;
        }
 
        if (!lp_locking(fsp->conn->params)) {
        }
 
        if (!lp_locking(fsp->conn->params)) {
@@ -307,7 +309,7 @@ NTSTATUS do_lock(files_struct *fsp,
        }
 
        if (!fsp->fsp_flags.can_lock) {
        }
 
        if (!fsp->fsp_flags.can_lock) {
-               if (fsp->is_directory) {
+               if (fsp->fsp_flags.is_directory) {
                        return NT_STATUS_INVALID_DEVICE_REQUEST;
                }
                return NT_STATUS_INVALID_HANDLE;
                        return NT_STATUS_INVALID_DEVICE_REQUEST;
                }
                return NT_STATUS_INVALID_HANDLE;
@@ -363,7 +365,9 @@ NTSTATUS do_unlock(files_struct *fsp,
        struct byte_range_lock *br_lck = NULL;
 
        if (!fsp->fsp_flags.can_lock) {
        struct byte_range_lock *br_lck = NULL;
 
        if (!fsp->fsp_flags.can_lock) {
-               return fsp->is_directory ? NT_STATUS_INVALID_DEVICE_REQUEST : NT_STATUS_INVALID_HANDLE;
+               return fsp->fsp_flags.is_directory ?
+                       NT_STATUS_INVALID_DEVICE_REQUEST :
+                       NT_STATUS_INVALID_HANDLE;
        }
 
        if (!lp_locking(fsp->conn->params)) {
        }
 
        if (!lp_locking(fsp->conn->params)) {
@@ -929,7 +933,7 @@ bool set_delete_on_close(files_struct *fsp, bool delete_on_close,
                reset_delete_on_close_lck(fsp, lck);
        }
 
                reset_delete_on_close_lck(fsp, lck);
        }
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
                send_stat_cache_delete_message(fsp->conn->sconn->msg_ctx,
                                               fsp->fsp_name->base_name);
                SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
                send_stat_cache_delete_message(fsp->conn->sconn->msg_ctx,
                                               fsp->fsp_name->base_name);
index c562f1bab0bec02154e066030cce9e77a9aa3aef..a5975811f5db4fbb54a8cce8f2b35acb4cf06d05 100644 (file)
@@ -280,13 +280,13 @@ NTSTATUS vfs_offload_token_check_handles(uint32_t fsctl,
                return NT_STATUS_ACCESS_DENIED;
        }
 
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       if (src_fsp->is_directory) {
+       if (src_fsp->fsp_flags.is_directory) {
                DBG_INFO("copy chunk no read on src directory handle (%s).\n",
                         smb_fname_str_dbg(src_fsp->fsp_name));
                return NT_STATUS_ACCESS_DENIED;
        }
 
                DBG_INFO("copy chunk no read on src directory handle (%s).\n",
                         smb_fname_str_dbg(src_fsp->fsp_name));
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       if (dst_fsp->is_directory) {
+       if (dst_fsp->fsp_flags.is_directory) {
                DBG_INFO("copy chunk no read on dst directory handle (%s).\n",
                         smb_fname_str_dbg(dst_fsp->fsp_name));
                return NT_STATUS_ACCESS_DENIED;
                DBG_INFO("copy chunk no read on dst directory handle (%s).\n",
                         smb_fname_str_dbg(dst_fsp->fsp_name));
                return NT_STATUS_ACCESS_DENIED;
index 40071c8543148060bd46fbe45f45554093291f65..e4b99fdcf93de51546236761754f89af7f7bab17 100644 (file)
@@ -930,7 +930,7 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
                return NT_STATUS_NO_MEMORY;
        }
 
                return NT_STATUS_NO_MEMORY;
        }
 
-       if (!fsp->is_directory) {
+       if (!fsp->fsp_flags.is_directory) {
                /* We need to get the name of the directory containing the
                 * file, this is where the AFS acls live */
                char *p = strrchr(name, '/');
                /* We need to get the name of the directory containing the
                 * file, this is where the AFS acls live */
                char *p = strrchr(name, '/');
@@ -951,7 +951,7 @@ static NTSTATUS afs_set_nt_acl(vfs_handle_struct *handle, files_struct *fsp,
 
        split_afs_acl(&old_afs_acl, &dir_acl, &file_acl);
 
 
        split_afs_acl(&old_afs_acl, &dir_acl, &file_acl);
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
 
                if (!strequal(fileacls, "yes")) {
                        /* Throw away file acls, we depend on the
 
                if (!strequal(fileacls, "yes")) {
                        /* Throw away file acls, we depend on the
index 7af9ff655c127d55fd6b97350c7c1f2b25363d32..2b625843187d78365e17221155332ca173af8f81 100644 (file)
@@ -380,7 +380,7 @@ static int ceph_snap_get_shadow_copy_data(struct vfs_handle_struct *handle,
                goto err_out;
        }
 
                goto err_out;
        }
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                parent_dir = fsp->fsp_name->base_name;
        } else {
                ret = ceph_snap_get_parent_path(handle->conn->connectpath,
                parent_dir = fsp->fsp_name->base_name;
        } else {
                ret = ceph_snap_get_parent_path(handle->conn->connectpath,
index ca1f000143a6280b32c38f1e63a5d4e39d74bddb..42964c98499bc39f19748d2b8b869c161b5bc64c 100644 (file)
@@ -2987,7 +2987,7 @@ static NTSTATUS vfswrap_streaminfo(vfs_handle_struct *handle,
        struct stream_struct *tmp_streams = NULL;
        int ret;
 
        struct stream_struct *tmp_streams = NULL;
        int ret;
 
-       if ((fsp != NULL) && (fsp->is_directory)) {
+       if ((fsp != NULL) && (fsp->fsp_flags.is_directory)) {
                /*
                 * No default streams on directories
                 */
                /*
                 * No default streams on directories
                 */
index 1d82b47045cdaf3ebea83401c6d95b2b44829433..86870f8f9cf50a930675c3844ccaeec4246f90e1 100644 (file)
@@ -3946,7 +3946,7 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
        fsp = *result;
 
        if (global_fruit_config.nego_aapl) {
        fsp = *result;
 
        if (global_fruit_config.nego_aapl) {
-               if (config->posix_rename && fsp->is_directory) {
+               if (config->posix_rename && fsp->fsp_flags.is_directory) {
                        /*
                         * Enable POSIX directory rename behaviour
                         */
                        /*
                         * Enable POSIX directory rename behaviour
                         */
@@ -3975,8 +3975,7 @@ static NTSTATUS fruit_create_file(vfs_handle_struct *handle,
                fio->created = true;
        }
 
                fio->created = true;
        }
 
-       if (is_named_stream(smb_fname)
-           || fsp->is_directory) {
+       if (is_named_stream(smb_fname) || fsp->fsp_flags.is_directory) {
                return status;
        }
 
                return status;
        }
 
index 9dbe9b6348baa5acbcbb2f6decb80d56cab98162..256bf420eb1ca1ba26f604c29561667f26788f5b 100644 (file)
@@ -1158,7 +1158,7 @@ static int virusfilter_vfs_open(
        SMB_VFS_HANDLE_GET_DATA(handle, config,
                                struct virusfilter_config, return -1);
 
        SMB_VFS_HANDLE_GET_DATA(handle, config,
                                struct virusfilter_config, return -1);
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                DBG_INFO("Not scanned: Directory: %s/\n", cwd_fname);
                goto virusfilter_vfs_open_next;
        }
                DBG_INFO("Not scanned: Directory: %s/\n", cwd_fname);
                goto virusfilter_vfs_open_next;
        }
@@ -1344,7 +1344,7 @@ static int virusfilter_vfs_close(
                goto virusfilter_vfs_close_fail;
        }
 
                goto virusfilter_vfs_close_fail;
        }
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                DBG_INFO("Not scanned: Directory: %s/\n", cwd_fname);
                return close_result;
        }
                DBG_INFO("Not scanned: Directory: %s/\n", cwd_fname);
                return close_result;
        }
index c397902592c04b196eb2f95fc60d8f13e798c0c0..8943452c9d4f2caac24593d752ac33d3a39073a9 100644 (file)
@@ -235,7 +235,7 @@ NTSTATUS print_spool_open(files_struct *fsp,
        fsp->fsp_flags.modified = false;
        fsp->oplock_type = NO_OPLOCK;
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->fsp_flags.modified = false;
        fsp->oplock_type = NO_OPLOCK;
        fsp->sent_oplock_break = NO_BREAK_SENT;
-       fsp->is_directory = false;
+       fsp->fsp_flags.is_directory = false;
 
        fsp->print_file = pf;
 
 
        fsp->print_file = pf;
 
index 9a29bec4e7cd91f194c66a39dc1cc921aa761738..05ee03d2484691b9f6c99774dbc3abd8ad95f039 100644 (file)
@@ -1243,7 +1243,7 @@ NTSTATUS close_file(struct smb_request *req, files_struct *fsp,
        NTSTATUS status;
        struct files_struct *base_fsp = fsp->base_fsp;
 
        NTSTATUS status;
        struct files_struct *base_fsp = fsp->base_fsp;
 
-       if(fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                status = close_directory(req, fsp, close_type);
        } else if (fsp->fake_file_handle != NULL) {
                status = close_fake_file(req, fsp);
                status = close_directory(req, fsp, close_type);
        } else if (fsp->fake_file_handle != NULL) {
                status = close_fake_file(req, fsp);
index d5cc5213da0e406b6147272e0734e85a5f60fae4..b080aeb18f8981778d8936fc8c173ddb2607990f 100644 (file)
@@ -1376,7 +1376,7 @@ static struct smb_Dir *OpenDir_fsp(TALLOC_CTX *mem_ctx, connection_struct *conn,
                goto fail;
        }
 
                goto fail;
        }
 
-       if (!fsp->is_directory) {
+       if (!fsp->fsp_flags.is_directory) {
                errno = EBADF;
                goto fail;
        }
                errno = EBADF;
                goto fail;
        }
index 148de405462803751d9ecb05c90bfde122483d71..b9dbbbf58d6328b1d853e137c71efcf308c74654 100644 (file)
@@ -1152,7 +1152,7 @@ NTSTATUS file_set_sparse(connection_struct *conn,
                return NT_STATUS_ACCESS_DENIED;
        }
 
                return NT_STATUS_ACCESS_DENIED;
        }
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                DEBUG(9, ("invalid attempt to %s sparse flag on dir %s\n",
                          (sparse ? "set" : "clear"),
                          smb_fname_str_dbg(fsp->fsp_name)));
                DEBUG(9, ("invalid attempt to %s sparse flag on dir %s\n",
                          (sparse ? "set" : "clear"),
                          smb_fname_str_dbg(fsp->fsp_name)));
index d6e05c6245aa32132af1c8a3dc8ea6bef8961d20..26537567e8eeef61f399117ef5b9ade0b8ded3a4 100644 (file)
@@ -70,7 +70,7 @@ NTSTATUS vfs_default_durable_cookie(struct files_struct *fsp,
                return NT_STATUS_NOT_SUPPORTED;
        }
 
                return NT_STATUS_NOT_SUPPORTED;
        }
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                return NT_STATUS_NOT_SUPPORTED;
        }
 
                return NT_STATUS_NOT_SUPPORTED;
        }
 
@@ -695,7 +695,7 @@ NTSTATUS vfs_default_durable_reconnect(struct connection_struct *conn,
        /*
         * no durables for directories
         */
        /*
         * no durables for directories
         */
-       fsp->is_directory = false;
+       fsp->fsp_flags.is_directory = false;
        /*
         * For normal files, can_lock == !is_directory
         */
        /*
         * For normal files, can_lock == !is_directory
         */
index 66c9ed3add7c5d32b65c051c770c102ef19aacf2..cc939325e6292b1a8b6832904f8cb35dc264079a 100644 (file)
@@ -231,7 +231,7 @@ NTSTATUS can_set_delete_on_close(files_struct *fsp, uint32_t dosmode)
        }
 
        /* Don't allow delete on close for non-empty directories. */
        }
 
        /* Don't allow delete on close for non-empty directories. */
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
 
                /* Or the root of a share. */
                SMB_ASSERT(!is_ntfs_stream_smb_fname(fsp->fsp_name));
 
                /* Or the root of a share. */
index 5a0b5622096513f8c0a47cbebc94b1dc94bfa853..7e2d12b8794432363afd6d96fc39a2034dd7c926 100644 (file)
@@ -208,7 +208,7 @@ NTSTATUS create_internal_dirfsp_at(connection_struct *conn,
 
        fsp->file_id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
        fsp->access_mask = FILE_LIST_DIRECTORY;
 
        fsp->file_id = vfs_file_id_from_sbuf(conn, &fsp->fsp_name->st);
        fsp->access_mask = FILE_LIST_DIRECTORY;
-       fsp->is_directory = true;
+       fsp->fsp_flags.is_directory = true;
 
        *_fsp = fsp;
        return NT_STATUS_OK;
 
        *_fsp = fsp;
        return NT_STATUS_OK;
@@ -794,7 +794,7 @@ NTSTATUS dup_file_fsp(
                CAN_WRITE(from->conn) &&
                ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0);
        to->fsp_flags.modified = from->fsp_flags.modified;
                CAN_WRITE(from->conn) &&
                ((access_mask & (FILE_WRITE_DATA | FILE_APPEND_DATA)) != 0);
        to->fsp_flags.modified = from->fsp_flags.modified;
-       to->is_directory = from->is_directory;
+       to->fsp_flags.is_directory = from->fsp_flags.is_directory;
        to->aio_write_behind = from->aio_write_behind;
 
        return fsp_set_smb_fname(to, from->fsp_name);
        to->aio_write_behind = from->aio_write_behind;
 
        return fsp_set_smb_fname(to, from->fsp_name);
index 38493d58c0280286f9499898f67d9b39517faee5..affedf5f52712f3561ed945e3c010bb945f7dcbe 100644 (file)
@@ -719,12 +719,12 @@ void reply_ntcreate_and_X(struct smb_request *req)
                SSVAL(p,2,file_status);
        }
        p += 4;
                SSVAL(p,2,file_status);
        }
        p += 4;
-       SCVAL(p,0,fsp->is_directory ? 1 : 0);
+       SCVAL(p,0,fsp->fsp_flags.is_directory ? 1 : 0);
 
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
                uint32_t perms = 0;
                p += 25;
 
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
                uint32_t perms = 0;
                p += 25;
-               if (fsp->is_directory ||
+               if (fsp->fsp_flags.is_directory ||
                    fsp->fsp_flags.can_write ||
                    can_write_to_file(conn, smb_fname)) {
                        perms = FILE_GENERIC_ALL;
                    fsp->fsp_flags.can_write ||
                    can_write_to_file(conn, smb_fname)) {
                        perms = FILE_GENERIC_ALL;
@@ -1374,12 +1374,12 @@ static void call_nt_transact_create(connection_struct *conn,
                SSVAL(p,2,file_status);
        }
        p += 4;
                SSVAL(p,2,file_status);
        }
        p += 4;
-       SCVAL(p,0,fsp->is_directory ? 1 : 0);
+       SCVAL(p,0,fsp->fsp_flags.is_directory ? 1 : 0);
 
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
                uint32_t perms = 0;
                p += 25;
 
        if (flags & EXTENDED_RESPONSE_REQUIRED) {
                uint32_t perms = 0;
                p += 25;
-               if (fsp->is_directory ||
+               if (fsp->fsp_flags.is_directory ||
                    fsp->fsp_flags.can_write ||
                    can_write_to_file(conn, smb_fname)) {
                        perms = FILE_GENERIC_ALL;
                    fsp->fsp_flags.can_write ||
                    can_write_to_file(conn, smb_fname)) {
                        perms = FILE_GENERIC_ALL;
@@ -1837,7 +1837,7 @@ static void call_nt_transact_notify_change(connection_struct *conn,
                TALLOC_FREE(filter_string);
        }
 
                TALLOC_FREE(filter_string);
        }
 
-       if((!fsp->is_directory) || (conn != fsp->conn)) {
+       if((!fsp->fsp_flags.is_directory) || (conn != fsp->conn)) {
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return;
        }
                reply_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return;
        }
index ffb3ea5f9d147fed23c5fd277a5938a2dcf81c0d..63018759dfba646987e7434276457df42d3ab424 100644 (file)
@@ -614,7 +614,7 @@ static int non_widelink_open(struct connection_struct *conn,
        const char *final_component = NULL;
        bool ok;
 
        const char *final_component = NULL;
        bool ok;
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                parent_dir = talloc_strdup(talloc_tos(), smb_fname->base_name);
                if (parent_dir == NULL) {
                        saved_errno = errno;
                parent_dir = talloc_strdup(talloc_tos(), smb_fname->base_name);
                if (parent_dir == NULL) {
                        saved_errno = errno;
@@ -1437,7 +1437,7 @@ static NTSTATUS open_file(files_struct *fsp,
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
-       fsp->is_directory = False;
+       fsp->fsp_flags.is_directory = false;
        if (conn->aio_write_behind_list &&
            is_in_path(smb_fname->base_name, conn->aio_write_behind_list,
                       conn->case_sensitive)) {
        if (conn->aio_write_behind_list &&
            is_in_path(smb_fname->base_name, conn->aio_write_behind_list,
                       conn->case_sensitive)) {
@@ -4405,7 +4405,7 @@ static NTSTATUS open_directory(connection_struct *conn,
        fsp->fsp_flags.modified = false;
        fsp->oplock_type = NO_OPLOCK;
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->fsp_flags.modified = false;
        fsp->oplock_type = NO_OPLOCK;
        fsp->sent_oplock_break = NO_BREAK_SENT;
-       fsp->is_directory = True;
+       fsp->fsp_flags.is_directory = true;
        if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
                fsp->posix_flags |= FSP_POSIX_FLAGS_ALL;
        }
        if (file_attributes & FILE_FLAG_POSIX_SEMANTICS) {
                fsp->posix_flags |= FSP_POSIX_FLAGS_ALL;
        }
@@ -4863,7 +4863,7 @@ static NTSTATUS inherit_new_acl(files_struct *fsp)
        }
 
        inheritable_components = sd_has_inheritable_components(parent_desc,
        }
 
        inheritable_components = sd_has_inheritable_components(parent_desc,
-                                       fsp->is_directory);
+                                       fsp->fsp_flags.is_directory);
 
        if (!inheritable_components && !inherit_owner) {
                TALLOC_FREE(frame);
 
        if (!inheritable_components && !inherit_owner) {
                TALLOC_FREE(frame);
@@ -4984,7 +4984,7 @@ static NTSTATUS inherit_new_acl(files_struct *fsp)
                        parent_desc,
                        owner_sid,
                        group_sid,
                        parent_desc,
                        owner_sid,
                        group_sid,
-                       fsp->is_directory);
+                       fsp->fsp_flags.is_directory);
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(frame);
                return status;
        if (!NT_STATUS_IS_OK(status)) {
                TALLOC_FREE(frame);
                return status;
@@ -5637,7 +5637,9 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
                }
        }
 
                }
        }
 
-       if (!fsp->is_directory && S_ISDIR(fsp->fsp_name->st.st_ex_mode)) {
+       if (!fsp->fsp_flags.is_directory &&
+           S_ISDIR(fsp->fsp_name->st.st_ex_mode))
+       {
                status = NT_STATUS_ACCESS_DENIED;
                goto fail;
        }
                status = NT_STATUS_ACCESS_DENIED;
                goto fail;
        }
@@ -5645,7 +5647,7 @@ static NTSTATUS create_file_unixpath(connection_struct *conn,
        /* Save the requested allocation size. */
        if ((info == FILE_WAS_CREATED) || (info == FILE_WAS_OVERWRITTEN)) {
                if ((allocation_size > (uint64_t)fsp->fsp_name->st.st_ex_size)
        /* Save the requested allocation size. */
        if ((info == FILE_WAS_CREATED) || (info == FILE_WAS_OVERWRITTEN)) {
                if ((allocation_size > (uint64_t)fsp->fsp_name->st.st_ex_size)
-                   && !(fsp->is_directory))
+                   && !(fsp->fsp_flags.is_directory))
                {
                        fsp->initial_allocation_size = smb_roundup(
                                fsp->conn, allocation_size);
                {
                        fsp->initial_allocation_size = smb_roundup(
                                fsp->conn, allocation_size);
@@ -5782,7 +5784,7 @@ static NTSTATUS get_relative_fid_filename(
                goto out;
        }
 
                goto out;
        }
 
-       if (!dir_fsp->is_directory) {
+       if (!dir_fsp->fsp_flags.is_directory) {
 
                /*
                 * Check to see if this is a mac fork of some kind.
 
                /*
                 * Check to see if this is a mac fork of some kind.
index e5ea305748681ff4e2c4299fbe3aa7602b46fcd5..7e64965d85ef5770e0de70072f13caad01a5faac 100644 (file)
@@ -1707,7 +1707,7 @@ static bool add_current_ace_to_acl(files_struct *fsp, struct security_ace *psa,
         * DLIST_ADD_END) as NT ACLs are order dependent.
         */
 
         * DLIST_ADD_END) as NT ACLs are order dependent.
         */
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
 
                /*
                 * We can only add to the default POSIX ACE list if the ACE is
 
                /*
                 * We can only add to the default POSIX ACE list if the ACE is
@@ -1870,7 +1870,7 @@ static bool create_canon_ace_lists(files_struct *fsp,
                                        canon_ace **ppdir_ace,
                                        const struct security_acl *dacl)
 {
                                        canon_ace **ppdir_ace,
                                        const struct security_acl *dacl)
 {
-       bool all_aces_are_inherit_only = (fsp->is_directory ? True : False);
+       bool all_aces_are_inherit_only = (fsp->fsp_flags.is_directory);
        canon_ace *file_ace = NULL;
        canon_ace *dir_ace = NULL;
        canon_ace *current_ace = NULL;
        canon_ace *file_ace = NULL;
        canon_ace *dir_ace = NULL;
        canon_ace *current_ace = NULL;
@@ -2131,7 +2131,7 @@ static bool create_canon_ace_lists(files_struct *fsp,
                }
        }
 
                }
        }
 
-       if (fsp->is_directory && all_aces_are_inherit_only) {
+       if (fsp->fsp_flags.is_directory && all_aces_are_inherit_only) {
                /*
                 * Windows 2000 is doing one of these weird 'inherit acl'
                 * traverses to conserve NTFS ACL resources. Just pretend
                /*
                 * Windows 2000 is doing one of these weird 'inherit acl'
                 * traverses to conserve NTFS ACL resources. Just pretend
@@ -2558,7 +2558,7 @@ static bool unpack_canon_ace(files_struct *fsp,
                &file_ace,
                false,
                fsp->conn->params,
                &file_ace,
                false,
                fsp->conn->params,
-               fsp->is_directory,
+               fsp->fsp_flags.is_directory,
                pfile_owner_sid,
                pfile_grp_sid,
                pst);
                pfile_owner_sid,
                pfile_grp_sid,
                pst);
@@ -2576,7 +2576,7 @@ static bool unpack_canon_ace(files_struct *fsp,
                        &dir_ace,
                        true,
                        fsp->conn->params,
                        &dir_ace,
                        true,
                        fsp->conn->params,
-                       fsp->is_directory,
+                       fsp->fsp_flags.is_directory,
                        pfile_owner_sid,
                        pfile_grp_sid,
                        pst);
                        pfile_owner_sid,
                        pfile_grp_sid,
                        pst);
@@ -3026,7 +3026,7 @@ static bool set_canon_ace_list(files_struct *fsp,
         * Finally apply it to the file or directory.
         */
 
         * Finally apply it to the file or directory.
         */
 
-       if(default_ace || fsp->is_directory || fsp->fh->fd == -1) {
+       if (default_ace || fsp->fsp_flags.is_directory || fsp->fh->fd == -1) {
                if (SMB_VFS_SYS_ACL_SET_FILE(conn, fsp->fsp_name,
                                             the_acl_type, the_acl) == -1) {
                        /*
                if (SMB_VFS_SYS_ACL_SET_FILE(conn, fsp->fsp_name,
                                             the_acl_type, the_acl) == -1) {
                        /*
@@ -3215,7 +3215,7 @@ static bool convert_canon_ace_to_posix_perms( files_struct *fsp, canon_ace *file
        /* The owner must have at least read access. */
 
        *posix_perms |= S_IRUSR;
        /* The owner must have at least read access. */
 
        *posix_perms |= S_IRUSR;
-       if (fsp->is_directory)
+       if (fsp->fsp_flags.is_directory)
                *posix_perms |= (S_IWUSR|S_IXUSR);
 
        DEBUG(10,("convert_canon_ace_to_posix_perms: converted u=%o,g=%o,w=%o "
                *posix_perms |= (S_IWUSR|S_IXUSR);
 
        DEBUG(10,("convert_canon_ace_to_posix_perms: converted u=%o,g=%o,w=%o "
@@ -3490,7 +3490,7 @@ NTSTATUS posix_fget_nt_acl(struct files_struct *fsp, uint32_t security_info,
                  fsp_str_dbg(fsp)));
 
        /* can it happen that fsp_name == NULL ? */
                  fsp_str_dbg(fsp)));
 
        /* can it happen that fsp_name == NULL ? */
-       if (fsp->is_directory ||  fsp->fh->fd == -1) {
+       if (fsp->fsp_flags.is_directory ||  fsp->fh->fd == -1) {
                status = posix_get_nt_acl(fsp->conn, fsp->fsp_name,
                                          security_info, mem_ctx, ppdesc);
                TALLOC_FREE(frame);
                status = posix_get_nt_acl(fsp->conn, fsp->fsp_name,
                                          security_info, mem_ctx, ppdesc);
                TALLOC_FREE(frame);
@@ -3878,7 +3878,7 @@ NTSTATUS set_nt_acl(files_struct *fsp, uint32_t security_info_sent, const struct
                }
        }
 
                }
        }
 
-       if (acl_perms && acl_set_support && fsp->is_directory) {
+       if (acl_perms && acl_set_support && fsp->fsp_flags.is_directory) {
                if (dir_ace_list) {
                        if (set_acl_as_root) {
                                become_root();
                if (dir_ace_list) {
                        if (set_acl_as_root) {
                                become_root();
@@ -4380,7 +4380,7 @@ NTSTATUS set_unix_posix_default_acl(connection_struct *conn,
        NTSTATUS status;
        int ret;
 
        NTSTATUS status;
        int ret;
 
-       if (!fsp->is_directory) {
+       if (!fsp->fsp_flags.is_directory) {
                return NT_STATUS_INVALID_HANDLE;
        }
 
                return NT_STATUS_INVALID_HANDLE;
        }
 
@@ -4781,7 +4781,7 @@ int posix_sys_acl_blob_get_fd(vfs_handle_struct *handle,
        int ret;
 
        /* This ensures that we also consider the default ACL */
        int ret;
 
        /* This ensures that we also consider the default ACL */
-       if (fsp->is_directory ||  fsp->fh->fd == -1) {
+       if (fsp->fsp_flags.is_directory ||  fsp->fh->fd == -1) {
                return posix_sys_acl_blob_get_file(handle,
                                                fsp->fsp_name,
                                                mem_ctx,
                return posix_sys_acl_blob_get_file(handle,
                                                fsp->fsp_name,
                                                mem_ctx,
index d9d4a6143cc3f70a2140855dbe3f9d8a6e6cf0bc..d3a701dcc32cb8918d90002843fbc5b7bd1fa579 100644 (file)
@@ -199,7 +199,7 @@ static NTSTATUS init_files_struct(TALLOC_CTX *mem_ctx,
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
-       fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode);
+       fsp->fsp_flags.is_directory = S_ISDIR(smb_fname->st.st_ex_mode);
 
        *_fsp = fsp;
 
 
        *_fsp = fsp;
 
index 7c9900d763cd6e2a89a97e48f8d55432dbe038e9..a2d621db1c337c6cbb4b67891e5113167b19f35e 100644 (file)
@@ -500,7 +500,7 @@ bool check_fsp(connection_struct *conn, struct smb_request *req,
        if (!check_fsp_open(conn, req, fsp)) {
                return False;
        }
        if (!check_fsp_open(conn, req, fsp)) {
                return False;
        }
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                reply_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
                return False;
        }
                reply_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
                return False;
        }
@@ -524,7 +524,7 @@ bool check_fsp_ntquota_handle(connection_struct *conn, struct smb_request *req,
                return false;
        }
 
                return false;
        }
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                return false;
        }
 
                return false;
        }
 
@@ -4003,7 +4003,7 @@ void reply_readbraw(struct smb_request *req)
            conn == NULL ||
            conn != fsp->conn ||
            req->vuid != fsp->vuid ||
            conn == NULL ||
            conn != fsp->conn ||
            req->vuid != fsp->vuid ||
-           fsp->is_directory ||
+           fsp->fsp_flags.is_directory ||
            fsp->fh->fd == -1)
        {
                /*
            fsp->fh->fd == -1)
        {
                /*
@@ -6032,11 +6032,12 @@ void reply_close(struct smb_request *smb1req)
        }
 
        DBG_NOTICE("Close %s fd=%d %s (numopen=%d)\n",
        }
 
        DBG_NOTICE("Close %s fd=%d %s (numopen=%d)\n",
-                 fsp->is_directory ? "directory" : "file",
+                 fsp->fsp_flags.is_directory ?
+                 "directory" : "file",
                  fsp->fh->fd, fsp_fnum_dbg(fsp),
                  conn->num_files_open);
 
                  fsp->fh->fd, fsp_fnum_dbg(fsp),
                  conn->num_files_open);
 
-       if (!fsp->is_directory) {
+       if (!fsp->fsp_flags.is_directory) {
                time_t t;
 
                /*
                time_t t;
 
                /*
@@ -7830,7 +7831,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                          "%s -> %s\n", smb_fname_str_dbg(fsp->fsp_name),
                          smb_fname_str_dbg(smb_fname_dst)));
 
                          "%s -> %s\n", smb_fname_str_dbg(fsp->fsp_name),
                          smb_fname_str_dbg(smb_fname_dst)));
 
-               if (!fsp->is_directory &&
+               if (!fsp->fsp_flags.is_directory &&
                    !(fsp->posix_flags & FSP_POSIX_FLAGS_PATHNAMES) &&
                    (lp_map_archive(SNUM(conn)) ||
                    lp_store_dos_attributes(SNUM(conn)))) {
                    !(fsp->posix_flags & FSP_POSIX_FLAGS_PATHNAMES) &&
                    (lp_map_archive(SNUM(conn)) ||
                    lp_store_dos_attributes(SNUM(conn)))) {
@@ -7848,7 +7849,7 @@ NTSTATUS rename_internals_fsp(connection_struct *conn,
                }
 
                notify_rename(conn,
                }
 
                notify_rename(conn,
-                             fsp->is_directory,
+                             fsp->fsp_flags.is_directory,
                              fsp->fsp_name,
                              smb_fname_dst);
 
                              fsp->fsp_name,
                              smb_fname_dst);
 
index 677877ca62f22b5eed0c2160c6b55af6c03cfffb..14eb3750e3654b4de523160b84acbf8440305057 100644 (file)
@@ -152,7 +152,7 @@ static struct tevent_req *smbd_smb2_flush_send(TALLOC_CTX *mem_ctx,
                bool allow_dir_flush = false;
                uint32_t flush_access = FILE_ADD_FILE | FILE_ADD_SUBDIRECTORY;
 
                bool allow_dir_flush = false;
                uint32_t flush_access = FILE_ADD_FILE | FILE_ADD_SUBDIRECTORY;
 
-               if (!fsp->is_directory) {
+               if (!fsp->fsp_flags.is_directory) {
                        tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
                        return tevent_req_post(req, ev);
                }
                        tevent_req_nterror(req, NT_STATUS_ACCESS_DENIED);
                        return tevent_req_post(req, ev);
                }
index 68429b7b766a324f61ac45047aec6d238a81a2e7..200a6e85d9a09a3a3bbc8f79b55e5db6747c8028 100644 (file)
@@ -255,7 +255,7 @@ static struct tevent_req *smbd_smb2_notify_send(TALLOC_CTX *mem_ctx,
                TALLOC_FREE(filter_string);
        }
 
                TALLOC_FREE(filter_string);
        }
 
-       if ((!fsp->is_directory) || (conn != fsp->conn)) {
+       if ((!fsp->fsp_flags.is_directory) || (conn != fsp->conn)) {
                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return tevent_req_post(req, ev);
        }
                tevent_req_nterror(req, NT_STATUS_INVALID_PARAMETER);
                return tevent_req_post(req, ev);
        }
index 1c7d4e91c9730a94dae4c0db9f987f20230d96f2..28c4b51fbf9c1db931e1989b72b1d94c64f7f566 100644 (file)
@@ -293,7 +293,7 @@ static struct tevent_req *smbd_smb2_query_directory_send(TALLOC_CTX *mem_ctx,
                return tevent_req_post(req, ev);
        }
 
                return tevent_req_post(req, ev);
        }
 
-       if (!fsp->is_directory) {
+       if (!fsp->fsp_flags.is_directory) {
                tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
                return tevent_req_post(req, ev);
        }
                tevent_req_nterror(req, NT_STATUS_NOT_SUPPORTED);
                return tevent_req_post(req, ev);
        }
index e84584349ab9aa8c56becb1059d2605bd02cd6f8..3441ac27c0c33d50696407290ab73b1c3e229373 100644 (file)
@@ -475,7 +475,7 @@ static struct tevent_req *smbd_smb2_read_send(TALLOC_CTX *mem_ctx,
        }
        state->smbreq = smbreq;
 
        }
        state->smbreq = smbreq;
 
-       if (fsp->is_directory) {
+       if (fsp->fsp_flags.is_directory) {
                tevent_req_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
                return tevent_req_post(req, ev);
        }
                tevent_req_nterror(req, NT_STATUS_INVALID_DEVICE_REQUEST);
                return tevent_req_post(req, ev);
        }
index 380b276e759061d90fbdf6b2e3d2a4ccf845ed5b..19706d32bd5d24b4b85aae3a26066a40c79ef273 100644 (file)
@@ -5003,7 +5003,7 @@ static NTSTATUS smb_query_posix_acl(connection_struct *conn,
                 * We can only have default POSIX ACLs on
                 * directories.
                 */
                 * We can only have default POSIX ACLs on
                 * directories.
                 */
-               if (!fsp->is_directory) {
+               if (!fsp->fsp_flags.is_directory) {
                        DBG_INFO("Non-directory open %s\n",
                                fsp_str_dbg(fsp));
                        status = NT_STATUS_INVALID_HANDLE;
                        DBG_INFO("Non-directory open %s\n",
                                fsp_str_dbg(fsp));
                        status = NT_STATUS_INVALID_HANDLE;
@@ -7598,7 +7598,7 @@ static NTSTATUS smb_set_posix_acl(connection_struct *conn,
        }
 
        /* If we have a default acl, this *must* be a directory. */
        }
 
        /* If we have a default acl, this *must* be a directory. */
-       if (valid_def_acls && !fsp->is_directory) {
+       if (valid_def_acls && !fsp->fsp_flags.is_directory) {
                DBG_INFO("Can't set default acls on "
                         "non-directory %s\n",
                         fsp_str_dbg(fsp));
                DBG_INFO("Can't set default acls on "
                         "non-directory %s\n",
                         fsp_str_dbg(fsp));
index e66f5d44d969594c3559bc2113db41b1f98f3ca4..263f4da2660e693a78ab7541feeda58e5eb2b71f 100644 (file)
@@ -428,7 +428,7 @@ static NTSTATUS cmd_open(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int argc, c
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
-       fsp->is_directory = False;
+       fsp->fsp_flags.is_directory = false;
 
        vfs->files[fsp->fh->fd] = fsp;
        printf("open: fd=%d\n", fsp->fh->fd);
 
        vfs->files[fsp->fh->fd] = fsp;
        printf("open: fd=%d\n", fsp->fh->fd);
@@ -1656,8 +1656,7 @@ static NTSTATUS cmd_set_nt_acl(struct vfs_state *vfs, TALLOC_CTX *mem_ctx, int a
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
        fsp->print_file = NULL;
        fsp->fsp_flags.modified = false;
        fsp->sent_oplock_break = NO_BREAK_SENT;
-       fsp->is_directory = S_ISDIR(smb_fname->st.st_ex_mode);
-
+       fsp->fsp_flags.is_directory = S_ISDIR(smb_fname->st.st_ex_mode);
 
        sd = sddl_decode(talloc_tos(), argv[2], get_global_sam_sid());
        if (!sd) {
 
        sd = sddl_decode(talloc_tos(), argv[2], get_global_sam_sid());
        if (!sd) {