s3: VFS: Change SMB_VFS_SYS_ACL_BLOB_GET_FILE to use const struct smb_filename *...
[samba.git] / source3 / modules / vfs_full_audit.c
index dd1593923b864d7557628a37a3518d90013eecec..6d281d88c901fbf497885bd63ba1bcbd4494e48c 100644 (file)
@@ -219,12 +219,10 @@ typedef enum _vfs_op_type {
        SMB_VFS_OP_IS_OFFLINE,
        SMB_VFS_OP_SET_OFFLINE,
 
-       /* Durable handle operations */
-       /* Missing:
-               durable_cookie
-               durable_disconnect
-               durable_reconnect
-       */
+       /* Durable handle operations. */
+       SMB_VFS_OP_DURABLE_COOKIE,
+       SMB_VFS_OP_DURABLE_DISCONNECT,
+       SMB_VFS_OP_DURABLE_RECONNECT,
 
        SMB_VFS_OP_READDIR_ATTR,
 
@@ -347,11 +345,9 @@ static struct {
        { SMB_VFS_OP_AIO_FORCE, "aio_force" },
        { SMB_VFS_OP_IS_OFFLINE, "is_offline" },
        { SMB_VFS_OP_SET_OFFLINE, "set_offline" },
-       /* Missing:
-               durable_cookie
-               durable_disconnect
-               durable_reconnect
-       */
+       { SMB_VFS_OP_DURABLE_COOKIE, "durable_cookie" },
+       { SMB_VFS_OP_DURABLE_DISCONNECT, "durable_disconnect" },
+       { SMB_VFS_OP_DURABLE_RECONNECT, "durable_reconnect" },
        { SMB_VFS_OP_READDIR_ATTR,      "readdir_attr" },
        { SMB_VFS_OP_LAST, NULL }
 };
@@ -1893,12 +1889,14 @@ static struct tevent_req *smb_full_audit_copy_chunk_send(struct vfs_handle_struc
                                                         off_t src_off,
                                                         struct files_struct *dest_fsp,
                                                         off_t dest_off,
-                                                        off_t num)
+                                                        off_t num,
+                                                        uint32_t flags)
 {
        struct tevent_req *req;
 
        req = SMB_VFS_NEXT_COPY_CHUNK_SEND(handle, mem_ctx, ev, src_fsp,
-                                          src_off, dest_fsp, dest_off, num);
+                                          src_off, dest_fsp, dest_off, num,
+                                          flags);
 
        do_log(SMB_VFS_OP_COPY_CHUNK_SEND, req, handle, "");
 
@@ -2154,16 +2152,17 @@ static int smb_full_audit_fchmod_acl(vfs_handle_struct *handle, files_struct *fs
 }
 
 static SMB_ACL_T smb_full_audit_sys_acl_get_file(vfs_handle_struct *handle,
-                                       const char *path_p,
-                                                SMB_ACL_TYPE_T type,
-                                                TALLOC_CTX *mem_ctx)
+                               const struct smb_filename *smb_fname,
+                               SMB_ACL_TYPE_T type,
+                               TALLOC_CTX *mem_ctx)
 {
        SMB_ACL_T result;
 
-       result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, path_p, type, mem_ctx);
+       result = SMB_VFS_NEXT_SYS_ACL_GET_FILE(handle, smb_fname,
+                               type, mem_ctx);
 
        do_log(SMB_VFS_OP_SYS_ACL_GET_FILE, (result != NULL), handle,
-              "%s", path_p);
+              "%s", smb_fname->base_name);
 
        return result;
 }
@@ -2182,17 +2181,18 @@ static SMB_ACL_T smb_full_audit_sys_acl_get_fd(vfs_handle_struct *handle,
 }
 
 static int smb_full_audit_sys_acl_blob_get_file(vfs_handle_struct *handle,
-                                               const char *path_p,
-                                               TALLOC_CTX *mem_ctx,
-                                               char **blob_description,
-                                               DATA_BLOB *blob)
+                               const struct smb_filename *smb_fname,
+                               TALLOC_CTX *mem_ctx,
+                               char **blob_description,
+                               DATA_BLOB *blob)
 {
        int result;
 
-       result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, path_p, mem_ctx, blob_description, blob);
+       result = SMB_VFS_NEXT_SYS_ACL_BLOB_GET_FILE(handle, smb_fname,
+                       mem_ctx, blob_description, blob);
 
        do_log(SMB_VFS_OP_SYS_ACL_BLOB_GET_FILE, (result >= 0), handle,
-              "%s", path_p);
+              "%s", smb_fname->base_name);
 
        return result;
 }
@@ -2243,15 +2243,14 @@ static int smb_full_audit_sys_acl_set_fd(vfs_handle_struct *handle, files_struct
 }
 
 static int smb_full_audit_sys_acl_delete_def_file(vfs_handle_struct *handle,
-
-                                        const char *path)
+                               const struct smb_filename *smb_fname)
 {
        int result;
 
-       result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, path);
+       result = SMB_VFS_NEXT_SYS_ACL_DELETE_DEF_FILE(handle, smb_fname);
 
        do_log(SMB_VFS_OP_SYS_ACL_DELETE_DEF_FILE, (result >= 0), handle,
-              "%s", path);
+              "%s", smb_fname->base_name);
 
        return result;
 }
