【问题标题】:/var/lib/tor cannot be read: Permission denied or Couldn't create private data directory/var/lib/tor 无法读取:权限被拒绝或无法创建私有数据目录
【发布时间】:2020-06-27 02:10:24
【问题描述】:

我使用google cloud shell来执行这个程序

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

  2. 当我尝试重新启动“sudo service tor restart”Tor 时,我收到了一个错误

[ 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. 所以我为 tor 目录设置了完全权限 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. 我使用root权限sudo su

    [ ok ] 停止 tor 守护进程...完成(未运行 - 没有 /run/tor/tor.pid)。 [....] 启动 Tor 守护进程...Jun 27 01:58:58.455 [警告] 目录 /var/lib/tor 无法读取:权限被拒绝 Jun 27 01:58:58.455 [警告] 无法解析/验证配置:无法创建私有数据目录“/var/lib/tor” 6 月 27 日 01:58:58.455 [错误] 读取配置失败 - 请参阅上面的警告。

有什么方法可以帮助我解决我的问题,或者我怎样才能安装 tor 版本 2.9.14?

【问题讨论】:

    标签: tor google-cloud-shell


    【解决方案1】:

    你现在可能已经解决了这个问题,如果没有,我希望这可以帮助。


    有什么方法可以帮助我解决我的问题吗?

    选项 1

    让我们来看看这些警告:

    [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.
    

    要获取所有用户的日志,请运行 cat /etc/passwd,您将看到 debian-tor 列出:

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

    文件夹/var/lib/tor 归用户debian-tor 所有,所以sudo -u debian-tor tor 可以使用。

    或者,您可以为当前用户运行此命令:(或chmod 777 为所有用户)

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

    您实际上应该以非 root 身份运行 tor,否则您会收到以下消息:

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

    选项 2

    正如警告向see logs for details 建议的那样,您应该检查dsmeg 和/var/log/syslog 中的消息。如果您发现任何东西,那么它可能是 AppArmor 或 SELinux 阻塞 Tor。 SELinux 和 AppArmor 都提供了一组工具来将应用程序相互隔离以保护主机系统不被入侵,因此不建议永久禁用它们,而是暂时禁用它们以进行调试。

    根据Debian SELinux support:

    Debian 打包的 Linux 内核已经编译了 SELinux 支持, 但默认禁用。

    使用getenforce 检查 SELinux 状态,如果输出为 Permissive 或 Disabled,则说明您已设置完毕。

    另外,看AppArmor/Progress:

    从 Debian 10 (Buster) 开始,AppArmor 默认启用。

    要在您的系统上禁用 AppArmor,请运行:(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
    

    任何一方都有可能是罪魁祸首。用户已报告类似问题here。


    如何才能安装 tor 版本 2.9.14?

    降级tor包就这么简单:

    sudo apt-get install tor=0.2.9.14
    

    但是你为什么要这样做呢?

    tor v2 将很快成为deprecated。您会看到如下警告:

    [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
    

    注意:在tor.stackexchange 上发布有关 Tor 相关问题的信息。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2018-08-15
      • 1970-01-01
      • 1970-01-01
      • 2021-12-11
      • 2021-11-01
      • 2021-01-12
      相关资源
      最近更新 更多