[Twisted-Python] Known bug with twistd log rotation
Hi! I'm finding it difficult to get log rotation working cleanly with twistd (if dropping privileges through twistd, which we require). I went through all the docs and also found [1] very helpful, but the problem boils down to the fact that
Implications for Logfile Rotation
Using the configuration described here, the LOGFILE will be created as user "root" and group "root", but rotated as user UID and group GID. If you want rotation to work as advertised it is necessary to put the LOGFILE in a directory in which UID/GID has permissions to rename files.
and
def rotate(self): """ Rotate the file and create a new one.
If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. """ if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)): return
(twisted 14.0.0) will never work together. Even if the user twistd runs as is technically able to rename the log file (due to having write permissions on the directory), it will never try to since it can't write to the file. There is a workaround on a comment in [1] but that's a really unnecessary and hacky solution, IMHO. Is this a known bug? I remember running into this issue a year ago or so and IIRC I just gave up. Thanks for any pointers, max [1] http://www.tsheffler.com/blog/?p=526
On 03:05 pm, max@riehl.io wrote:
Hi!
I'm finding it difficult to get log rotation working cleanly with twistd (if dropping privileges through twistd, which we require). I went through all the docs and also found [1] very helpful, but the problem boils down to the fact that
Implications for Logfile Rotation
Using the configuration described here, the LOGFILE will be created as user "root" and group "root", but rotated as user UID and group GID. If you want rotation to work as advertised it is necessary to put the LOGFILE in a directory in which UID/GID has permissions to rename files.
and
def rotate(self): """ Rotate the file and create a new one.
If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. """ if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)): return
(twisted 14.0.0)
will never work together. Even if the user twistd runs as is technically able to rename the log file (due to having write permissions on the directory), it will never try to since it can't write to the file. There is a workaround on a comment in [1] but that's a really unnecessary and hacky solution, IMHO.
Is this a known bug?
Sounds like https://twistedmatrix.com/trac/ticket/5723 Jean-Paul
Thanks Jean-Paul. I have no idea how I managed to miss both tickets (there is a duplicate) and would like to apologize. The required change is really small, despite the age of the ticket. Is there anything I can do to help fix it (e.G. contribute)? Thanks a lot for your work on Twisted. Regards, max
exarkun@twistedmatrix.com hat am 11. Juni 2014 um 17:52 geschrieben:
On 03:05 pm, max@riehl.io wrote:
Hi!
I'm finding it difficult to get log rotation working cleanly with twistd (if dropping privileges through twistd, which we require). I went through all the docs and also found [1] very helpful, but the problem boils down to the fact that
Implications for Logfile Rotation
Using the configuration described here, the LOGFILE will be created as user "root" and group "root", but rotated as user UID and group GID. If you want rotation to work as advertised it is necessary to put the LOGFILE in a directory in which UID/GID has permissions to rename files.
and
def rotate(self): """ Rotate the file and create a new one.
If it's not possible to open new logfile, this will fail silently, and continue logging to old logfile. """ if not (os.access(self.directory, os.W_OK) and os.access(self.path, os.W_OK)): return (twisted 14.0.0)
will never work together. Even if the user twistd runs as is technically able to rename the log file (due to having write permissions on the directory), it will never try to since it can't write to the file. There is a workaround on a comment in [1] but that's a really unnecessary and hacky solution, IMHO.
Is this a known bug?
Sounds like https://twistedmatrix.com/trac/ticket/5723
Jean-Paul
_______________________________________________ Twisted-Python mailing list Twisted-Python@twistedmatrix.com http://twistedmatrix.com/cgi-bin/mailman/listinfo/twisted-python
On 04:22 pm, max@riehl.io wrote:
Thanks Jean-Paul. I have no idea how I managed to miss both tickets (there is a duplicate) and would like to apologize.
No worries! I'm glad you asked here instead of filing another duplicate. ;) And a lot of people have trouble finding tickets in our tracker - there are a lot to sort through and trac's search functionality isn't very good. For what it's worth, I search the tracker using Google and including this term: inurl:twistedmatrix.com/trac/ticket It produces much better results than trac itself in almost all cases.
The required change is really small, despite the age of the ticket. Is there anything I can do to help fix it (e.G. contribute)?
Contribution would be most welcome! It looks like no one has started work on the ticket at all, so it's yours for the taking. :) Grab a checkout of Twisted (from subversion or git, as you prefer), write a failing unit test, then make it pass by changing the implementation. :) Attach a patch to the ticket and add the "review" keyword. Read more about the contribution process on the wiki: https://twistedmatrix.com/trac/wiki/ReviewProcess Thanks! Jean-Paul
participants (3)
-
exarkun@twistedmatrix.com
-
Maximilien Riehl
-
wp11226852-max