s3: vfs: add SMB_VFS_GET_DOS_ATTRIBUTES_SEND/RECV
authorRalph Boehme <slow@samba.org>
Thu, 15 Mar 2018 12:08:55 +0000 (13:08 +0100)
committerRalph Boehme <slow@samba.org>
Fri, 27 Jul 2018 11:07:14 +0000 (13:07 +0200)
Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
13 files changed:
examples/VFS/skel_opaque.c
examples/VFS/skel_transparent.c
source3/include/vfs.h
source3/include/vfs_macros.h
source3/modules/vfs_catia.c
source3/modules/vfs_default.c
source3/modules/vfs_full_audit.c
source3/modules/vfs_gpfs.c
source3/modules/vfs_not_implemented.c
source3/modules/vfs_offline.c
source3/modules/vfs_time_audit.c
source3/modules/vfs_tsmsm.c
source3/smbd/vfs.c

index 971303436b01e9cc8ceaaeddd697b00a59549bef..054de50197e3bb754a7034c2234a0f63fd465893 100644 (file)
@@ -707,6 +707,52 @@ static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
        return NT_STATUS_NOT_IMPLEMENTED;
 }
 
+struct skel_get_dos_attributes_state {
+       struct vfs_aio_state aio_state;
+       uint32_t dosmode;
+};
+
+static struct tevent_req *skel_get_dos_attributes_send(
+                       TALLOC_CTX *mem_ctx,
+                       const struct smb_vfs_ev_glue *evg,
+                       struct vfs_handle_struct *handle,
+                       files_struct *dir_fsp,
+                       struct smb_filename *smb_fname)
+{
+       struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
+       struct tevent_req *req = NULL;
+       struct skel_get_dos_attributes_state *state = NULL;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct skel_get_dos_attributes_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
+       return tevent_req_post(req, ev);
+}
+
+static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
+                                            struct vfs_aio_state *aio_state,
+                                            uint32_t *dosmode)
+{
+       struct skel_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct skel_get_dos_attributes_state);
+       NTSTATUS status;
+
+       if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
+               return status;
+       }
+
+       *aio_state = state->aio_state;
+       *dosmode = state->dosmode;
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
                                struct files_struct *fsp,
                                uint32_t *dosmode)
@@ -1069,6 +1115,8 @@ static struct vfs_fn_pointers skel_opaque_fns = {
 
        /* DOS attributes. */
        .get_dos_attributes_fn = skel_get_dos_attributes,
+       .get_dos_attributes_send_fn = skel_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
        .fget_dos_attributes_fn = skel_fget_dos_attributes,
        .set_dos_attributes_fn = skel_set_dos_attributes,
        .fset_dos_attributes_fn = skel_fset_dos_attributes,
index 503c14edcc0ab25a42176a357dd7f6e4be3cdce1..cff52fa185ef66d9711cd09ea1ea75ded7da9738 100644 (file)
@@ -886,6 +886,86 @@ static NTSTATUS skel_get_dos_attributes(struct vfs_handle_struct *handle,
                                dosmode);
 }
 
+struct skel_get_dos_attributes_state {
+       struct vfs_aio_state aio_state;
+       uint32_t dosmode;
+};
+
+static void skel_get_dos_attributes_done(struct tevent_req *subreq);
+
+static struct tevent_req *skel_get_dos_attributes_send(
+                       TALLOC_CTX *mem_ctx,
+                       const struct smb_vfs_ev_glue *evg,
+                       struct vfs_handle_struct *handle,
+                       files_struct *dir_fsp,
+                       struct smb_filename *smb_fname)
+{
+       struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
+       struct tevent_req *req = NULL;
+       struct skel_get_dos_attributes_state *state = NULL;
+       struct tevent_req *subreq = NULL;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct skel_get_dos_attributes_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
+                                                     evg,
+                                                     handle,
+                                                     dir_fsp,
+                                                     smb_fname);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq, skel_get_dos_attributes_done, req);
+
+       return req;
+}
+
+static void skel_get_dos_attributes_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req =
+               tevent_req_callback_data(subreq,
+               struct tevent_req);
+       struct skel_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct skel_get_dos_attributes_state);
+       NTSTATUS status;
+
+       status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
+                                                     &state->aio_state,
+                                                     &state->dosmode);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+
+       tevent_req_done(req);
+       return;
+}
+
+static NTSTATUS skel_get_dos_attributes_recv(struct tevent_req *req,
+                                            struct vfs_aio_state *aio_state,
+                                            uint32_t *dosmode)
+{
+       struct skel_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct skel_get_dos_attributes_state);
+       NTSTATUS status;
+
+       if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
+               return status;
+       }
+
+       *aio_state = state->aio_state;
+       *dosmode = state->dosmode;
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
 static NTSTATUS skel_fget_dos_attributes(struct vfs_handle_struct *handle,
                                struct files_struct *fsp,
                                uint32_t *dosmode)
