Hi {Nico} and the List, i think this is a good idea. But some other things i would change too. The default homefolder of tor is /var/lib/tor (tor creates only files in this folder) so the homedir in /etc/passwd should be changed to that directory too. And as every program creates a pid in /var/run without subfolders the touch & chown approch of a file is much nicer - imho. Also if a user would change the the pid to /var/run/tor.pid in torrc tor would still not start. As the folder is allready there it wouldnt be created and tor has no write previleges to write into this folder. (if you use my updates patch - tor_v1.patch)
I think tor should create a pid in /var/run without a subfolder and setting the --PidFile option that is also needed with your updated approach (see tor_v1.patch). i would still prefer v2 patch as it ignores the value of torrc and just creates a file in /var/run. it is simpler and as nearly no user cares about the pid file it even uses less memory as no dir is created ;) and the init file is much smaller and simpler. I would perfer that tor gets stopped on shutdown because when extroot is used it will result in an unclean umounted fs. What do you think? :) Hasta luego, Peter On Dienstag, 15. November 2011 22:46:12 Nico wrote: > Hi Peter & the List, > > On Tue, Nov 15, 2011 at 2:40 AM, Peter Wagner <tripo...@gmx.at> wrote: > > Hi, > > > > the current tor init script that uses the new service wrapper is broken. > > It is working fine here. From our discussion on IRC, I suspect your > issue was related to a free space problem on /tmp. > > Anyway, looking at your patch, I thought it might me good to have tor > & its initscript share the same idea of what the pid-file is (patch > enclosed) > > What do you think ? > > Cheers, > -- > -{Nico}
diff --git a/net/tor/files/tor.init b/net/tor/files/tor.init index 42eff1a..95a6314 100644 --- a/net/tor/files/tor.init +++ b/net/tor/files/tor.init @@ -2,15 +2,23 @@ # Copyright (C) 2006-2011 OpenWrt.org START=50 +STOP=50 -SERVICE_PID_FILE=/var/run/tor/tor.pid +SERVICE_USE_PID=1 + +lookup_pid_file() { + local f="$(grep '^PidFile' /etc/tor/torrc|awk '{ print $2; }' 2>/dev/null)" + SERVICE_PID_FILE="${f:-/var/run/tor/tor.pid}" + TOR_PATH="$(echo ${SERVICE_PID_FILE}|awk -F/ -vOFS=/ '{ $NF=""; print $0; }' 2>/dev/null)" +} start() { - user_exists tor 52 || user_add tor 52 + user_exists tor 52 || user_add tor 52 52 /var/lib/tor group_exists tor 52 || group_add tor 52 - [ -d /var/run/tor ] || { - mkdir -m 0755 -p /var/run/tor - chown tor:tor /var/run/tor + lookup_pid_file + [ -d ${TOR_PATH} ] || { + mkdir -m 0755 -p $TOR_PATH + chown tor:tor $TOR_PATH } [ -d /var/lib/tor ] || { mkdir -m 0755 -p /var/lib/tor @@ -21,9 +29,10 @@ start() { mkdir -m 0755 -p /var/log/tor chown tor:tor /var/log/tor } - service_start /usr/sbin/tor + service_start /usr/sbin/tor --PidFile ${SERVICE_PID_FILE} } stop() { + lookup_pid_file service_stop /usr/sbin/tor }
diff --git a/net/tor/files/tor.init b/net/tor/files/tor.init index 42eff1a..8d11089 100644 --- a/net/tor/files/tor.init +++ b/net/tor/files/tor.init @@ -2,15 +2,16 @@ # Copyright (C) 2006-2011 OpenWrt.org START=50 +STOP=50 -SERVICE_PID_FILE=/var/run/tor/tor.pid +SERVICE_USE_PID=1 start() { - user_exists tor 52 || user_add tor 52 + user_exists tor 52 || user_add tor 52 52 /var/lib/tor group_exists tor 52 || group_add tor 52 - [ -d /var/run/tor ] || { - mkdir -m 0755 -p /var/run/tor - chown tor:tor /var/run/tor + [ -f /var/run/tor.pid ] || { + touch /var/run/tor.pid + chown tor:tor /var/run/tor.pid } [ -d /var/lib/tor ] || { mkdir -m 0755 -p /var/lib/tor @@ -21,7 +22,7 @@ start() { mkdir -m 0755 -p /var/log/tor chown tor:tor /var/log/tor } - service_start /usr/sbin/tor + service_start /usr/sbin/tor --PidFile /var/run/tor.pid } stop() {
_______________________________________________ openwrt-devel mailing list openwrt-devel@lists.openwrt.org https://lists.openwrt.org/mailman/listinfo/openwrt-devel