Skip to content

system_config: add umask option to <system> directive#5390

Merged
kenhys merged 2 commits into
fluent:masterfrom
somaz94:feat/system-config-umask
Jul 14, 2026
Merged

system_config: add umask option to <system> directive#5390
kenhys merged 2 commits into
fluent:masterfrom
somaz94:feat/system-config-umask

Conversation

@somaz94

@somaz94 somaz94 commented Jun 22, 2026

Copy link
Copy Markdown
Contributor

Which issue(s) this PR fixes: Fixes #4816

What this PR does / why we need it:
Adds a umask option to the <system> directive so the process umask can be
set from the config file. Previously this required the --umask command line
option, which is inconvenient for services and container images.

It reuses the existing chumask handling: <system> umask sets the same value
that --umask does, and the command line option takes precedence when both are
given. Both supervised and --no-supervisor modes honor it.

<system>
  umask 0022
</system>

Tests: added a config round-trip case and a supervisor test asserting the value
reaches ServerEngine, including command-line precedence.

Docs Changes:
fluent/fluentd-docs-gitbook#625

Release Note:
Add umask option to the <system> directive.

Signed-off-by: somaz <genius5711@gmail.com>
@somaz94 somaz94 marked this pull request as ready for review June 23, 2026 09:40
@kenhys

kenhys commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

It is ideal that not only checking serverengine layer, but also actual generated buffer permissions for example. could you afford to add such a test case?

…ermissions

Signed-off-by: somaz <genius5711@gmail.com>
@somaz94

somaz94 commented Jul 3, 2026

Copy link
Copy Markdown
Contributor Author

Added an end-to-end test in test/command/test_fluentd.rb that boots fluentd with <system> umask 0077 and a file buffer, then asserts the staged buffer chunk is created as 0600 (0644 & ~umask).

One thing worth noting: the buffer files only pick up the umask in --no-supervisor mode, where fluentd calls File.umask directly in the worker. In supervised mode the umask reaches only the supervisor process (ServerEngine applies chumask there, not the workers' worker_chumask), so worker-created buffer files stay 0644 — and this is true for the existing --umask option too, not something this PR changes. So the test runs with --no-supervisor to deterministically verify the actual file permission. Happy to open a separate issue for the supervised-mode worker umask gap if that's useful.

@Watson1978 Watson1978 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for seeing this through, and for adding the buffer-permission test in response to the review.

The implementation is nicely minimal — reusing the existing chumask path (now that #4836 fixed it reaching ServerEngine) and keeping umask as a string so it flows through the same to_i(8) handling is the right call. The command-line precedence via !@cl_opt.key?(:chumask) is correct too, since cmd_opts only gains :chumask when --umask is actually passed.

For future readers, it's worth being explicit that <system> umask takes effect in exactly the same modes as the existing --umask option:

  • --no-supervisor (standalone): applied — Fluentd calls File.umask directly in the worker.
  • Supervised + --daemon (daemonize, e.g. fluent-package): applied — ServerEngine sets the umask before spawning workers, so worker-created files inherit it.
  • Supervised without --daemon (foreground): not applied to worker-created files — ServerEngine's non-daemonize path never calls File.umask, and Fluentd doesn't set worker_chumask.

So the common packaged deployment (--daemon) does honor it; only the foreground-supervisor case is uncovered. That's existing --umask behavior rather than anything this PR changes, so it's not a blocker.

For the foreground-supervisor gap, let's track it in a separate follow-up issue rather than widening this PR — keeping this one scoped to "the config-file equivalent of --umask" is cleanest, and matches what you already suggested.

For the docs follow-up, it'd help to spell out which modes the option takes effect in, so users on a foreground supervisor don't expect it to change buffer file permissions.

Thanks.

@Watson1978 Watson1978 added this to the v1.20.0 milestone Jul 14, 2026
@Watson1978

Copy link
Copy Markdown
Contributor

@kenhys I'm planning to approve this. The umask applicability matches the existing --umask (works with --no-supervisor and --daemon, not under a foreground supervisor — I verified all three) and I'll track the foreground-supervisor gap in a separate issue. Anything you'd like addressed before I do?

@kenhys

kenhys commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

I verified all three) and I'll track the foreground-supervisor gap in a separate issue. Anything you'd like addressed before I do?

I'll second that decision.

@kenhys kenhys merged commit e833442 into fluent:master Jul 14, 2026
42 of 43 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

System config: add umask option

3 participants