s3: VFS: vfs_virusfilter. Implement unlinkat().
authorJeremy Allison <jra@samba.org>
Thu, 12 Sep 2019 21:16:55 +0000 (14:16 -0700)
committerRalph Boehme <slow@samba.org>
Thu, 26 Sep 2019 17:20:47 +0000 (17:20 +0000)
This is identical to unlink(), as there
are no special cases needed for rmdir().

Signed-off-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
source3/modules/vfs_virusfilter.c

index 6519ff4c087747d5b798d420e2718b531d57f933..e4cc45be5b64c737956fc8220a94480b4a69f636 100644 (file)
@@ -1457,6 +1457,38 @@ static int virusfilter_vfs_unlink(
        return 0;
 }
 
+static int virusfilter_vfs_unlinkat(struct vfs_handle_struct *handle,
+               struct files_struct *dirfsp,
+               const struct smb_filename *smb_fname,
+               int flags)
+{
+       int ret = SMB_VFS_NEXT_UNLINKAT(handle,
+                       dirfsp,
+                       smb_fname,
+                       flags);
+       struct virusfilter_config *config = NULL;
+       char *fname = NULL;
+       char *cwd_fname = handle->conn->cwd_fsp->fsp_name->base_name;
+
+       if (ret != 0 && errno != ENOENT) {
+               return ret;
+       }
+
+       SMB_VFS_HANDLE_GET_DATA(handle, config,
+                               struct virusfilter_config, return -1);
+
+       if (config->cache == NULL) {
+               return 0;
+       }
+
+       fname = smb_fname->base_name;
+
+       DBG_DEBUG("Removing cache entry (if existent): fname: %s\n", fname);
+       virusfilter_cache_remove(config->cache, cwd_fname, fname);
+
+       return 0;
+}
+
 static int virusfilter_vfs_renameat(
        struct vfs_handle_struct *handle,
        files_struct *srcfsp,
@@ -1505,6 +1537,7 @@ static struct vfs_fn_pointers vfs_virusfilter_fns = {
        .open_fn        = virusfilter_vfs_open,
        .close_fn       = virusfilter_vfs_close,
        .unlink_fn      = virusfilter_vfs_unlink,
+       .unlinkat_fn    = virusfilter_vfs_unlinkat,
        .renameat_fn    = virusfilter_vfs_renameat,
 };