The tor package does not create the /var/run/tor folder. so it's this line: ${tor_pidfile="/var/run/tor/tor.pid"} in http://svnweb.freebsd.org/ports/head/security/tor/files/tor.in?view=markup I personally would like if it would be just /var/run/tor.pid. Or is there a reason that the pid file is in /var/run/tor? I didn't add a patch because it's probably easier to change it than to apply a patch.
This is typically because tor runs as the unprivileged user "_tor" and does not have permissions to create a file within the /var/run/ folder. Creating the folder /var/run/tor which is owned by the _tor user is one way to solve this. Another way to solve it, is to get the rc.d script (which is executed as root) to manage the creation and deletion of the pid file and datadir folder. Something like this: start_precmd=%%RC_NAME%%_precmd %%RC_NAME%%_precmd() { if [ ! -e "${pidfile}" ]; then install -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} -- /dev/null "${pidfile}"; fi if [ ! -d "${%%RC_NAME%%_datadir}" ]; then install -d -g ${%%RC_NAME%%_group} -o ${%%RC_NAME%%_user} -- "${%%RC_NAME%%_datadir}"; fi } stop_postcmd=%%RC_NAME%%_postcmd %%RC_NAME%%_postcmd() { rm -f -- "${pidfile}" }
(In reply to Sir l33tname from comment #0) Hi Sir l33tname. Technically your issue is covered already by the package post installation message: Message from tor-0.2.6.9: ================================================================================ To enable the tor server, set tor_enable="YES" in your /etc/rc.conf and edit /usr/local/etc/tor/torrc as desired. (However, note that the /usr/local/etc/rc.d/tor rc.subr script can override some torrc options: see that script for details.) To use the torify script, install the net/torsocks port. After installing tor for the first time, or after a major update of tor, you should: rm -r /var/db/tor /var/run/tor mkdir -p /var/db/tor/data /var/run/tor touch /var/log/tor chown -R _tor:_tor /var/db/tor /var/log/tor /var/run/tor chmod -R 700 /var/db/tor before starting the tor server. Tor users are strongly advised to prevent traffic analysis that exploits sequential IP IDs by setting: sysctl net.inet.ip.random_id=1 (see sysctl.conf(5)). ================================================================================
Created attachment 164867 [details] Create pid folder with rc script
Comment on attachment 164867 [details] Create pid folder with rc script maybe something like this? (I hope I created the patch the right way)
I'm working on this. It _should_ be a folder for tor, running under _tor user, to be able to create its pidfile (only root can create files in /var/run). Port should also create log directory, same reasons.
See https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=206235