Running twistd as root, no modules found

I have a simple web server written in Twisted, and I'm trying to start it using twistd . Everything works fine with reactor.run() , but when I use twistd -y (as root), none of my packages that are in direct child directories are found. I am running twistd as root since the server is running on port 80. the manpage for twistd says:

Note that if twistd starts as root, the working directory does not look for Python modules.

Well, but why? And how can I work? Twistd seems to ignore --rundir . even if I set this option explicitly.

+4
source share
1 answer

The common wisdom of UNIX is that finding a working directory to do things when root is a bad idea. The argument says that it opens the door to the Trojans. Not intending to add a working directory to the Python import search module at startup as root, the twist basically tries to follow this wisdom.

As another commenter said, you can explicitly tell PYTHONPATH to include directories themselves that contain the code you need.

You can also skip execution as fully root and use authbind to bind low port numbers without root privileges. This is how all my servers are deployed.

+7
source

All Articles