Session problem using a daemonized site

[email protected]
Newsgroups gmane.comp.web.quixote.user
Message-ID <[email protected]>
When daemonizing a Quixote site that uses sessions, you have to put

    os._urandomfd = None

after the fork call.  Otherwise you'll get a "bad file descriptor" error
on some systems.  It happened specifically on Mac OS X 10.3.9 (Python
2.4.1), but not on my Linux development system.  Something else apparently
calls os.urandom() early at Python startup, and it opens /dev/urandom and
puts the file descriptor in the _urandom global.  But after a fork the
file descriptor is invalid, so you have to reset it to make it open the
file again.  Otherwise an innocent user comes along and Quixote tries to
create a random session ID and blammo!

My daemonizing module is at http://cafepy.com/quixote_extras/rex/toplevel.py
Append "?download=1" for download-friendly format.
It has several command-line options (--simple, --scgi, --daemon, --pidfile,
--stop, --user, --group) but requires a 'config' module in a specific
format.  This could be made generic with some minimal work.

-- 
-- Mike Orr <[email protected]>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.