Description of problem: after updating to tor-0.2.8.7-1.fc24.x86_64, I found out that tor refuse to start if I have a HiddenService defined: Sep 12 23:18:30.884 [notice] Tor v0.2.8.7 running on Linux with Libevent 2.0.21-stable, OpenSSL 1.0.2h-fips and Zlib 1.2.8. Sep 12 23:18:30.884 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning Sep 12 23:18:30.884 [notice] Read configuration file "/usr/share/tor/defaults-torrc". Sep 12 23:18:30.885 [notice] Read configuration file "/etc/tor/torrc". Sep 12 23:18:30.889 [warn] Directory /var/lib/tor/ssh_service/ cannot be read: Permission denied Sep 12 23:18:30.889 [warn] Failed to parse/validate config: Failed to configure rendezvous options. See logs for details. Sep 12 23:18:30.889 [err] Reading config failed--see warnings above. tor.service: Control process exited, code=exited status=1 The relelvent part of the config is HiddenServiceDir /var/lib/tor/hidden_service_ssh HiddenServicePort 22 127.0.0.1:22 At first, i supposed this was a local issue, but I can reproduce on another computer. I put selinux in permissive and that's not the issue. Starting tor manually work, and config is seen as ok. So I suspect something in the service file.
So, after searching, the issue is caused by "CapabilityBoundingSet=CAP_SETUID CAP_SETGID CAP_NET_BIND_SERVICE". I guess one caps is missing, not sure which one.
So, i found that the cap missing is CAP_DAC_READ_SEARCH.
This does not appear to be the only cap missing, if I add the following drop-in file it still does not work: # cat /etc/systemd/system/tor.conf.d/fix-caps.conf [Service] CapabilityBoundingSet=CAP_SETUID CAP_SETGID CAP_NET_BIND_SERVICE CAP_DAC_READ_SEARCH I have now copied the entire service and just commented out the CapbilityBoundingSet and now tor is starting again. The problem is at least definitely the capabilities but I do not know which one(s)
So it works on the first start of the daemon and the onionservice directories are getting created, as well as the onionservices. However as soon as you try to restart a service with a previously present onionservice, the service will fail to start. To make it work you have to: * disable SELinux * cp the entire service and just commented out the CapbilityBoundingSet as Hein-Pieter mentioned. It's not possible to restart it with SELinux enabled nor the right capabilities. This is on EL7 with tor v0.2.8.7
Downgrading to tor-0.2.7.6-4.el7 makes the service working again.
Seeing this on f24.
There is also some generic selinux issue,(likely the one seen by #4), tracked https://bugzilla.redhat.com/show_bug.cgi?id=1357395 On my side, I do have this: # cat fix_rh_1375369.conf [Service] CapabilityBoundingSet=CAP_DAC_READ_SEARCH In the case of #3, it seems that the file name is wrong, it should be /etc/systemd/system/tor.service.d/fix-caps.conf , not tor.conf.d
Created attachment 1206673 [details] Fix the issue on F24 and EPEL7
(In reply to Michael Scherer from comment #7) > There is also some generic selinux issue,(likely the one seen by #4), > tracked https://bugzilla.redhat.com/show_bug.cgi?id=1357395 > > On my side, I do have this: > > # cat fix_rh_1375369.conf > [Service] > CapabilityBoundingSet=CAP_DAC_READ_SEARCH > > In the case of #3, it seems that the file name is wrong, it should be > /etc/systemd/system/tor.service.d/fix-caps.conf , not tor.conf.d Do'h! Thanks! That was... stupid of me.
Tor shouldn't need CAP_DAC_READ_SEARCH, or at least I thought some patches I sent upstream last year removed the need for it (and apparently things have been working without it until recently). I'll have to take a closer look, but for now I'll add CAP_DAC_READ_SEARCH back into the bounding set. Builds in progress, updates to follow. Sorry for the delay.
So, that's only for hidden services, not for regular tor. The code is running as root before the configuration is parsed, and so root need to be able to open the directory, who has restricted permissions (and so need CAP_DAC_READ_SEARCH is needed for that use case) I guess having the directory could be owned by the root group with g+rx as a alternative ?
tor-0.2.8.8-1.fc25 has been pushed to the Fedora 25 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-881d78edf2
tor-0.2.8.8-1.el7 has been pushed to the Fedora EPEL 7 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-EPEL-2016-69f1c1433b
tor-0.2.8.8-1.fc23 has been pushed to the Fedora 23 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-877b55bdd7
tor-0.2.8.8-1.fc24 has been pushed to the Fedora 24 testing repository. If problems still persist, please make note of it in this bug report. See https://fedoraproject.org/wiki/QA:Updates_Testing for instructions on how to install test updates. You can provide feedback for this update here: https://bodhi.fedoraproject.org/updates/FEDORA-2016-1fce1e0993
tor-0.2.8.8-1.fc24 has been pushed to the Fedora 24 stable repository. If problems still persist, please make note of it in this bug report.
Tor services still won't start.
So you test with selinux on enforcing, or permissive ?
tor-0.2.8.8-1.fc25 has been pushed to the Fedora 25 stable repository. If problems still persist, please make note of it in this bug report.
Enforcing.
tor-0.2.8.8-1.fc23 has been pushed to the Fedora 23 stable repository. If problems still persist, please make note of it in this bug report.
I can confirm that with 0.2.8.8-1 onion services still do not work with SELinux in enforcing mode. They work now with SELinux disabled. The missing parts in the tor policy are: # grep tor /var/log/audit/audit.log | audit2allow -m tor_dac module tor_dac 1.0; require { type tor_t; class capability { dac_read_search dac_override }; } #============= tor_t ============== allow tor_t self:capability { dac_read_search dac_override }; loading this module makes tor and onionservices working with selinux in enforcing mode.
tor-0.2.8.8-1.el7 has been pushed to the Fedora EPEL 7 stable repository. If problems still persist, please make note of it in this bug report.
Unfortunately, the selinux policy still needs to be added to get onion services running: An initial starting with an onionservice configured works and it gets created. However, once an onionservice was created and the tor daemon gets restarted it's not able to read from the onionservice directory. The problem is that tor requires onionservice directories to be owned very clearly by the daemon user, but still requiring access at the moment when it runs as root. Nov 04 10:39:38 foo tor[28961]: Nov 04 10:39:38.459 [notice] Tor v0.2.8.9 running on Linux with Libevent 2.0.21-stable, Nov 04 10:39:38 foo tor[28961]: Nov 04 10:39:38.459 [notice] Tor can't help you if you use it wrong! Learn how to be saf Nov 04 10:39:38 foo tor[28961]: Nov 04 10:39:38.459 [notice] Read configuration file "/usr/share/tor/defaults-torrc". Nov 04 10:39:38 foo tor[28961]: Nov 04 10:39:38.459 [notice] Read configuration file "/etc/tor/torrc". Nov 04 10:39:38 foo tor[28961]: Nov 04 10:39:38.463 [warn] Directory /var/lib/tor/smtp cannot be read: Permission denied Nov 04 10:39:38 foo tor[28961]: Nov 04 10:39:38.463 [warn] Failed to parse/validate config: Failed to configure rendezvo Nov 04 10:39:38 foo tor[28961]: Nov 04 10:39:38.463 [err] Reading config failed--see warnings above. # rpm -qi tor Name : tor Version : 0.2.8.9 Release : 1.el7 Architecture: x86_64 Install Date: Fri 04 Nov 2016 10:39:17 AM CET Group : System Environment/Daemons Size : 10756994 License : BSD Signature : RSA/SHA256, Fri 21 Oct 2016 09:24:38 PM CEST, Key ID 6a2faea2352c64e5 Source RPM : tor-0.2.8.9-1.el7.src.rpm Build Date : Wed 19 Oct 2016 08:48:19 AM CEST Build Host : buildvm-08.phx2.fedoraproject.org Relocations : (not relocatable) Packager : Fedora Project Vendor : Fedora Project URL : https://www.torproject.org Summary : Anonymizing overlay network for TCP erver on the Tor network, or as a client to connect to the Tor network. # grep tor /var/log/audit/audit.log | audit2allow -m tor_dac module tor_dac 1.0; require { type tor_t; class capability { dac_read_search dac_override }; } #============= tor_t ============== allow tor_t self:capability { dac_read_search dac_override };
I confirm. So I opened another bug for that : https://bugzilla.redhat.com/show_bug.cgi?id=1392187
Still not working on selinux-policy-targeted-3.13.1-225.6.fc25.noarch
I am experiencing the exact issue as described in comment 24 (https://bugzilla.redhat.com/show_bug.cgi?id=1375369#c24) but on Fedora 25 with all packages up to date. The same solution of allowing dac_read_search and dac_override makes it work on a fresh (enforcing) minimal installation of Fedora 25. However, I almost want to blame systemd. Commenting the user line in /usr/share/tor/defaults-torrc and adding User=toranon under the Service section of /usr/lib/systemd/system/tor.service (or a drop-in file) also makes it work, which seems to imply that systemd is denying the root user access to the directories. Access to a hidden service directory is also granted when manually running the ExecStart command as root outside of the systemd service. I am not familiar enough with SELinux workings to know if there's a difference in applied policies depending on how I execute the tor binary.
This message is a reminder that Fedora 24 is nearing its end of life. Approximately 2 (two) weeks from now Fedora will stop maintaining and issuing updates for Fedora 24. It is Fedora's policy to close all bug reports from releases that are no longer maintained. At that time this bug will be closed as EOL if it remains open with a Fedora 'version' of '24'. Package Maintainer: If you wish for this bug to remain open because you plan to fix it in a currently maintained version, simply change the 'version' to a later Fedora version. Thank you for reporting this issue and we are sorry that we were not able to fix it before Fedora 24 is end of life. If you would still like to see this bug fixed and are able to reproduce it against a later version of Fedora, you are encouraged change the 'version' to a later Fedora version prior this bug is closed as described in the policy above. Although we aim to fix as many bugs as possible during every release's lifetime, sometimes those efforts are overtaken by events. Often a more recent Fedora release includes newer upstream software that fixes bugs or makes them obsolete.
Applies to both Fedora 25 and 26. Please update version field accordingly.
This is possibly a duplicate of: https://bugzilla.redhat.com/show_bug.cgi?id=1357395
Whoops, misjudged the situation with both Fedora 25 and 26. A boolean has been added to enable hidden service-supporting policies: sudo setsebool -P tor_can_onion_services on See: $ sudo ausearch -c tor --raw | audit2allow #============= tor_t ============== #!!!! This avc can be allowed using the boolean 'tor_can_onion_services' allow tor_t self:capability { dac_override dac_read_search };
(In reply to Kyle Marek from comment #31) > Whoops, misjudged the situation with both Fedora 25 and 26. A boolean has > been added to enable hidden service-supporting policies: > > sudo setsebool -P tor_can_onion_services on > > > See: > $ sudo ausearch -c tor --raw | audit2allow > > > #============= tor_t ============== > > #!!!! This avc can be allowed using the boolean 'tor_can_onion_services' > allow tor_t self:capability { dac_override dac_read_search }; This resolves the issue for me on f26, thank you!
(In reply to Kyle Marek from comment #30) > This is possibly a duplicate of: > https://bugzilla.redhat.com/show_bug.cgi?id=1357395 I'd rather say https://bugzilla.redhat.com/show_bug.cgi?id=1471477.
(In reply to Christian Stadelmann from comment #33) > (In reply to Kyle Marek from comment #30) > > This is possibly a duplicate of: > > https://bugzilla.redhat.com/show_bug.cgi?id=1357395 > > I'd rather say https://bugzilla.redhat.com/show_bug.cgi?id=1471477. Bug ID 1471477 > 1357395.
Fedora 24 changed to end-of-life (EOL) status on 2017-08-08. Fedora 24 is no longer maintained, which means that it will not receive any further security or bug fix updates. As a result we are closing this bug. If you can reproduce this bug against a currently maintained version of Fedora please feel free to reopen this bug against that version. If you are unable to reopen this bug, please file a new report against the current release. If you experience problems, please add a comment to this bug. Thank you for reporting this bug and we are sorry it could not be fixed.
it seems this issue was only pending another bug for an selinux update. So the original issue of this bug is actually resolved.
*** Bug 1301667 has been marked as a duplicate of this bug. ***