1 |
commit: b8a558a87e3b1242cc6c7b746fcf9d2ce70a9b75 |
2 |
Author: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Aug 30 11:30:15 2011 +0000 |
4 |
Commit: Anthony G. Basile <blueness <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Aug 30 11:30:15 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=dev/blueness.git;a=commit;h=b8a558a8 |
7 |
|
8 |
net-misc/tor: make tor.initd-r5 checkvarrun fool proof |
9 |
|
10 |
--- |
11 |
net-misc/tor/ChangeLog | 3 +++ |
12 |
net-misc/tor/files/tor.initd-r5 | 33 +++++++++++++++++++++++---------- |
13 |
2 files changed, 26 insertions(+), 10 deletions(-) |
14 |
|
15 |
diff --git a/net-misc/tor/ChangeLog b/net-misc/tor/ChangeLog |
16 |
index 051ef02..31c4316 100644 |
17 |
--- a/net-misc/tor/ChangeLog |
18 |
+++ b/net-misc/tor/ChangeLog |
19 |
@@ -2,6 +2,9 @@ |
20 |
# Copyright 1999-2011 Gentoo Foundation; Distributed under the GPL v2 |
21 |
# $Header: /var/cvsroot/gentoo-x86/net-misc/tor/ChangeLog,v 1.269 2011/08/28 11:15:42 blueness Exp $ |
22 |
|
23 |
+ 30 Aug 2011; Anthony G. Basile <blueness@g.o> files/tor.initd-r5: |
24 |
+ Make tor.initd-r5 checkvarrun fool proof |
25 |
+ |
26 |
30 Aug 2011; Anthony G. Basile <blueness@g.o> files/torrc-r1, |
27 |
files/torrc.sample.patch: |
28 |
Remove obsolete configuration option 'Group' |
29 |
|
30 |
diff --git a/net-misc/tor/files/tor.initd-r5 b/net-misc/tor/files/tor.initd-r5 |
31 |
index f55fefb..d27a411 100644 |
32 |
--- a/net-misc/tor/files/tor.initd-r5 |
33 |
+++ b/net-misc/tor/files/tor.initd-r5 |
34 |
@@ -3,14 +3,33 @@ |
35 |
# Distributed under the terms of the GNU General Public License v2 |
36 |
# $Header: /var/cvsroot/gentoo-x86/net-misc/tor/files/tor.initd-r4,v 1.7 2011/08/23 12:26:36 blueness Exp $ |
37 |
|
38 |
-opts="${opts} checkconfig reload" |
39 |
-PIDFILE=/var/run/tor/tor.pid |
40 |
-CONFFILE=/etc/tor/torrc |
41 |
+opts="${opts} checkconfig checkvarrun reload" |
42 |
+PIDDIR="/var/run/tor" |
43 |
+PIDFILE="${PIDDIR}/tor.pid" |
44 |
+CONFFILE="/etc/tor/torrc" |
45 |
|
46 |
depend() { |
47 |
need net |
48 |
} |
49 |
|
50 |
+checkvarrun() |
51 |
+{ |
52 |
+ # Check if /var/run/tor exists, create it if it doesn't |
53 |
+ [ ! -d /var/run/tor ] && mkdir -p /var/run/tor |
54 |
+ [ ! -d /var/run/tor ] && return 1 |
55 |
+ |
56 |
+ # The directory definitly exists now, but does it belong to tor? |
57 |
+ find ${PIDDIR} -maxdepth 0 -a -user tor -a -group tor >/dev/null && chown tor:tor ${PIDDIR} |
58 |
+ find ${PIDDIR} -maxdepth 0 -a -user tor -a -group tor >/dev/null && return 1 |
59 |
+ |
60 |
+ # And does it have the right perms? |
61 |
+ find ${PIDDIR} -maxdepth 0 -perm 0755 >/dev/null && chmod 0755 /var/run/tor |
62 |
+ find ${PIDDIR} -maxdepth 0 -perm 0755 >/dev/null && return 1 |
63 |
+ |
64 |
+ # If any of the above failed, we would not be here |
65 |
+ return 0 |
66 |
+} |
67 |
+ |
68 |
checkconfig() { |
69 |
# first check that it exists |
70 |
if [ ! -f ${CONFFILE} ] ; then |
71 |
@@ -29,17 +48,11 @@ checkconfig() { |
72 |
/usr/bin/tor --verify-config -f ${CONFFILE} |
73 |
return 1 |
74 |
fi |
75 |
- |
76 |
- # finally check if /var/run/tor exists and belongs to tor:tor |
77 |
- if [ ! -d /var/run/tor ] ; then |
78 |
- mkdir -p /var/run/tor |
79 |
- chown tor:tor /var/run/tor |
80 |
- chmod 0755 /var/run/tor |
81 |
- fi |
82 |
} |
83 |
|
84 |
start() { |
85 |
checkconfig || return 1 |
86 |
+ checkvarrun || return 1 |
87 |
ebegin "Starting Tor" |
88 |
HOME=/var/lib/tor |
89 |
start-stop-daemon --start --pidfile "${PIDFILE}" --quiet --exec /usr/bin/tor -- -f "${CONFFILE}" --runasdaemon 1 --PidFile "${PIDFILE}" > /dev/null 2>&1 |