Skip to content

Commit 48657c9

Browse files
Watson1978kenhys
authored andcommitted
in_tail: fix error when files without read permission are included in glob patterns (#5161)
**Which issue(s) this PR fixes**: Fixes #5152 **What this PR does / why we need it**: It is referencing an uninitialized instance variable for Linux Capability feature, causing an error. This PR will fix the bug. **Docs Changes**: N/A **Release Note**: * in_tail: fix error preventing the use of Linux Capability feature --------- Signed-off-by: Shizuo Fujita <[email protected]> Signed-off-by: Kentaro Hayashi <[email protected]>
1 parent efdc4dc commit 48657c9

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/fluent/plugin/in_tail.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@ def initialize
5959
@shutdown_start_time = nil
6060
@metrics = nil
6161
@startup = true
62+
@capability = Fluent::Capability.new(:current_process)
6263
end
6364

6465
desc 'The paths to read. Multiple paths can be specified, separated by comma.'
@@ -195,7 +196,6 @@ def configure(conf)
195196
@dir_perm = system_config.dir_permission || Fluent::DEFAULT_DIR_PERMISSION
196197
# parser is already created by parser helper
197198
@parser = parser_create(usage: parser_config['usage'] || @parser_configs.first.usage)
198-
@capability = Fluent::Capability.new(:current_process)
199199
if @read_bytes_limit_per_second > 0
200200
if !@enable_watch_timer
201201
raise Fluent::ConfigError, "Need to enable watch timer when using log throttling feature"

test/plugin/test_in_tail.rb

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2648,6 +2648,22 @@ def test_no_warn_with_directory_permission
26482648
end
26492649
end
26502650

2651+
def test_other_user_owned_files
2652+
# https://github.com/fluent/fluentd/issues/5141
2653+
omit "Cannot test with root user" if Process::UID.eid == 0
2654+
omit "NTFS doesn't support UNIX like permissions" if Fluent.windows?
2655+
2656+
config = config_element('', '', {
2657+
'tag' => "tail",
2658+
'path' => "/var/log/*.log",
2659+
'format' => 'none',
2660+
"pos_file" => "#{@tmp_dir}/tail.pos",
2661+
})
2662+
assert_nothing_raised do
2663+
create_driver(config, false)
2664+
end
2665+
end
2666+
26512667
def test_shutdown_timeout
26522668
Fluent::FileWrapper.open("#{@tmp_dir}/tail.txt", "wb") do |f|
26532669
# Should be large enough to take too long time to consume

0 commit comments

Comments
 (0)