[Twisted-web] mailman with twisted
Tommi Virtanen
tv at twistedmatrix.com
Thu Feb 10 13:35:42 MST 2005
Andrea Arcangeli wrote:
> internet.UNIXServer('/var/lib/mailman/.twistd-web-pb',
> pb.PBServerFactory(distrib.ResourcePublisher(site))).setServiceParent(s)
> However the above isn't good, the socket is created word writeable, and
> it's owned by root, the setuid is executed later on (which is a good
> thing normally to bind ports <1024, but not in this case).
Pass in a different mode.
def listenUNIX(self, address, factory, backlog=5, mode=0666, wantPID=0):
UNIXServer should accept the same args.
> And if the file is
> already present I get the below problem. Why can't simply bind the device
> without recreating it? I don't recall any bind(2) limitation in the kernel that
> forces to recreate the device.
If a file by given name exists, bind(2) returns -1, EADDRINUSE.
Twisted is just passing that straight-through to you.
> At least there should be an option to auto-delete it.
Maybe, but that option would need to default to False.
I consider to be too risky to automate in a library. If another process
is listening on that socket, removing it just hides that fact.
Of course, if you really want it, you could just run
try:
os.unlink(sockName)
except OSError, e:
if e.errno == errno.ENOENT:
pass
else:
raise
before binding.
More information about the Twisted-web
mailing list