@@ -1298,6 +1378,8 @@ static struct vfs_fn_pointers skel_transparent_fns = {
 
        /* DOS attributes. */
        .get_dos_attributes_fn = skel_get_dos_attributes,
+       .get_dos_attributes_send_fn = skel_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = skel_get_dos_attributes_recv,
        .fget_dos_attributes_fn = skel_fget_dos_attributes,
        .set_dos_attributes_fn = skel_set_dos_attributes,
        .fset_dos_attributes_fn = skel_fset_dos_attributes,
index def802c9772b78c59d276ed152225c1de09ec3a5..4f3db69489640486fefe5e0200e81f12b0322fb5 100644 (file)
 /* Version 40 - Introduce smb_vfs_ev_glue infrastructure. */
 /* Version 40 - Add vfs_not_implemented_* helper functions. */
 /* Version 40 - Add SMB_VFS_GETXATTRAT_SEND/RECV */
+/* Version 40 - Add SMB_VFS_GET_DOS_ATTRIBUTES_SEND/RECV */
 
 #define SMB_VFS_INTERFACE_VERSION 40
 
@@ -900,6 +901,18 @@ struct vfs_fn_pointers {
                                           struct files_struct *fsp,
                                           uint32_t dosmode);
 
+       struct tevent_req *(*get_dos_attributes_send_fn)(
+                               TALLOC_CTX *mem_ctx,
+                               const struct smb_vfs_ev_glue *evg,
+                               struct vfs_handle_struct *handle,
+                               files_struct *dir_fsp,
+                               struct smb_filename *smb_fname);
+
+       NTSTATUS (*get_dos_attributes_recv_fn)(
+                               struct tevent_req *req,
+                               struct vfs_aio_state *aio_state,
+                               uint32_t *dosmode);
+
        /* NT ACL operations. */
 
        NTSTATUS (*fget_nt_acl_fn)(struct vfs_handle_struct *handle,
@@ -1355,6 +1368,16 @@ NTSTATUS smb_vfs_call_set_dos_attributes(struct vfs_handle_struct *handle,
 NTSTATUS smb_vfs_call_fset_dos_attributes(struct vfs_handle_struct *handle,
                                          struct files_struct *fsp,
                                          uint32_t dosmode);
+struct tevent_req *smb_vfs_call_get_dos_attributes_send(
+                       TALLOC_CTX *mem_ctx,
+                       const struct smb_vfs_ev_glue *evg,
+                       struct vfs_handle_struct *handle,
+                       files_struct *dir_fsp,
+                       struct smb_filename *smb_fname);
+NTSTATUS smb_vfs_call_get_dos_attributes_recv(
+                       struct tevent_req *req,
+                       struct vfs_aio_state *aio_state,
+                       uint32_t *dosmode);
 struct tevent_req *smb_vfs_call_offload_read_send(
        TALLOC_CTX *mem_ctx,
        struct tevent_context *ev,
@@ -1827,6 +1850,16 @@ NTSTATUS vfs_not_implemented_readdir_attr(struct vfs_handle_struct *handle,
 NTSTATUS vfs_not_implemented_get_dos_attributes(struct vfs_handle_struct *handle,
                                                struct smb_filename *smb_fname,
                                                uint32_t *dosmode);
+struct tevent_req *vfs_not_implemented_get_dos_attributes_send(
+                       TALLOC_CTX *mem_ctx,
+                       const struct smb_vfs_ev_glue *evg,
+                       struct vfs_handle_struct *handle,
+                       files_struct *dir_fsp,
+                       struct smb_filename *smb_fname);
+NTSTATUS vfs_not_implemented_get_dos_attributes_recv(
+                       struct tevent_req *req,
+                       struct vfs_aio_state *aio_state,
+                       uint32_t *dosmode);
 NTSTATUS vfs_not_implemented_fget_dos_attributes(struct vfs_handle_struct *handle,
                                                 struct files_struct *fsp,
                                                 uint32_t *dosmode);
index d4863536cc22a3a8625e2b036c7f066a2851377a..a13680c239e23baa02dbbeab97df92a3274e57cf 100644 (file)
 #define SMB_VFS_NEXT_FGET_DOS_ATTRIBUTES(handle, fsp, attributes) \
        smb_vfs_call_fget_dos_attributes((handle)->next, (fsp), (attributes))
 
+#define SMB_VFS_GET_DOS_ATTRIBUTES_SEND(mem_ctx, evg, dir_fsp, smb_fname) \
+       smb_vfs_call_get_dos_attributes_send((mem_ctx), (evg), \
+                                            (dir_fsp)->conn->vfs_handles, \
+                                            (dir_fsp), (smb_fname))
+#define SMB_VFS_GET_DOS_ATTRIBUTES_RECV(req, aio_state, dosmode) \
+       smb_vfs_call_get_dos_attributes_recv((req), (aio_state), (dosmode))
+
+#define SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx, evg, handle, dir_fsp, \
+                                            smb_fname) \
+       smb_vfs_call_get_dos_attributes_send((mem_ctx), (evg), \
+                                            (handle)->next, \
+                                            (dir_fsp), (smb_fname))
+#define SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(req, aio_state, dosmode) \
+       smb_vfs_call_get_dos_attributes_recv((req), (aio_state), (dosmode))
+
 #define SMB_VFS_SET_DOS_ATTRIBUTES(conn, smb_fname, attributes) \
        smb_vfs_call_set_dos_attributes((conn)->vfs_handles, (smb_fname), (attributes))
 #define SMB_VFS_NEXT_SET_DOS_ATTRIBUTES(handle, smb_fname, attributes) \
index d2dddaf692136a7c6500251e89610088ca3499ee..12995dda9bfaf87933972d40b9f1804a679223c9 100644 (file)
@@ -2447,6 +2447,8 @@ static struct vfs_fn_pointers vfs_catia_fns = {
        .translate_name_fn = catia_translate_name,
        .fsctl_fn = catia_fsctl,
        .get_dos_attributes_fn = catia_get_dos_attributes,
+       .get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
        .set_dos_attributes_fn = catia_set_dos_attributes,
        .fset_dos_attributes_fn = catia_fset_dos_attributes,
        .fget_dos_attributes_fn = catia_fget_dos_attributes,
index 0523644ac983b86e9b8c3ae7189682de8d6e9f82..81c707d15ecb65eb1ca5b1105ab9fe87e33dd2cc 100644 (file)
@@ -3164,6 +3164,8 @@ static struct vfs_fn_pointers vfs_default_fns = {
        .set_dos_attributes_fn = vfswrap_set_dos_attributes,
        .fset_dos_attributes_fn = vfswrap_fset_dos_attributes,
        .get_dos_attributes_fn = vfswrap_get_dos_attributes,
+       .get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
        .fget_dos_attributes_fn = vfswrap_fget_dos_attributes,
        .offload_read_send_fn = vfswrap_offload_read_send,
        .offload_read_recv_fn = vfswrap_offload_read_recv,
index f28413b83c28d6fe5d5c3dfe7ce0bebb927a0ce5..0fbf9ecafe32a27557c19344a5400b45bee21139 100644 (file)
@@ -69,6 +69,7 @@
 #include "lib/util/tevent_unix.h"
 #include "libcli/security/sddl.h"
 #include "passdb/machine_sid.h"
+#include "lib/util/tevent_ntstatus.h"
 
 static int vfs_full_audit_debug_level = DBGC_VFS;
 
@@ -178,6 +179,8 @@ typedef enum _vfs_op_type {
 
        /* DOS attribute operations. */
        SMB_VFS_OP_GET_DOS_ATTRIBUTES,
+       SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
+       SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV,
        SMB_VFS_OP_FGET_DOS_ATTRIBUTES,
        SMB_VFS_OP_SET_DOS_ATTRIBUTES,
        SMB_VFS_OP_FSET_DOS_ATTRIBUTES,
@@ -317,6 +320,8 @@ static struct {
        { SMB_VFS_OP_SNAP_CREATE, "snap_create" },
        { SMB_VFS_OP_SNAP_DELETE, "snap_delete" },
        { SMB_VFS_OP_GET_DOS_ATTRIBUTES, "get_dos_attributes" },
+       { SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND, "get_dos_attributes_send" },
+       { SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV, "get_dos_attributes_recv" },
        { SMB_VFS_OP_FGET_DOS_ATTRIBUTES, "fget_dos_attributes" },
        { SMB_VFS_OP_SET_DOS_ATTRIBUTES, "set_dos_attributes" },
        { SMB_VFS_OP_FSET_DOS_ATTRIBUTES, "fset_dos_attributes" },
@@ -2064,6 +2069,128 @@ static NTSTATUS smb_full_audit_get_dos_attributes(
        return status;
 }
 
+struct smb_full_audit_get_dos_attributes_state {
+       struct vfs_aio_state aio_state;
+       vfs_handle_struct *handle;
+       files_struct *dir_fsp;
+       const struct smb_filename *smb_fname;
+       uint32_t dosmode;
+};
+
+static void smb_full_audit_get_dos_attributes_done(struct tevent_req *subreq);
+
+static struct tevent_req *smb_full_audit_get_dos_attributes_send(
+               TALLOC_CTX *mem_ctx,
+               const struct smb_vfs_ev_glue *evg,
+               struct vfs_handle_struct *handle,
+               files_struct *dir_fsp,
+               struct smb_filename *smb_fname)
+{
+       struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
+       struct tevent_req *req = NULL;
+       struct smb_full_audit_get_dos_attributes_state *state = NULL;
+       struct tevent_req *subreq = NULL;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct smb_full_audit_get_dos_attributes_state);
+       if (req == NULL) {
+               do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
+                      false,
+                      handle,
+                      "%s/%s",
+                      fsp_str_do_log(dir_fsp),
+                      smb_fname->base_name);
+               return NULL;
+       }
+       *state = (struct smb_full_audit_get_dos_attributes_state) {
+               .handle = handle,
+               .dir_fsp = dir_fsp,
+               .smb_fname = smb_fname,
+       };
+
+       subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
+                                                     evg,
+                                                     handle,
+                                                     dir_fsp,
+                                                     smb_fname);
+       if (tevent_req_nomem(subreq, req)) {
+               do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
+                      false,
+                      handle,
+                      "%s/%s",
+                      fsp_str_do_log(dir_fsp),
+                      smb_fname->base_name);
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq,
+                               smb_full_audit_get_dos_attributes_done,
+                               req);
+
+       do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_SEND,
+              true,
+              handle,
+              "%s/%s",
+              fsp_str_do_log(dir_fsp),
+              smb_fname->base_name);
+
+       return req;
+}
+
+static void smb_full_audit_get_dos_attributes_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req =
+               tevent_req_callback_data(subreq,
+               struct tevent_req);
+       struct smb_full_audit_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct smb_full_audit_get_dos_attributes_state);
+       NTSTATUS status;
+
+       status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
+                                                     &state->aio_state,
+                                                     &state->dosmode);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+
+       tevent_req_done(req);
+       return;
+}
+
+static NTSTATUS smb_full_audit_get_dos_attributes_recv(struct tevent_req *req,
+                                               struct vfs_aio_state *aio_state,
+                                               uint32_t *dosmode)
+{
+       struct smb_full_audit_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct smb_full_audit_get_dos_attributes_state);
+       NTSTATUS status;
+
+       if (tevent_req_is_nterror(req, &status)) {
+               do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV,
+                      false,
+                      state->handle,
+                      "%s/%s",
+                      fsp_str_do_log(state->dir_fsp),
+                      state->smb_fname->base_name);
+               tevent_req_received(req);
+               return status;
+       }
+
+       do_log(SMB_VFS_OP_GET_DOS_ATTRIBUTES_RECV,
+              true,
+              state->handle,
+              "%s/%s",
+              fsp_str_do_log(state->dir_fsp),
+              state->smb_fname->base_name);
+
+       *aio_state = state->aio_state;
+       *dosmode = state->dosmode;
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
 static NTSTATUS smb_full_audit_fget_dos_attributes(
                                struct vfs_handle_struct *handle,
                                struct files_struct *fsp,
@@ -2716,6 +2843,8 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
        .translate_name_fn = smb_full_audit_translate_name,
        .fsctl_fn = smb_full_audit_fsctl,
        .get_dos_attributes_fn = smb_full_audit_get_dos_attributes,
+       .get_dos_attributes_send_fn = smb_full_audit_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = smb_full_audit_get_dos_attributes_recv,
        .fget_dos_attributes_fn = smb_full_audit_fget_dos_attributes,
        .set_dos_attributes_fn = smb_full_audit_set_dos_attributes,
        .fset_dos_attributes_fn = smb_full_audit_fset_dos_attributes,
index d733df0aa5cf71289d4fd0b89e196b136bc8cf0d..5f21bc0826d5db49643cf6f7f34becbc3d226acf 100644 (file)
@@ -2561,6 +2561,8 @@ static struct vfs_fn_pointers vfs_gpfs_fns = {
        .linux_setlease_fn = vfs_gpfs_setlease,
        .get_real_filename_fn = vfs_gpfs_get_real_filename,
        .get_dos_attributes_fn = vfs_gpfs_get_dos_attributes,
+       .get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
        .fget_dos_attributes_fn = vfs_gpfs_fget_dos_attributes,
        .set_dos_attributes_fn = vfs_gpfs_set_dos_attributes,
        .fset_dos_attributes_fn = vfs_gpfs_fset_dos_attributes,
index bb4854d8bf8cf5ca27ff4c5a0dde418b67d18bf2..e20b7eb76ed96e3cd13d7e051141c1fe70c63379 100644 (file)
@@ -710,6 +710,53 @@ NTSTATUS vfs_not_implemented_get_dos_attributes(struct vfs_handle_struct *handle
        return NT_STATUS_NOT_IMPLEMENTED;
 }
 
+struct vfs_not_implemented_get_dos_attributes_state {
+       struct vfs_aio_state aio_state;
+       uint32_t dosmode;
+};
+
+struct tevent_req *vfs_not_implemented_get_dos_attributes_send(
+                       TALLOC_CTX *mem_ctx,
+                       const struct smb_vfs_ev_glue *evg,
+                       struct vfs_handle_struct *handle,
+                       files_struct *dir_fsp,
+                       struct smb_filename *smb_fname)
+{
+       struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
+       struct tevent_req *req = NULL;
+       struct vfs_not_implemented_get_dos_attributes_state *state = NULL;
+
+       req = tevent_req_create(mem_ctx, &state,
+                       struct vfs_not_implemented_get_dos_attributes_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       tevent_req_nterror(req, NT_STATUS_NOT_IMPLEMENTED);
+       return tevent_req_post(req, ev);
+}
+
+NTSTATUS vfs_not_implemented_get_dos_attributes_recv(
+                       struct tevent_req *req,
+                       struct vfs_aio_state *aio_state,
+                       uint32_t *dosmode)
+{
+       struct vfs_not_implemented_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct vfs_not_implemented_get_dos_attributes_state);
+       NTSTATUS status;
+
+       if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
+               return status;
+       }
+
+       *aio_state = state->aio_state;
+       *dosmode = state->dosmode;
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
 NTSTATUS vfs_not_implemented_fget_dos_attributes(struct vfs_handle_struct *handle,
                                                 struct files_struct *fsp,
                                                 uint32_t *dosmode)
@@ -1072,6 +1119,8 @@ static struct vfs_fn_pointers vfs_not_implemented_fns = {
 
        /* DOS attributes. */
        .get_dos_attributes_fn = vfs_not_implemented_get_dos_attributes,
+       .get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
        .fget_dos_attributes_fn = vfs_not_implemented_fget_dos_attributes,
        .set_dos_attributes_fn = vfs_not_implemented_set_dos_attributes,
        .fset_dos_attributes_fn = vfs_not_implemented_fset_dos_attributes,
index d70fad4c042407b067f7e912381c2ca6a3e982cf..0a7e8af469c909dd1b5feaeda9701e7378c3f0a0 100644 (file)
@@ -46,6 +46,8 @@ static NTSTATUS offline_fget_dos_attributes(struct vfs_handle_struct *handle,
 static struct vfs_fn_pointers offline_fns = {
     .fs_capabilities_fn = offline_fs_capabilities,
        .get_dos_attributes_fn = offline_get_dos_attributes,
+       .get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
        .fget_dos_attributes_fn = offline_fget_dos_attributes,
 };
 
index 07c14415312fb6a13d89b36dcad0448046b82047..64e1f5d4d13cbb1e8388319de542dd750e279759 100644 (file)
@@ -1757,6 +1757,104 @@ static NTSTATUS smb_time_get_dos_attributes(struct vfs_handle_struct *handle,
        return result;
 }
 
+struct smb_time_audit_get_dos_attributes_state {
+       struct vfs_aio_state aio_state;
+       files_struct *dir_fsp;
+       const struct smb_filename *smb_fname;
+       uint32_t dosmode;
+};
+
+static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq);
+
+static struct tevent_req *smb_time_audit_get_dos_attributes_send(
+                       TALLOC_CTX *mem_ctx,
+                       const struct smb_vfs_ev_glue *evg,
+                       struct vfs_handle_struct *handle,
+                       files_struct *dir_fsp,
+                       struct smb_filename *smb_fname)
+{
+       struct tevent_context *ev = smb_vfs_ev_glue_ev_ctx(evg);
+       struct tevent_req *req = NULL;
+       struct smb_time_audit_get_dos_attributes_state *state = NULL;
+       struct tevent_req *subreq = NULL;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct smb_time_audit_get_dos_attributes_state);
+       if (req == NULL) {
+               return NULL;
+       }
+       *state = (struct smb_time_audit_get_dos_attributes_state) {
+               .dir_fsp = dir_fsp,
+               .smb_fname = smb_fname,
+       };
+
+       subreq = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_SEND(mem_ctx,
+                                                     evg,
+                                                     handle,
+                                                     dir_fsp,
+                                                     smb_fname);
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, ev);
+       }
+       tevent_req_set_callback(subreq,
+                               smb_time_audit_get_dos_attributes_done,
+                               req);
+
+       return req;
+}
+
+static void smb_time_audit_get_dos_attributes_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req =
+               tevent_req_callback_data(subreq,
+               struct tevent_req);
+       struct smb_time_audit_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct smb_time_audit_get_dos_attributes_state);
+       NTSTATUS status;
+
+       status = SMB_VFS_NEXT_GET_DOS_ATTRIBUTES_RECV(subreq,
+                                                     &state->aio_state,
+                                                     &state->dosmode);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+
+       tevent_req_done(req);
+       return;
+}
+
+static NTSTATUS smb_time_audit_get_dos_attributes_recv(struct tevent_req *req,
+                                               struct vfs_aio_state *aio_state,
+                                               uint32_t *dosmode)
+{
+       struct smb_time_audit_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct smb_time_audit_get_dos_attributes_state);
+       NTSTATUS status;
+       double timediff;
+
+       timediff = state->aio_state.duration * 1.0e-9;
+
+       if (timediff > audit_timeout) {
+               smb_time_audit_log_at("async get_dos_attributes",
+                                     timediff,
+                                     state->dir_fsp,
+                                     state->smb_fname);
+       }
+
+       if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
+               return status;
+       }
+
+       *aio_state = state->aio_state;
+       *dosmode = state->dosmode;
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
 static NTSTATUS smb_time_fget_dos_attributes(struct vfs_handle_struct *handle,
                                        struct files_struct *fsp,
                                        uint32_t *dosmode)
