Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add file writable check in #configure #401

Merged
merged 1 commit into from
Jan 14, 2015
Merged

add file writable check in #configure #401

merged 1 commit into from
Jan 14, 2015

Conversation

sonots
Copy link
Member

@sonots sonots commented Aug 11, 2014

--config-test is very useful, but it does not check file permission. This proposition is to make a rule to check file permissions in #configure method of each plugin because I thought it is impossible to check file permissions for each configuration parameter of each plugin from Fluentd side (Fluentd can not know what each plugin wants to do)

This pull request is just the first example of the proposition.

@repeatedly What do you think? Yes, each plugin author should support file permission check in #configure method of each plugin when we decide as this is an official way.

PS. @repeatedly Could you tell me if you have a right place to put the file permission check utility function?

@kenjiskywalker
Copy link
Contributor

👍

@sonots
Copy link
Member Author

sonots commented Nov 25, 2014

I will write a permission check for out_file, but the permission check will be limited because out_file would make dirs not only on configure but also on running loop dynamically.

@repeatedly
Copy link
Member

PS. @repeatedly Could you tell me if you have a right place to put the file permission check utility function?

I'm not sure. I put some socket utilities in https://github.com/fluent/fluentd/blob/master/lib/fluent/plugin/socket_util.rb.
So similar file is good for me.

@sonots sonots self-assigned this Dec 3, 2014
@sonots sonots changed the title [PROPOSE] add file writable check in #configure add file writable check in #configure Dec 29, 2014
@sonots sonots force-pushed the writable_check branch 2 times, most recently from 6f1cde3 to 22ca0b9 Compare December 29, 2014 19:58
@sonots
Copy link
Member Author

sonots commented Dec 29, 2014

@repeatedly Could you review?

  1. Add FileUtil#wrtitable? method
  2. Add file writable check for in_debug_agent's unix_path
  3. Add file writable check for out_file's path (This permission check is limited because out_file would make dirs not only on configure but also on running loop dynamically.)

@sonots
Copy link
Member Author

sonots commented Jan 13, 2015

@repeatedly ping

# @param [String] path File path
# @return [Boolean] file is writable or not
def writable?(path)
if File.exists?(path)
Copy link
Member

Choose a reason for hiding this comment

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

Should use exist? instead of exists?

Copy link
Member Author

Choose a reason for hiding this comment

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

I do not mind. I will fix.

@sonots sonots force-pushed the writable_check branch 3 times, most recently from 03d6829 to 9181ee8 Compare January 14, 2015 06:06
@sonots
Copy link
Member Author

sonots commented Jan 14, 2015

@repeatedly fixed!

# @param [String] path File path
# @return [Boolean] file is writable or not
def writable?(path)
if File.exist?(path)
Copy link
Member

Choose a reason for hiding this comment

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

How about following code?

path = File.dirname(path) unless File.exist?(path) # or path = File.exist?(path) ? path : File.dirname(path)
File.writable?(path)

Copy link
Member Author

Choose a reason for hiding this comment

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

Good. Fixed

repeatedly added a commit that referenced this pull request Jan 14, 2015
add file writable check in #configure
@repeatedly repeatedly merged commit 3737171 into master Jan 14, 2015
@repeatedly repeatedly deleted the writable_check branch December 3, 2015 10:33
@coveralls
Copy link

Coverage Status

Changes Unknown when pulling fd1b901 on writable_check into * on master*.

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.

4 participants