Tor won't automatically start on 19.07 head

$subject. Manually doing /etc/init.d/tor start works fine. I believe 19.07 also needs the ubox/libubox fixes from master, no?

Have you done /etc/init.d/tor enable to create the autostart symlink in /etc/rc.d ???

(The recent libubox fixes in master were for recently introduced bugs in master)

It's enabled by default, but yes, I obviously verified that.

It's rather strange, since all other services come up just fine… My rc.d looks like this:

root@heimdal:~# ls -la /etc/rc.d/
drwxr-xr-x    2 root     root           512 Dec 29 08:08 .
drwxr-xr-x    1 root     root          3488 Dec 30 14:36 ..
lrwxrwxrwx    1 root     root            21 Dec 29 08:08 K10gpio_switch -> ../init.d/gpio_switch
lrwxrwxrwx    1 root     root            18 Dec 29 08:08 K50dropbear -> ../init.d/dropbear
lrwxrwxrwx    1 root     root            13 Dec 29 08:08 K50tor -> ../init.d/tor
lrwxrwxrwx    1 root     root            16 Dec 29 08:08 K51stubby -> ../init.d/stubby
lrwxrwxrwx    1 root     root            13 Dec 29 08:08 K89log -> ../init.d/log
lrwxrwxrwx    1 root     root            14 Dec 29 08:08 K90boot -> ../init.d/boot
lrwxrwxrwx    1 root     root            17 Dec 29 08:08 K90network -> ../init.d/network
lrwxrwxrwx    1 root     root            20 Dec 29 08:08 K90sysfixtime -> ../init.d/sysfixtime
lrwxrwxrwx    1 root     root            16 Dec 29 08:08 K90umount -> ../init.d/umount
lrwxrwxrwx    1 root     root            20 Dec 29 08:08 S00sysfixtime -> ../init.d/sysfixtime
lrwxrwxrwx    1 root     root            14 Dec 29 08:08 S10boot -> ../init.d/boot
lrwxrwxrwx    1 root     root            16 Dec 29 08:08 S10system -> ../init.d/system
lrwxrwxrwx    1 root     root            16 Dec 29 08:08 S11sysctl -> ../init.d/sysctl
lrwxrwxrwx    1 root     root            13 Dec 29 08:08 S12log -> ../init.d/log
lrwxrwxrwx    1 root     root            17 Dec 29 08:08 S13haveged -> ../init.d/haveged
lrwxrwxrwx    1 root     root            14 Dec 29 08:08 S15zram -> ../init.d/zram
lrwxrwxrwx    1 root     root            17 Dec 29 08:08 S19dnsmasq -> ../init.d/dnsmasq
lrwxrwxrwx    1 root     root            18 Dec 29 08:08 S19dropbear -> ../init.d/dropbear
lrwxrwxrwx    1 root     root            18 Dec 29 08:08 S19firewall -> ../init.d/firewall
lrwxrwxrwx    1 root     root            17 Dec 29 08:08 S20network -> ../init.d/network
lrwxrwxrwx    1 root     root            16 Dec 29 08:08 S30stubby -> ../init.d/stubby
lrwxrwxrwx    1 root     root            14 Dec 29 08:08 S50cron -> ../init.d/cron
lrwxrwxrwx    1 root     root            13 Dec 29 08:08 S50sqm -> ../init.d/sqm
lrwxrwxrwx    1 root     root            13 Dec 29 08:08 S50tor -> ../init.d/tor
lrwxrwxrwx    1 root     root            21 Dec 29 08:08 S94gpio_switch -> ../init.d/gpio_switch
lrwxrwxrwx    1 root     root            14 Dec 29 08:08 S95done -> ../init.d/done
lrwxrwxrwx    1 root     root            13 Dec 29 08:08 S96led -> ../init.d/led
lrwxrwxrwx    1 root     root            17 Dec 29 08:08 S98sysntpd -> ../init.d/sysntpd
lrwxrwxrwx    1 root     root            19 Dec 29 08:08 S99bootcount -> ../init.d/bootcount
root@heimdal:~#

So, I tried to invoke Tor from rc.local, like this…

root@heimdal:~# cat /etc/rc.local 
# Put your custom commands here that should be executed once
# the system init finished. By default this file does nothing.
logger START TOR
/etc/init.d/tor start
logger END START TOR
exit 0
root@heimdal:~#

… and nothing. The relevant part of the log only shows the logger messages…

Mon Dec 30 15:08:47 2019 kern.info kernel: [   14.605899] mv88e6085 f1072004.mdio-mii:10 lan2: Link is Down
Mon Dec 30 15:08:47 2019 kern.info kernel: [   14.657870] mv88e6085 f1072004.mdio-mii:10 lan4: Link is Down
Mon Dec 30 15:08:47 2019 user.notice root: START TOR
Mon Dec 30 15:08:48 2019 user.notice root: END START TOR
Mon Dec 30 15:08:48 2019 user.notice sysctl: net.ipv4.conf.br-tor.route_localnet = 1
Mon Dec 30 15:08:48 2019 user.notice firewall: Reloading firewall due to ifup of lan (br-lan)
Mon Dec 30 15:08:48 2019 daemon.info procd: - init complete -

… so, yeah, running out of options, here.

F**K. This worked. :man_facepalming:

sleep 10
logger START TOR
/etc/init.d/tor start
logger END START TOR

There's a race condition on startup, I wager the interfaces on which I have the DNSPort listening aren't coming up before Tor. I can work around this with the DNSPort on localhost and DNATing the requests on the respective interfaces. Still, it's weird it worked for so long without any problems…

As expected, the moment I started listening only on localhost, Tor came up perfectly. Since I had a second dnsmasq instance working only as a DHCP server, now I'm using it also as DNS forwarder for Tor, so no DNAT needed. Problem solved, sorry for the noise, guys.

Hi, I had similar problem with tor. Could you try this fix from master ? https://github.com/openwrt/packages/commit/5bce9c3e1d043e90fb31920e7a1ff5dbe1116124

Hi! Sorry for not replying earlier. I haven't tested your change, but I guess it doesn't hurt. Now, what I did notice is a bit of (unrelated) nonsense in the exact same init script. Case in point:

	touch /var/run/tor.pid
	chown tor:tor /var/run/tor.pid

This is no way to create a PID file. Yes, Tor supports creating PID files, but they're not created by default. And if the point is to create a placeholder for Tor to create a PID file, it also doesn't make sense (as it's able to write it, but it won't be able to delete it).

Yes, I think that something like procd_set_param pidfile /var/run/tor.pid would be better. I'll add that to my open PR https://github.com/openwrt/packages/pull/10908

btw that respawn change was cherrypicked to 19.07 https://github.com/openwrt/packages/commit/74e9ca74fd7e84bedf258aa7f582efb2f86a895d#diff-75c8e7eb6437d1b46c76bc58a4e86cf4

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.