PEP 3143: Standard daemon process library
exarkun at divmod.com
Sun Mar 22 02:29:37 CET 2009
On Sun, 22 Mar 2009 10:19:58 +1100, Ben Finney <ben+python at benfinney.id.au> wrote:
>Jean-Paul Calderone <exarkun at divmod.com> writes:
>> The biggest shortcoming seems to be a complete lack of unit tests.
>A full unit test suite is in the source distribution's ‘tests/’
>directory. You can run it with ‘python ./setup.py test’.
Of course this is correct. My apologizes for my incorrect statement. I
was probably looking for the tests in the "daemon" directory, not used to
seeing them outside the package they are testing. In my hurry I didn't
>> A quick skim of the code suggests that part of it don't even work at
>> all and have never been tested, even interactively, since they must
>> surely fail. For example, uid/gid setting is broken.
>This doesn't help identify the problem. Can you explain what you see
>as broken, preferably after running the code to observe its behaviour?
Here is a demonstration of the problem:
# python -c '
from __future__ import with_statement
import sys, daemon, os
with daemon.DaemonContext(stdout=sys.stdout, stdin=sys.stdin,
stderr=sys.stderr, uid=1, gid=1) as c:
Traceback (most recent call last):
File "<string>", line 5, in <module>
File "daemon/daemon.py", line 342, in __enter__
File "daemon/daemon.py", line 325, in open
OSError: [Errno 1] Operation not permitted
This happens because setuid is called before setgid. This means that by
the time setgid is called, it is no longer allowed. Reversing the order
is a simple fix. An additional feature which would be useful for the
library to provide, however, would be the setting of euid and egid instead
of uid and gid. This is necessary, for example, to write an SSH daemon
which gives out user shells.
More information about the Python-list