Unfortunatelly this is not so easy.
- Safe, but (seems?) undocumented way in Linux -- is to call
os.fchmod(socket.fileno()) BEFORE bind() + set umask to proper value. Since umask is not thread safe (affect all threads) that action should be done in fork()...
- Portable way -- is to call
os.chmod(path) after binding. But this will leave socket with wrong permissions during small amount of time.
Socket write permissions are required in order unprivileged process to connect to it.