Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions lib/fluent/supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -808,6 +808,12 @@ def configure(supervisor: false)
)
@system_config = build_system_config(@conf)

# `<system> umask` sets the process umask, just like the `--umask` command
# line option. The command line option takes precedence when both are given.
if @system_config.umask && !@cl_opt.key?(:chumask)
@chumask = @system_config.umask
end

$log.info :supervisor, 'parsing config file is succeeded', path: @config_path

build_additional_configurations(parsed_files) do |additional_conf|
Expand Down
5 changes: 4 additions & 1 deletion lib/fluent/system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class SystemConfig
:file_permission, :dir_permission, :counter_server, :counter_client,
:strict_config_value, :enable_msgpack_time_support, :disable_shared_socket,
:metrics, :enable_input_metrics, :enable_size_metrics, :enable_jit, :source_only_buffer,
:config_include_dir
:config_include_dir, :umask
]

config_param :workers, :integer, default: 1
Expand Down Expand Up @@ -61,6 +61,9 @@ class SystemConfig
v.to_i(8)
end
config_param :config_include_dir, default: Fluent::DEFAULT_CONFIG_INCLUDE_DIR
# Kept as a string (like the `--umask` command line option) so that it flows
# through the existing chumask handling, which applies `to_i(8)` later.
config_param :umask, :string, default: nil
config_section :log, required: false, init: true, multi: false do
config_param :path, :string, default: nil
config_param :format, :enum, list: [:text, :json], default: :text
Expand Down
1 change: 1 addition & 0 deletions test/config/test_system_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,7 @@ def parse_text(text)
'enable_input_metrics' => ['enable_input_metrics', false],
'enable_size_metrics' => ['enable_size_metrics', true],
'enable_jit' => ['enable_jit', true],
'umask' => ['umask', '0022'],
)
test "accepts parameters" do |(k, v)|
conf = parse_text(<<-EOS)
Expand Down
15 changes: 15 additions & 0 deletions test/test_supervisor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -704,6 +704,21 @@ def test_chumask_should_be_passed_to_ServerEngine((cl_opt, expected_chumask_valu
supervisor.run_supervisor
end

data("system config only", [{}, "0227", "0227"])
data("command line takes precedence", [{chumask: "222"}, "0227", "222"])
def test_umask_in_system_config_is_passed_to_ServerEngine((cl_opt, system_umask, expected_chumask_value))
proxy.mock(Fluent::Supervisor).serverengine_config(hash_including("chumask" => expected_chumask_value))
any_instance_of(ServerEngine::Daemon) { |daemon| mock(daemon).run.once }

supervisor = Fluent::Supervisor.new(cl_opt)
system_conf = config_element('ROOT', '', {}, [config_element('system', '', { 'umask' => system_umask })])
stub(Fluent::Config).build { system_conf }
stub(supervisor).build_spawn_command { "dummy command line" }
supervisor.configure(supervisor: true)

supervisor.run_supervisor
end

sub_test_case "init logger" do
data(supervisor: true)
data(worker: false)
Expand Down