0

This starts up Tor correctly:

sudo -u debian-tor /usr/sbin/tor --runasdaemon 0 -f /etc/tor/torrc

But when I try the same from supervisord

[program:tor]

command=/usr/sbin/tor --runasdaemon 0 -f /etc/tor/torrc

user=debian-tor

it fails with

Dec 16 11:00:06.977 [notice] Read configuration file "/etc/tor/torrc".

Dec 16 11:00:06.979 [notice] Opening Socks listener on 127.0.0.1:9050

Dec 16 11:00:06.979 [notice] Opened Socks listener connection (ready) on 127.0.0.1:9050

Dec 16 11:00:06.979 [warn] Directory /root/.tor cannot be read: Permission denied

Dec 16 11:00:06.979 [notice] Closing partially-constructed Socks listener connection (ready) on 127.0.0.1:9050

Dec 16 11:00:06.979 [warn] Failed to parse/validate config: Couldn't create private data directory "/root/.tor"

Dec 16 11:00:06.979 [err] Reading config failed--see warnings above.

Tor version 0.4.7.16.

No idea why it looks for /root/.tor in this case, anyway I did

sudo mkdir -p /root/.tor

sudo chown debian-tor /root/.tor

but same error.

1 Answer 1

0

It's about the $HOME environment variable that still points to the /root folder and of course it's not writable or readable by other users. To avoid that set Data directory and the user in /etc/tor/torrc config and simply launch it as root: it will drop itself to the user you've set in config ASAP after opening the port listeners, so it's safe and secure. In your case it's a wrong place to drop the privileges in your supervisord service config

2
  • Turns out supervisord only changes the userid but not $HOME.
    – Eva4684
    Dec 17, 2023 at 22:28
  • And he should not behave otherwise! That's what the configuration files are for
    – Alexey Vesnin
    Dec 18, 2023 at 14:10

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .