[Twisted-Python] twistd --uid and --logfile
exarkun at twistedmatrix.com
exarkun at twistedmatrix.com
Tue Aug 17 13:04:04 MDT 2010
On 06:14 pm, dave at krondo.com wrote:
>On Tue, Aug 17, 2010 at 10:40 AM, <exarkun at twistedmatrix.com> wrote:
>>On 11:35 am, zoran.bosnjak at sloveniacontrol.si wrote:
>>>I am running twisted application from /etc/init/myapp.conf by exec
>>>statement like this:
>>>exec /usr/bin/twistd --uid=<id> --gid=<gid>
>>>--logfile=/var/log/dir/file
>>>
>>>The problem is when log file is first created under /var/log/dir (dir
>>>is
>>>owned by user id), the owner of the file is 'root', not requested
>>>user.
>>>As a consequence, the twistd is not able to rotate log files.
>>>
>>>If the logfile is already created (and chowned) before running
>>>twistd,
>>>there is no problem. It looks like set uid/gid is called too late
>>>inside
>>>twistd. It is suppose to be called before creating a logfile.
>>>
>>>Is this a bug or am I missing something?
>>
>>If <id> or <gid> has write permission on /var/log/dir/ then rotation
>>should work, even if <id> or <gid> does not own the first logfile
>>created.
>
>That's true. It does seem reasonable, however, that the log files would
>get created with the uid/gid that you specified. I've been surprised by
>this
>in the past as well. Any reason not to do that?
No. It works the way it does now by accident. The code in question is
quite complicated and not necessarily fully covered by the test suite.
And the actual behavior of the --uid/--gid options isn't documented
anyway, so it's not clear what you *should* expect from it, nor which of
its current behaviors people /do/ expect from it.
Jean-Paul
More information about the Twisted-Python
mailing list