If Tor crashes, a managed obfsproxy sticks around. That's not so bad, because Tor isn't supposed to ever crash. But shouldn't we have defense-in-depth here?
To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information
Child items 0
Show closed items
No child items are currently assigned. Use child items to break down this issue into smaller parts.
Linked items 0
Link issues together to show that they're related.
Learn more.
So, to do that we need to pass obfsproxy the pid of Tor on startup, because if we don't, we can't learn it reliably in a portable way afaik. We can then use the procmon thing that we have in Tor, ported over. That's ugly and insane, but maybe our best alternative?
To pass the pid, we could invent something like passing a --managed= to obfsproxy, and in the torrc specify a certain magic string to mean "pass whatever pid we have". I think that should work, and it would be the cleanest alternative I can think of.
So, to do that we need to pass obfsproxy the pid of Tor on startup, because if we don't, we can't learn it reliably in a portable way afaik. We can then use the procmon thing that we have in Tor, ported over. That's ugly and insane, but maybe our best alternative?
To pass the pid, we could invent something like passing a --managed= to obfsproxy, and in the torrc specify a certain magic string to mean "pass whatever pid we have". I think that should work, and it would be the cleanest alternative I can think of.
Put it in the environment! We're cramming everything else a managed proxy needs to know into that blivet; another few bytes can't hurt.
I think it's not urgent to get a fix for this in, if it involves a whole lot of code, assuming it really only happens when Tor crashes. We should fix the Tor crashes in that case.
Apparently twilde saw it happen on a normal Tor exit though? If that's the case then there's a Tor bug there too.
I had to solve this problem for meek-client-torbrowser on Windows. meek-client-torbrowser starts two of its own subprocesses, and on Windows, tor kills its PTs uncleanly with TerminateProcess (#9330 (moved)), hence they don't have a chance to clean up their subprocesses.
What I did was described in comment:5:ticket:10047. You stick another process (called terminateprocess-buffer) in between tor and the real PT (meek-client-torbrowser). tor kills terminateprocess-buffer uncleanly. The real PT senses that its stdin has closed, and uses that as a signal to shut down cleanly.
How this would work in the obfsproxy case is you would put the buffer process in between tor and obfsproxy, and modify obfsproxy to monitor the closedness of its stdin.
Unfortunately, tor closes the stdin of its PT processes on startup, so the PT has to know whether it is being run with a terminateprocess-buffer or not, and interpret the closing of stdin appropriately. In meek-client-torbrowser, this is done with a special --exit-on-stdin-eof option.