Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add in_tail patch for pos file dir create (#1442)
Browse files Browse the repository at this point in the history
  • Loading branch information
hestolz authored Mar 23, 2022
1 parent 1e518f5 commit 5684b56
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 0 deletions.
4 changes: 4 additions & 0 deletions build/configure
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,10 @@ apply_patch ${base_dir}/source/ext/patches/fluentd/in_exec.patch ${base_dir}/sou
# Patching in_syslog.rb to support configurable syslog delimiter
apply_patch ${base_dir}/source/ext/patches/fluentd/in_syslog.patch ${base_dir}/source/ext/fluentd/lib/fluent/plugin/in_syslog.rb

# Patching in_tail.rb to ensure pos file directory exists and has appropriate permissions
# e568e2345f00bf8bd6bd6dbd469922ebd62c3bca, 90e399e014cd2462d9b7de2af4eab2972337708e
apply_patch ${base_dir}/source/ext/patches/fluentd/in_tail.patch ${base_dir}/source/ext/fluentd/lib/fluent/plugin/in_tail.rb

# This patch make sure to only load external plugin files starting with in_, out_, filter_, buf_, parser_, formatter_ or storage_
# It has not effect on fluentd internal plugins
apply_patch ${base_dir}/source/ext/patches/fluentd/plugin.patch ${base_dir}/source/ext/fluentd/lib/fluent/plugin.rb
Expand Down
32 changes: 32 additions & 0 deletions source/ext/patches/fluentd/in_tail.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
--- ../source/ext/fluentd/lib/fluent/plugin/in_tail.rb 2022-03-22 14:44:11.797607707 -0700
+++ ../source/ext/fluentd/lib/fluent/plugin/in_tail.rb.new 2022-03-22 15:00:10.526473440 -0700
@@ -24,6 +24,8 @@
class NewTailInput < Input
Plugin.register_input('tail', self)

+ FILE_PERMISSION = 0644
+ DIR_PERMISSION = 0755
+
def initialize
super
@paths = []
@@ -94,6 +96,7 @@
end

def configure_parser(conf)
+ @file_perm = system_config.file_permission || FILE_PERMISSION
+ @dir_perm = system_config.dir_permission || DIR_PERMISSION
@parser = Plugin.new_parser(conf['format'])
@parser.configure(conf)
end
@@ -130,7 +133,9 @@

def start
if @pos_file
- @pf_file = File.open(@pos_file, File::RDWR|File::CREAT, DEFAULT_FILE_PERMISSION)
+ pos_file_dir = File.dirname(@pos_file)
+ FileUtils.mkdir_p(pos_file_dir, mode: @dir_perm) unless Dir.exist?(pos_file_dir)
+ @pf_file = File.open(@pos_file, File::RDWR|File::CREAT|File::BINARY, @file_perm)
@pf_file.sync = true
@pf = PositionFile.parse(@pf_file)
end

0 comments on commit 5684b56

Please sign in to comment.