Trac issueshttps://gitlab.torproject.org/legacy/trac/-/issues2020-06-13T15:19:23Zhttps://gitlab.torproject.org/legacy/trac/-/issues/24715Job for tor.service failed when /var/run is tmpfs2020-06-13T15:19:23ZTracJob for tor.service failed when /var/run is tmpfsISSUE SUMMARY
=============
For this test I'm running Tor 0.3.2.6-alpha (git-87012d076ef58bb9) on Gentoo Linux. On my system, the /var/run/tor directory does not exist, and /var/run is a link to /run which is mounted as tmpfs:
tmpf...ISSUE SUMMARY
=============
For this test I'm running Tor 0.3.2.6-alpha (git-87012d076ef58bb9) on Gentoo Linux. On my system, the /var/run/tor directory does not exist, and /var/run is a link to /run which is mounted as tmpfs:
tmpfs on /run type tmpfs (rw,nosuid,nodev,mode=755)
Attempting to start tor using tor.service fails:
vilhelm@sophia ~ $ sudo systemctl restart tor
Job for tor.service failed because the control process exited with error code.
See "systemctl status tor.service" and "journalctl -xe" for details.
vilhelm@sophia ~ $ sudo systemctl status tor.service
● tor.service - Anonymizing overlay network for TCP
Loaded: loaded (/lib/systemd/system/tor.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Wed 2017-12-06 09:08:19 EST; 4s ago
Process: 12244 ExecStart=/usr/bin/tor -f /etc/tor/torrc (code=exited, status=1/FAILURE)
Process: 12243 ExecStartPre=/usr/bin/tor -f /etc/tor/torrc --verify-config (code=exited, status=0/SUCCESS)
Main PID: 12244 (code=exited, status=1/FAILURE)
Dec 06 09:08:19 sophia systemd[1]: tor.service: Service hold-off time over, scheduling restart.
Dec 06 09:08:19 sophia systemd[1]: tor.service: Scheduled restart job, restart counter is at 5.
Dec 06 09:08:19 sophia systemd[1]: Stopped Anonymizing overlay network for TCP.
Dec 06 09:08:19 sophia systemd[1]: tor.service: Start request repeated too quickly.
Dec 06 09:08:19 sophia systemd[1]: tor.service: Failed with result 'exit-code'.
Dec 06 09:08:19 sophia systemd[1]: Failed to start Anonymizing overlay network for TCP.
vilhelm@sophia ~ $ sudo journalctl -xe
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tor.service has begun starting up.
Dec 06 09:08:18 sophia tor[12243]: Dec 06 09:08:18.595 [notice] Tor 0.3.2.6-alpha (git-87012d076ef58bb9) running on Linux with Libevent 2.1.8-stable, OpenSSL 1.0.2m, Zlib 1.2.11, Liblzma 5.2.3, and Libzstd N/A.
Dec 06 09:08:18 sophia tor[12243]: Dec 06 09:08:18.595 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Dec 06 09:08:18 sophia tor[12243]: Dec 06 09:08:18.595 [notice] This version is not a stable Tor release. Expect more bugs than usual.
Dec 06 09:08:18 sophia tor[12243]: Dec 06 09:08:18.596 [notice] Read configuration file "/etc/tor/torrc".
Dec 06 09:08:18 sophia tor[12243]: Dec 06 09:08:18.597 [notice] Based on detected system memory, MaxMemInQueues is set to 8192 MB. You can override this by setting MaxMemInQueues by hand.
Dec 06 09:08:18 sophia tor[12243]: Configuration was valid
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.036 [notice] Tor 0.3.2.6-alpha (git-87012d076ef58bb9) running on Linux with Libevent 2.1.8-stable, OpenSSL 1.0.2m, Zlib 1.2.11, Liblzma 5.2.3, and Libzstd N/A.
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.036 [notice] Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.036 [notice] This version is not a stable Tor release. Expect more bugs than usual.
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.036 [notice] Read configuration file "/etc/tor/torrc".
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.038 [notice] Based on detected system memory, MaxMemInQueues is set to 8192 MB. You can override this by setting MaxMemInQueues by hand.
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.038 [notice] Scheduler type KIST has been enabled.
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.038 [notice] Opening OR listener on 0.0.0.0:443
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.038 [notice] Opening Extended OR listener on 127.0.0.1:0
Dec 06 09:08:19 sophia tor[12244]: Dec 06 09:08:19.038 [notice] Extended OR listener listening on port 35193.
Dec 06 09:08:19 sophia Tor[12244]: Tor 0.3.2.6-alpha (git-87012d076ef58bb9) running on Linux with Libevent 2.1.8-stable, OpenSSL 1.0.2m, Zlib 1.2.11, Liblzma 5.2.3, and Libzstd N/A.
Dec 06 09:08:19 sophia Tor[12244]: Tor can't help you if you use it wrong! Learn how to be safe at https://www.torproject.org/download/download#warning
Dec 06 09:08:19 sophia Tor[12244]: This version is not a stable Tor release. Expect more bugs than usual.
Dec 06 09:08:19 sophia Tor[12244]: Read configuration file "/etc/tor/torrc".
Dec 06 09:08:19 sophia Tor[12244]: Based on detected system memory, MaxMemInQueues is set to 8192 MB. You can override this by setting MaxMemInQueues by hand.
Dec 06 09:08:19 sophia Tor[12244]: Scheduler type KIST has been enabled.
Dec 06 09:08:19 sophia Tor[12244]: Opening OR listener on 0.0.0.0:443
Dec 06 09:08:19 sophia Tor[12244]: Opening Extended OR listener on 127.0.0.1:0
Dec 06 09:08:19 sophia Tor[12244]: Extended OR listener listening on port 35193.
Dec 06 09:08:19 sophia Tor[12244]: Unable to open "/var/run/tor/tor.pid" for writing: No such file or directory
Dec 06 09:08:19 sophia Tor[12244]: Unable to write PIDFile "/var/run/tor/tor.pid"
Dec 06 09:08:19 sophia Tor[12244]: set_options(): Bug: Acting on config options left us in a broken state. Dying. (on Tor 0.3.2.6-alpha 87012d076ef58bb9)
Dec 06 09:08:19 sophia systemd[1]: tor.service: Main process exited, code=exited, status=1/FAILURE
Dec 06 09:08:19 sophia systemd[1]: tor.service: Failed with result 'exit-code'.
Dec 06 09:08:19 sophia systemd[1]: Failed to start Anonymizing overlay network for TCP.
-- Subject: Unit tor.service has failed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tor.service has failed.
--
-- The result is RESULT.
Dec 06 09:08:19 sophia systemd[1]: tor.service: Service hold-off time over, scheduling restart.
Dec 06 09:08:19 sophia systemd[1]: tor.service: Scheduled restart job, restart counter is at 5.
Dec 06 09:08:19 sophia systemd[1]: Stopped Anonymizing overlay network for TCP.
-- Subject: Unit tor.service has finished shutting down
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tor.service has finished shutting down.
Dec 06 09:08:19 sophia systemd[1]: tor.service: Start request repeated too quickly.
Dec 06 09:08:19 sophia systemd[1]: tor.service: Failed with result 'exit-code'.
Dec 06 09:08:19 sophia systemd[1]: Failed to start Anonymizing overlay network for TCP.
-- Subject: Unit tor.service has failed
-- Defined-By: systemd
-- Support: https://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit tor.service has failed.
--
-- The result is RESULT.
SUSPECTED CAUSE
===============
The issue appears to result from the missing /var/run/tor directory and a lack of write permission to create the /var/run/tor/tor.pid PIDFile. I can manually create a /var/run/tor directory, but it will be gone if the system restarts since /var/run is tmpfs. The /var/run/tor directory and appropriate permissions should be configured in the tor.service file by default.
PROPOSED SOLUTION
=================
If I add the following lines to the /lib64/systemd/system/tor.service file the issue is resolved:
Group=tor
RuntimeDirectory=tor
RuntimeDirectoryMode=0770
I suggest adding these lines to the Tor source code contrib/dist/tor.service.in file so that the installed tor.service file will have the configuration lines to automatically create a /var/run/tor directory with the necessary permissions.
**Trac**:
**Username**: vilhelmgrayTor: 0.3.3.x-finalhttps://gitlab.torproject.org/legacy/trac/-/issues/24577Systemctl tor.service invalid - Tor does not restart on systemctl start tor c...2020-06-13T15:18:41ZTracSystemctl tor.service invalid - Tor does not restart on systemctl start tor commandPlease refer to: https://askubuntu.com/questions/882527/tor-process-will-not-start-automatically-on-ubuntu-16-04/903341
When I looked at tor.service I find it's nothing more than a dummy file that only returns true if the tor.service is...Please refer to: https://askubuntu.com/questions/882527/tor-process-will-not-start-automatically-on-ubuntu-16-04/903341
When I looked at tor.service I find it's nothing more than a dummy file that only returns true if the tor.service is running and not the actual tor program itself:
----
# This service is actually a systemd target,
# but we are using a service since targets cannot be reloaded.
[Unit]
Description=Anonymizing overlay network for TCP (multi-instance-master)
[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/bin/true
ExecReload=/bin/true
----
So regardless if the TOR process is actually running or not, tor.service always returns TRUE. This is Invalid. and As a result running: sudo systemctl start|stop tor does nothing as you can see here:
● tor.service - Anonymizing overlay network for TCP (multi-instance-master)
** Loaded: loaded (/lib/systemd/system/tor.service; enabled; vendor preset: enabled)**
Active: active (exited) since Sun 2017-12-10 14:24:42 EST; 9min ago
Main PID: 17641 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/tor.service
So for the moment the temporary fix is:
Removing or renaming offending file /lib/systemd/system/tor.service and reloading the scripts w/ systemctl daemon-reload. because the actual and correct script to start tor is in /etc/init.d/tor
After this modifcation the resulting output of sudo systemctl status tor:
● tor.service - LSB: Starts The Onion Router daemon processes
** Loaded: loaded (/etc/init.d/tor; bad; vendor preset: enabled)**
Active: active (exited) since Sun 2017-12-10 14:24:42 EST; 26min ago
Docs: !man:systemd-sysv-generator(8)
Main PID: 17641 (code=exited, status=0/SUCCESS)
CGroup: /system.slice/tor.service
I believe the tor script in /etc/init.d/tor is incorrectly attempting to start/stop tor through tor.service as well.
Please correct this as soon as possible thank you !
**Trac**:
**Username**: d3m0nkingxTor: 0.3.1.x-final