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

Log rotation doesn't copy file ownership #80

Open
regsmith opened this issue Sep 23, 2022 · 1 comment
Open

Log rotation doesn't copy file ownership #80

regsmith opened this issue Sep 23, 2022 · 1 comment

Comments

@regsmith
Copy link

If you create a file with user permissions but then run logger under root the file rotate will not preserve these permissions causing access issues.

% ls -al log.log 
-rw-r--r--  1 reginaldsmith  staff  0 23 Sep 11:17 log.log
% rvmsudo irb
2.7.2 :001 > require "logger"
 => true 
2.7.2 :004 > puts File.stat("log.log").uid
502
 => nil 
2.7.2 :005 > log = File.open("log.log", "a")
 => #<File:log.log> 
2.7.2 :006 > logger = Logger.new(log, "everytime")
 => #<Logger:0x00007fd7cfbc5ee0 @level=0, @progname=nil, @default_formatter=#<Logger::Formatter:0x00007fd7cfbc5eb8 @datetime_format=nil>, @formatte... 
2.7.2 :007 > logger.info "hello"
 => true 
2.7.2 :008 > puts File.stat("log.log").uid
0 
2.7.2 :010 > exit
% ls -al log.log
-rw-r--r--  1 root  staff  123 23 Sep 11:20 log.log
% irb
2.7.2 :001 > require "logger"
 => true 
2.7.2 :002 > log = File.open("log.log", "a")
Errno::EACCES (Permission denied @ rb_sysopen - log.log)
>
@olleolleolle
Copy link
Contributor

Peeking at the code, perhaps this is where we have the information about the old file and are creating a new one:

@dev = create_logfile(@filename)

(Perhaps there are more places, but this is a start, at least.)

@nobu nobu changed the title Log rotation doesn't preserve file permissions Log rotation doesn't copy file ownership Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants