/var/lib/tor cannot be read: Permission denied or Couldn't create private data directory
Asked Answered
C

1

7

I use google cloud shell to execute this program

  1. Linux version
    Distributor ID: Debian
    Description:    Debian GNU/Linux 10 (buster)
    Release:        10
    Codename:       buster
  1. Tor version 0.3.5.10.

  2. When I tried restarting "sudo service tor restart" Tor I received an error

[ ok ] Stopping tor daemon...done (not running - there is no /run/tor/tor.pid).
[....] Starting tor daemon...Jun 27 01:51:04.132 [warn] Directory /var/lib/tor cannot be read: Permission denied
Jun 27 01:51:04.132 [warn] Failed to parse/validate config: Couldn't create private data directory "/var/lib/tor"
Jun 27 01:51:04.132 [err] Reading config failed--see warnings above.
failed.
  1. So I set full permissions for the tor directory sudo chmod -R 777 /var/lib/tor

    [FAIL] Checking if tor configuration is valid ... failed!
     Jun 27 01:53:59.685 [notice] Tor 0.3.5.10 running on Linux with Libevent 2.1.8-stable, OpenSSL 1.1.1g, Zlib 1.2.11, Liblzma 5.2.4, and Libzstd 1.3.8.
     Jun 27 01:53:59.685 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
     Jun 27 01:53:59.685 [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
     Jun 27 01:53:59.685 [notice] Read configuration file "/etc/tor/torrc".
     Jun 27 01:53:59.688 [warn] Error setting groups to gid 114: "Operation not permitted".
     Jun 27 01:53:59.688 [warn] If you set the "User" option, you must start Tor as root.
     Jun 27 01:53:59.688 [warn] Failed to parse/validate config: Problem with User value. See logs for details.
     Jun 27 01:53:59.688 [err] Reading config failed--see warnings above.
    
  2. I use root privileges sudo su

    [ ok ] Stopping tor daemon...done (not running - there is no /run/tor/tor.pid). [....] Starting tor daemon...Jun 27 01:58:58.455 [warn] Directory /var/lib/tor cannot be read: Permission denied Jun 27 01:58:58.455 [warn] Failed to parse/validate config: Couldn't create private data directory "/var/lib/tor" Jun 27 01:58:58.455 [err] Reading config failed--see warnings above.

Is there any way that can help me solve my problem or how can i be able to install tor version 2.9.14?

Caseate answered 27/6, 2020 at 2:10 Comment(0)
G
6

You might have already solved the problem by now, if not I hope this can help.


Is there any way that can help me solve my problem?

OPTION 1

Let's take a look at these warnings:

[warn] Error setting groups to gid 114: "Operation not permitted".
[warn] If you set the "User" option, you must start Tor as root.
[warn] Failed to parse/validate config: Problem with User value.

To get a log of all users run cat /etc/passwd and you'll see debian-tor listed:

...
debian-tor:x:108:114::/var/lib/tor:/bin/false
...

The folder /var/lib/tor is owned by user debian-tor, so sudo -u debian-tor tor will work.

Alternatively, you can run this for your current user: (or chmod 777 for all)

chmod 700 -R /var/lib/tor/*
chown -R tor /var/lib/tor/
sudo service tor restart

You actually should run tor as non-root, else you get this message:

You are running Tor as root. You don't need to, and you probably shouldn't.

OPTION 2

As the warning suggests to see logs for details you should check for a message within dsmeg and /var/log/syslog. If you find anything then it can be AppArmor or SELinux blocking tor. Both SELinux and AppArmor provide a set of tools to isolate applications from each other to protect the host system from being compromised, so it's not recommended disabling them permanently but temporarily for debugging.

According to Debian SELinux support:

The Debian packaged Linux kernels have SELinux support compiled in, but disabled by default.

Check the SELinux state with getenforce, if the output is Permissive or Disabled then you're set.

Moreover, looking at AppArmor/Progress:

Since Debian 10 (Buster), AppArmor is enabled by default.

To disable AppArmor on your system run: (reference)

sudo mkdir -p /etc/default/grub.d
echo 'GRUB_CMDLINE_LINUX_DEFAULT="$GRUB_CMDLINE_LINUX_DEFAULT apparmor=0"' \
| sudo tee /etc/default/grub.d/apparmor.cfg
sudo update-grub
sudo reboot

There's a chance that either one's the culprit. Users have reported similar issue here.


How can i be able to install tor version 2.9.14?

Downgrading the tor package is as simple as this:

sudo apt-get install tor=0.2.9.14

But why would you want do that?

tor v2 will be deprecated soon. You'll see warnings like:

[warn] At least one protocol listed as required in the consensus is
not supported by this version of Tor. You should upgrade. This version
of Tor will not work as a client on the Tor network. The missing
protocols are: DirCache=2 HSDir=2 HSIntro=4 Link=4-5

NB: Post on tor.stackexchange for tor related issues.

Gouveia answered 3/1, 2021 at 0:30 Comment(1)
Awesome, I looked for quite a few posts, and this allowed me to start tor without sudo rights: ``` sudo chmod 700 -R /var/lib/tor/* sudo chown -R myusername /var/lib/tor/ sudo service tor restart ```Defection

© 2022 - 2024 — McMap. All rights reserved.