From c88ced1371e95a6305596d1e2bd668146d96b622 Mon Sep 17 00:00:00 2001 From: Jan Pedersen Date: Mon, 13 Jul 2026 11:21:50 +0200 Subject: [PATCH] Add missing check for ignored files in rmdir and unlink --- src/tup/server/fuse_fs.c | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/src/tup/server/fuse_fs.c b/src/tup/server/fuse_fs.c index 7e7cfc07c..72e72260d 100644 --- a/src/tup/server/fuse_fs.c +++ b/src/tup/server/fuse_fs.c @@ -861,6 +861,7 @@ static int tup_fs_unlink(const char *path) { struct mapping *map; struct file_info *finfo; + struct tup_entry *match = NULL; if(context_check() < 0) return -EPERM; @@ -874,10 +875,16 @@ static int tup_fs_unlink(const char *path) put_finfo(finfo); tup_fuse_handle_file(path, NULL, ACCESS_UNLINK); return 0; + } else { + const char *peeled = peel(path); + if(exclusion_match(stderr, &finfo->exclusion_root, peeled, &match) < 0) { + put_finfo(finfo); + return -ENOSYS; + } } put_finfo(finfo); } - if(strstr(path, ".fuse_hidden") != NULL) { + if(match || strstr(path, ".fuse_hidden") != NULL) { /* Similar to the rename check for .fuse_hidden, this shows up * in Arch sometimes. */ @@ -896,9 +903,10 @@ static int tup_fs_unlink(const char *path) static int tup_fs_rmdir(const char *path) { struct tmpdir *tmpdir; - const char *peeled; + const char *peeled = NULL; struct file_info *finfo; struct mapping *map; + struct tup_entry *match = NULL; if(context_check() < 0) return -EPERM; @@ -932,8 +940,20 @@ static int tup_fs_rmdir(const char *path) return 0; } } + + if(exclusion_match(stderr, &finfo->exclusion_root, peeled, &match) < 0) { + put_finfo(finfo); + return -ENOSYS; + } + put_finfo(finfo); } + if (match) { + int res = rmdir(peeled); + if(res < 0) + return -errno; + return 0; + } fprintf(stderr, "tup error: Unable to rmdir a directory not created during this job: %s\n", peel(path)); return -EPERM; }