Tor problema de permissão de arquivo de serviço oculto

3

Eu instalei o Tor no Ubuntu 14.04 de acordo com as instruções no link

Eu tenho o relay básico configurado e funcionando, mas tenho problemas de permissão de arquivo com permissões de arquivo de um serviço oculto private_key e arquivos de nome de host. O Tor é iniciado como root, ele faz alguma mágica e depois cai para ser executado como "debian-tor".

Permissões de arquivo:

sudo ls -l /home/debian-tor /home/debian-tor/tor_keys =>
/home/debian-tor:
total 4
drwx------ 2 debian-tor debian-tor 4096 Jul 17 10:59 tor_keys

/home/debian-tor/tor_keys:
total 8
-rw------- 1 debian-tor debian-tor  23 Jul 17 10:59 hostname
-rw------- 1 debian-tor debian-tor 891 Jul 16 17:52 private_key

Começando como um serviço (não funciona):

sudo service tor start =>
[notice] Tor 0.2.6.10 (git-71459b2fe953a1c0) opening new log file.
[warn] Could not open "/home/debian-tor/tor_keys/private_key": Permission denied
[warn] Error reading private key from "/home/debian-tor/tor_keys/private_key"
[err] Error loading private key.
[warn] Error loading rendezvous service keys
[err] set_options(): Bug: Acting on config options left us in a broken state. Dying.

A partir da linha de comando (funciona!):

sudo tor =>
[notice] Tor 0.2.6.10 (git-71459b2fe953a1c0) opening log file.
[notice] Tor v0.2.6.10 (git-71459b2fe953a1c0) running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.1f and Zlib 1.2.8.
[notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
[notice] Read configuration file "/etc/tor/torrc".
[notice] Opening Control listener on 127.0.0.1:9052
[notice] Parsing GEOIP IPv4 file /usr/share/tor/geoip.
[notice] Parsing GEOIP IPv6 file /usr/share/tor/geoip6.
[notice] Bootstrapped 0%: Starting
...
[notice] Bootstrapped 100%: Done

Teste para que outro usuário possua os arquivos (isso mostra que o tor está realmente sendo executado como debian-tor):

sudo chown -R ubuntu_user:ubuntu_user /home/debian-tor
sudo service tor start =>
 * Checking if tor configuration is valid
Jul 17 12:23:06.811 [notice] Tor v0.2.6.10 (git-71459b2fe953a1c0) running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.1f and Zlib 1.2.8.
Jul 17 12:23:06.811 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Jul 17 12:23:06.811 [notice] Read configuration file "/usr/share/tor/tor-service-defaults-torrc".
Jul 17 12:23:06.811 [notice] Read configuration file "/etc/tor/torrc".
Jul 17 12:23:06.814 [warn] /home/debian-tor/tor_keys is not owned by this user (debian-tor, 108) but by ubuntu_user (1000). Perhaps you are running Tor as the wrong user?
Jul 17 12:23:06.814 [warn] Failed to parse/validate config: Failed to configure rendezvous options. See logs for details.
Jul 17 12:23:06.814 [err] Reading config failed--see warnings above.

Tentando obter as chaves de recriação do Tor:

sudo rm -r /home/debian-tor/tor_keys
sudo service tor start =>
[notice] Tor 0.2.6.10 (git-71459b2fe953a1c0) opening log file.
[warn] Error creating directory /home/debian-tor/tor_keys: Permission denied
[warn] Error loading rendezvous service keys
[err] set_options(): Bug: Acting on config options left us in a broken state. Dying.

A execução de sudo tor criaria a pasta e gravaria os arquivos hostname e private_key lá.

Então, minha pergunta é: como posso obter sudo service tor start funcionando? De alguma forma, não tem privilégios root nem debian-tor para escrever lá, ou talvez eu esteja perdendo alguma coisa. Ou devo simplesmente não usar o script /etc/init.d/tor para gerenciá-lo?

    
por NikoNyrh 17.07.2015 / 13:41

1 resposta

0

Existe uma resposta simples - AppArmor. Limita recursos para seus serviços. Você pode encontrar detalhes aqui man apparmor ou veja aqui link

Então você precisa adicionar regras ao /etc/apparmor.d/local/system_tor

# Site-specific additions and overrides for system_tor.
# For more details, please see /etc/apparmor.d/local/README.

/home/debian-tor/tor_keys/* rwmk,

Então sudo service apparmor restart E vai funcionar como um sharm.

sudo service tor restart

sudo service tor status

tail /var/log/tor/log

torify links my_abracadabra.onion

e assim por diante ...

    
por Sergey 19.08.2015 / 00:19

Tags