Skip to content

Commit

Permalink
out_file: don't create world writable directory in daemon mode
Browse files Browse the repository at this point in the history
How to reproduce:

Create the following config file as file-fluentd.conf:

    <source>
      type forward
    </source>

    <match **>
      type file
      path /tmp/x/y/z/a
    </match>

Start fluentd:

    % ruby -I lib bin/fluentd -c file-fluentd.conf --daemon fluentd.pid

Check permission of /tmp/x:

    % stat /tmp/x | grep Access
    Access: (0777/drwxrwxrwx)  Uid: ( 1000/     kou)   Gid: ( 1000/     kou)
    Access: 2014-11-21 17:15:59.898444064 +0900

Permission is "0777/drwxrwxrwx".

Because daemon mode changes umask to `0000`. (It's natural for daemon.)
  • Loading branch information
kou committed Nov 21, 2014
1 parent 8c7bc1c commit 19ae3d9
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions lib/fluent/env.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,5 @@ module Fluent
DEFAULT_SOCKET_PATH = ENV['FLUENT_SOCKET'] || '/var/run/fluent/fluent.sock'
DEFAULT_LISTEN_PORT = 24224
DEFAULT_FILE_PERMISSION = 0644
DEFAULT_DIR_PERMISSION = 0755
end
2 changes: 1 addition & 1 deletion lib/fluent/plugin/buf_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def configure(conf)
end

def start
FileUtils.mkdir_p File.dirname(@buffer_path_prefix + "path")
FileUtils.mkdir_p File.dirname(@buffer_path_prefix + "path"), :mode => DEFAULT_DIR_PERMISSION
super
end

Expand Down
2 changes: 1 addition & 1 deletion lib/fluent/plugin/out_file.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def format(tag, time, record)

def write(chunk)
path = generate_path(chunk)
FileUtils.mkdir_p File.dirname(path)
FileUtils.mkdir_p File.dirname(path), :mode => DEFAULT_DIR_PERMISSION

case @compress
when nil
Expand Down

0 comments on commit 19ae3d9

Please sign in to comment.