@@ -2774,6 +2872,8 @@ static struct vfs_fn_pointers vfs_time_audit_fns = {
        .translate_name_fn = smb_time_audit_translate_name,
        .fsctl_fn = smb_time_audit_fsctl,
        .get_dos_attributes_fn = smb_time_get_dos_attributes,
+       .get_dos_attributes_send_fn = smb_time_audit_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = smb_time_audit_get_dos_attributes_recv,
        .fget_dos_attributes_fn = smb_time_fget_dos_attributes,
        .set_dos_attributes_fn = smb_time_set_dos_attributes,
        .fset_dos_attributes_fn = smb_time_fset_dos_attributes,
index 99d11a53f9dfa75c58d16b10fe65478be518de9d..85a9bfdfa9c0bb4a0d7082debe3d646e34b6c864 100644 (file)
@@ -605,6 +605,8 @@ static struct vfs_fn_pointers tsmsm_fns = {
        .set_dos_attributes_fn = tsmsm_set_dos_attributes,
        .fset_dos_attributes_fn = tsmsm_fset_dos_attributes,
        .get_dos_attributes_fn = tsmsm_get_dos_attributes,
+       .get_dos_attributes_send_fn = vfs_not_implemented_get_dos_attributes_send,
+       .get_dos_attributes_recv_fn = vfs_not_implemented_get_dos_attributes_recv,
        .fget_dos_attributes_fn = tsmsm_fget_dos_attributes,
 };
 
index 501eafe1c02853506c97e89a216dc7b62a7255ae..2687e3540b89e916b05d942fa606fe88db68ba4b 100644 (file)
@@ -31,6 +31,7 @@
 #include "transfer_file.h"
 #include "ntioctl.h"
 #include "lib/util/tevent_unix.h"
+#include "lib/util/tevent_ntstatus.h"
 
 #undef DBGC_CLASS
 #define DBGC_CLASS DBGC_VFS
@@ -3250,6 +3251,102 @@ NTSTATUS smb_vfs_call_offload_write_recv(struct vfs_handle_struct *handle,
        return handle->fns->offload_write_recv_fn(handle, req, copied);
 }
 
+struct smb_vfs_call_get_dos_attributes_state {
+       NTSTATUS (*recv_fn)(struct tevent_req *req,
+                           struct vfs_aio_state *aio_state,
+                           uint32_t *dosmode);
+       struct vfs_aio_state aio_state;
+       uint32_t dos_attributes;
+};
+
+static void smb_vfs_call_get_dos_attributes_done(struct tevent_req *subreq);
+
+struct tevent_req *smb_vfs_call_get_dos_attributes_send(
+                       TALLOC_CTX *mem_ctx,
+                       const struct smb_vfs_ev_glue *evg,
+                       struct vfs_handle_struct *handle,
+                       files_struct *dir_fsp,
+                       struct smb_filename *smb_fname)
+{
+       struct tevent_req *req = NULL;
+       struct smb_vfs_call_get_dos_attributes_state *state = NULL;
+       struct tevent_req *subreq = NULL;
+       bool ok;
+
+       req = tevent_req_create(mem_ctx, &state,
+                               struct smb_vfs_call_get_dos_attributes_state);
+       if (req == NULL) {
+               return NULL;
+       }
+
+       VFS_FIND(get_dos_attributes_send);
+       state->recv_fn = handle->fns->get_dos_attributes_recv_fn;
+
+       ok = smb_vfs_ev_glue_push_use(evg, req);
+       if (!ok) {
+               tevent_req_error(req, EIO);
+               return tevent_req_post(req, evg->return_ev);
+       }
+
+       subreq = handle->fns->get_dos_attributes_send_fn(mem_ctx,
+                                                        evg->next_glue,
+                                                        handle,
+                                                        dir_fsp,
+                                                        smb_fname);
+       smb_vfs_ev_glue_pop_use(evg);
+
+       if (tevent_req_nomem(subreq, req)) {
+               return tevent_req_post(req, evg->return_ev);
+       }
+       tevent_req_set_callback(subreq,
+                               smb_vfs_call_get_dos_attributes_done,
+                               req);
+
+       return req;
+}
+
+static void smb_vfs_call_get_dos_attributes_done(struct tevent_req *subreq)
+{
+       struct tevent_req *req =
+               tevent_req_callback_data(subreq,
+               struct tevent_req);
+       struct smb_vfs_call_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct smb_vfs_call_get_dos_attributes_state);
+       NTSTATUS status;
+
+       status = state->recv_fn(subreq,
+                               &state->aio_state,
+                               &state->dos_attributes);
+       TALLOC_FREE(subreq);
+       if (tevent_req_nterror(req, status)) {
+               return;
+       }
+
+       tevent_req_done(req);
+}
+
+NTSTATUS smb_vfs_call_get_dos_attributes_recv(
+               struct tevent_req *req,
+               struct vfs_aio_state *aio_state,
+               uint32_t *dos_attributes)
+{
+       struct smb_vfs_call_get_dos_attributes_state *state =
+               tevent_req_data(req,
+               struct smb_vfs_call_get_dos_attributes_state);
+       NTSTATUS status;
+
+       if (tevent_req_is_nterror(req, &status)) {
+               tevent_req_received(req);
+               return status;
+       }
+
+       *aio_state = state->aio_state;
+       *dos_attributes = state->dos_attributes;
+       tevent_req_received(req);
+       return NT_STATUS_OK;
+}
+
 NTSTATUS smb_vfs_call_get_compression(vfs_handle_struct *handle,
                                      TALLOC_CTX *mem_ctx,
                                      struct files_struct *fsp,