[Twisted-Python] Known bug with twistd log rotation

Maximilien Riehl max at riehl.io
Wed Jun 11 09:05:10 MDT 2014


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
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://twistedmatrix.com/pipermail/twisted-python/attachments/20140611/486447a9/attachment-0001.html>


More information about the Twisted-Python mailing list