@@ -2380,26 +2379,69 @@ static bool smb_full_audit_aio_force(struct vfs_handle_struct *handle,
        return result;
 }
 
-static bool smb_full_audit_is_offline(struct vfs_handle_struct *handle,
-                                     const struct smb_filename *fname,
-                                     SMB_STRUCT_STAT *sbuf)
+static NTSTATUS smb_full_audit_durable_cookie(struct vfs_handle_struct *handle,
+                               struct files_struct *fsp,
+                               TALLOC_CTX *mem_ctx,
+                               DATA_BLOB *cookie)
 {
-       bool result;
+       NTSTATUS result;
+
+       result = SMB_VFS_NEXT_DURABLE_COOKIE(handle,
+                                       fsp,
+                                       mem_ctx,
+                                       cookie);
+
+       do_log(SMB_VFS_OP_DURABLE_COOKIE, NT_STATUS_IS_OK(result), handle,
+                       "%s", fsp_str_do_log(fsp));
 
-       result = SMB_VFS_NEXT_IS_OFFLINE(handle, fname, sbuf);
-       do_log(SMB_VFS_OP_IS_OFFLINE, result, handle, "%s",
-              smb_fname_str_do_log(fname));
        return result;
 }
 
-static int smb_full_audit_set_offline(struct vfs_handle_struct *handle,
-                                     const struct smb_filename *fname)
+static NTSTATUS smb_full_audit_durable_disconnect(
+                               struct vfs_handle_struct *handle,
+                               struct files_struct *fsp,
+                               const DATA_BLOB old_cookie,
+                               TALLOC_CTX *mem_ctx,
+                               DATA_BLOB *new_cookie)
 {
-       int result;
+       NTSTATUS result;
+
+       result = SMB_VFS_NEXT_DURABLE_DISCONNECT(handle,
+                                       fsp,
+                                       old_cookie,
+                                       mem_ctx,
+                                       new_cookie);
+
+       do_log(SMB_VFS_OP_DURABLE_DISCONNECT, NT_STATUS_IS_OK(result), handle,
+                       "%s", fsp_str_do_log(fsp));
+
+       return result;
+}
+
+static NTSTATUS smb_full_audit_durable_reconnect(
+                               struct vfs_handle_struct *handle,
+                               struct smb_request *smb1req,
+                               struct smbXsrv_open *op,
+                               const DATA_BLOB old_cookie,
+                               TALLOC_CTX *mem_ctx,
+                               struct files_struct **fsp,
+                               DATA_BLOB *new_cookie)
+{
+       NTSTATUS result;
+
+       result = SMB_VFS_NEXT_DURABLE_RECONNECT(handle,
+                                       smb1req,
+                                       op,
+                                       old_cookie,
+                                       mem_ctx,
+                                       fsp,
+                                       new_cookie);
+
+       do_log(SMB_VFS_OP_DURABLE_RECONNECT,
+                       NT_STATUS_IS_OK(result),
+                       handle,
+                       "");
 
-       result = SMB_VFS_NEXT_SET_OFFLINE(handle, fname);
-       do_log(SMB_VFS_OP_SET_OFFLINE, result >= 0, handle, "%s",
-              smb_fname_str_do_log(fname));
        return result;
 }
 
@@ -2513,25 +2555,23 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
        .setxattr_fn = smb_full_audit_setxattr,
        .fsetxattr_fn = smb_full_audit_fsetxattr,
        .aio_force_fn = smb_full_audit_aio_force,
-       .is_offline_fn = smb_full_audit_is_offline,
-       .set_offline_fn = smb_full_audit_set_offline,
-
-       /* Missing:
-
-               durable_cookie_fn
-               durable_disconnect_fn
-               durable_reconnect_fn
-       */
+       .durable_cookie_fn = smb_full_audit_durable_cookie,
+       .durable_disconnect_fn = smb_full_audit_durable_disconnect,
+       .durable_reconnect_fn = smb_full_audit_durable_reconnect,
        .readdir_attr_fn = smb_full_audit_readdir_attr
 
 };
 
 static_decl_vfs;
-NTSTATUS vfs_full_audit_init(void)
+NTSTATUS vfs_full_audit_init(TALLOC_CTX *ctx)
 {
-       NTSTATUS ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION,
-                                       "full_audit", &vfs_full_audit_fns);
-       
+       NTSTATUS ret;
+
+       smb_vfs_assert_all_fns(&vfs_full_audit_fns, "full_audit");
+
+       ret = smb_register_vfs(SMB_VFS_INTERFACE_VERSION, "full_audit",
+                              &vfs_full_audit_fns);
+
        if (!NT_STATUS_IS_OK(ret))
                return ret;