summaryrefslogtreecommitdiffstats
path: root/src/ctx.c
diff options
context:
space:
mode:
authorTavian Barnes <tavianator@tavianator.com>2024-07-30 16:44:17 -0400
committerTavian Barnes <tavianator@tavianator.com>2024-08-02 17:18:26 -0400
commit6290ce41f3ec1f889abb881cf90ca91da869b5b2 (patch)
tree679b1717100bd9f4c693d9d8b9463d51b195fd6c /src/ctx.c
parentb8a008dc9b84804d8b2c751daa9c04bd86d5e59c (diff)
downloadbfs-6290ce41f3ec1f889abb881cf90ca91da869b5b2.tar.xz
parse: Take umask into account in parse_mode()
POSIX 2024 clarified that find(1) is meant to work exactly like chmod(1) here, so for modes like +rw,-x with no "who" specified, apply the umask. Link: https://www.austingroupbugs.net/view.php?id=1392
Diffstat (limited to 'src/ctx.c')
-rw-r--r--src/ctx.c3
1 files changed, 3 insertions, 0 deletions
diff --git a/src/ctx.c b/src/ctx.c
index 0f619c2..8fafb32 100644
--- a/src/ctx.c
+++ b/src/ctx.c
@@ -52,6 +52,9 @@ struct bfs_ctx *bfs_ctx_new(void) {
trie_init(&ctx->files);
+ ctx->umask = umask(0);
+ umask(ctx->umask);
+
if (getrlimit(RLIMIT_NOFILE, &ctx->orig_nofile) != 0) {
goto fail;
}