Support raw file descriptors for all relevant configuration options
Summary
Tor currently supports raw file descriptors only for passphrases. However, it would be extremely beneficial for all types of Tor node if file descriptors could be used in place of any file or address.
One of the primary benefits of accepting file descriptors is that it allows Tor to be implemented with socket activation. This was discussed in a much more narrow sense in #8908 (closed), but that was closed due to focusing entirely on the performance benefit.
If Tor allowed file descriptors more broadly, users could easily connect it to any service management system they want: systemd, yes, but also launchd. This allows for socket activation, which makes a considerable difference when booting the OS, and more importantly it allows networking to be handled at a higher level.
For clients, this can mean that Tor is started in a more efficient manner, and is provided more resources based on connection activity. For relays and directories, this allows Tor to bind to any port it wants without requiring special privileges: the OS opens the socket, and Tor merely accepts it. For onion services, this allows dependencies between an onion service and whatever it connects with to be automatically managed, without needing to specify a loopback address or Unix domain socket.
What is the expected behavior?
Any Tor configuration option that accepts a file path or socket should also accept a file descriptor. This would mainly be used by service profiles (launchd LaunchAgents, systemd service units, etc.) to pass network sockets through the command line.
If only implementing this for specific options is preferred, I feel the following options (in descending utility) should be supported:
- ORPort
- DirPort
- SocksPort
- HiddenServicePort
- ControlPort
Note that I am not asking for Tor to natively support a specific service manager: that would be much more difficult to maintain, and far more complicated.
I'd also like to reiterate that this isn't just for socket activation. In fact, relays couldn't use it for socket activation: nothing would connect to an ORPort until Tor started advertising it.