s3: Pass smb_filename through the set_offline vfs op
[samba.git] / source3 / modules / vfs_full_audit.c
index 10422fca791b934177be76ed458d040f597d7d3f..303ffae660c65cba9e0ca6e6351b7aea7d133176 100644 (file)
@@ -87,6 +87,7 @@ typedef enum _vfs_op_type {
        /* Directory operations */
 
        SMB_VFS_OP_OPENDIR,
+       SMB_VFS_OP_FDOPENDIR,
        SMB_VFS_OP_READDIR,
        SMB_VFS_OP_SEEKDIR,
        SMB_VFS_OP_TELLDIR,
@@ -229,6 +230,7 @@ static struct {
        { SMB_VFS_OP_STATVFS,   "statvfs" },
        { SMB_VFS_OP_FS_CAPABILITIES,   "fs_capabilities" },
        { SMB_VFS_OP_OPENDIR,   "opendir" },
+       { SMB_VFS_OP_FDOPENDIR, "fdopendir" },
        { SMB_VFS_OP_READDIR,   "readdir" },
        { SMB_VFS_OP_SEEKDIR,   "seekdir" },
        { SMB_VFS_OP_TELLDIR,   "telldir" },
@@ -332,8 +334,8 @@ static struct {
        { SMB_VFS_OP_AIO_FSYNC, "aio_fsync" },
        { SMB_VFS_OP_AIO_SUSPEND,"aio_suspend" },
        { SMB_VFS_OP_AIO_FORCE, "aio_force" },
-       { SMB_VFS_OP_IS_OFFLINE, "aio_is_offline" },
-       { SMB_VFS_OP_SET_OFFLINE, "aio_set_offline" },
+       { SMB_VFS_OP_IS_OFFLINE, "is_offline" },
+       { SMB_VFS_OP_SET_OFFLINE, "set_offline" },
        { SMB_VFS_OP_LAST, NULL }
 };
 
@@ -395,11 +397,11 @@ static char *audit_prefix(TALLOC_CTX *ctx, connection_struct *conn)
        }
        result = talloc_sub_advanced(ctx,
                        lp_servicename(SNUM(conn)),
-                       conn->server_info->unix_name,
+                       conn->session_info->unix_name,
                        conn->connectpath,
-                       conn->server_info->utok.gid,
-                       conn->server_info->sanitized_username,
-                       conn->server_info->info3->base.domain.string,
+                       conn->session_info->utok.gid,
+                       conn->session_info->sanitized_username,
+                       conn->session_info->info3->base.domain.string,
                        prefix);
        TALLOC_FREE(prefix);
        return result;
@@ -735,6 +737,19 @@ static SMB_STRUCT_DIR *smb_full_audit_opendir(vfs_handle_struct *handle,
        return result;
 }
 
+static SMB_STRUCT_DIR *smb_full_audit_fdopendir(vfs_handle_struct *handle,
+                         files_struct *fsp, const char *mask, uint32 attr)
+{
+       SMB_STRUCT_DIR *result;
+
+       result = SMB_VFS_NEXT_FDOPENDIR(handle, fsp, mask, attr);
+
+       do_log(SMB_VFS_OP_FDOPENDIR, (result != NULL), handle, "%s",
+                       fsp_str_do_log(fsp));
+
+       return result;
+}
+
 static SMB_STRUCT_DIRENT *smb_full_audit_readdir(vfs_handle_struct *handle,
                                    SMB_STRUCT_DIR *dirp, SMB_STRUCT_STAT *sbuf)
 {
@@ -2188,6 +2203,29 @@ 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)
+{
+       bool result;
+
+       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)
+{
+       int result;
+
+       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;
+}
+
 static struct vfs_fn_pointers vfs_full_audit_fns = {
 
        /* Disk operations */
@@ -2201,6 +2239,7 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
        .statvfs = smb_full_audit_statvfs,
        .fs_capabilities = smb_full_audit_fs_capabilities,
        .opendir = smb_full_audit_opendir,
+       .fdopendir = smb_full_audit_fdopendir,
        .readdir = smb_full_audit_readdir,
        .seekdir = smb_full_audit_seekdir,
        .telldir = smb_full_audit_telldir,
@@ -2304,6 +2343,8 @@ static struct vfs_fn_pointers vfs_full_audit_fns = {
        .aio_fsync = smb_full_audit_aio_fsync,
        .aio_suspend = smb_full_audit_aio_suspend,
        .aio_force = smb_full_audit_aio_force,
+       .is_offline = smb_full_audit_is_offline,
+       .set_offline = smb_full_audit_set_offline,
 };
 
 NTSTATUS vfs_full_audit_init(void)