Relative DataDirectory + RunAsDaemon = Tor can't read or write most of its datadirectory files
Bug legacy/trac#22101 (moved) shows a case where if you start your Tor with a relative (non absolute) DataDirectory, and RunAsDaemon 1
, and CookieAuthentication 1
but no CookieAuthFile
, then Tor will attempt to save your control_auth_cookie file to datadir/
datadir/control_auth_cookie. (Yes, you read that correctly, datadir/
datadir/.) The attempt will fail because Tor doesn't mkdir the datadir/
datadir directory.
If you start with a relative DataDirectory, and RunAsDaemon, but no CookieAuthentication, then your Tor will start, but it will attempt to (and fail to) write each of your datadirectory files -- state, cached-microdescriptors, etc, because it is trying to write them to datadir/
datadir. I think that might be what teor saw in legacy/trac#20456 (moved), but he doesn't give us an actual torrc so I can't be sure.
The bug is because we call get_datadir_fname(), which creates a filename that prepends datadir, after we do the chdir(
datadir) operation that comes with RunAsDaemon.