Skip to content

Commit 7f7f3c1

Browse files
committed
Implemented fix for issue #341
1 parent a949810 commit 7f7f3c1

File tree

1 file changed

+17
-29
lines changed

1 file changed

+17
-29
lines changed

debian/tor2web.init

Lines changed: 17 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ DAEMON_USER=tor2web
2929

3030
DAEMON_ARGS="--pidfile ${DAEMON_PIDFILE} --uid ${DAEMON_USER} --gid ${DAEMON_USER}"
3131

32-
DAEMON_CMD="$DAEMON $DAEMON_ARGS"
32+
STARTCMD="$DAEMON $DAEMON_ARGS"
3333

3434
SCRIPTNAME=$0
3535

@@ -98,32 +98,20 @@ else
9898
fi
9999

100100
if [ -d "/etc/letsencrypt/live" ] && [ -d "/etc/letsencrypt/archive" ]; then
101-
echo "Letsencrypt detected, fixing permission for /etc/letsencrypt/{live,archive} for $DAEMON_USER user"
102-
chgrp $DAEMON_USER /etc/letsencrypt/live/
103-
chgrp $DAEMON_USER /etc/letsencrypt/archive
104-
chmod g+rx /etc/letsencrypt/archive
105-
chmod g+rx /etc/letsencrypt/live
101+
echo "Letsencrypt detected, fixing permission for /etc/letsencrypt/{live,archive} for $DAEMON_USER user"
102+
chgrp $DAEMON_USER /etc/letsencrypt/live/
103+
chgrp $DAEMON_USER /etc/letsencrypt/archive
104+
chmod g+rx /etc/letsencrypt/archive
105+
chmod g+rx /etc/letsencrypt/live
106+
fi
107+
108+
if [[ "$APPARMOR_SANDBOXING" -eq "1" && "$(cat /sys/module/apparmor/parameters/enabled 2>/dev/null)" != 'Y' ]]; then
109+
echo "WARNING: Missing Apparmor Sandboxing support"
110+
APPARMOR_SANDBOXING=0
106111
fi
107112

108113
if [ "${APPARMOR_SANDBOXING}" -eq "1" ]; then
109-
APPARMOR_STARTED=0
110-
111-
log_action_begin_msg "Enabling Tor2web Apparmor Sandboxing"
112-
113-
test -x /usr/sbin/aa-status \
114-
&& test -x /usr/sbin/aa-exec \
115-
&& test -e /etc/apparmor.d/usr.bin.tor2web \
116-
&& /usr/sbin/aa-status --enabled \
117-
&& DAEMON_CMD="/usr/sbin/aa-exec --profile=usr.bin.tor2web -- ${DAEMON_CMD}" \
118-
&& APPARMOR_STARTED=1
119-
120-
if [ "${APPARMOR_STARTED}" -eq "0" ]; then
121-
log_action_end_msg 1 "Unable to initialize AppArmor!"
122-
echo "Unable to initialize AppArmor!"
123-
echo "AppArmor is probably disabled; please enable it by following instructions at https://wiki.debian.org/AppArmor/HowToUse"
124-
echo "If you understand the risks involved and you know what you are doing, you can disable Tor2web's Apparmor support by editing /etc/default/tor2web and configuring APPARMOR_SANDBOXING=0"
125-
exit 1
126-
fi
114+
STARTCMD="aa-exec --profile=usr.bin.tor2web -- $STARTCMD"
127115
fi
128116

129117
do_t2w_start()
@@ -133,14 +121,14 @@ do_t2w_start()
133121
fi
134122

135123
# Check to see if the daemon is already running.
136-
$DAEMON_CMD --command=status
124+
$STARTCMD --command=status
137125
RETVAL=$?
138126
if [ $RETVAL -eq 0 ]; then
139127
log_end_msg 0 "already running"
140128
exit 0
141129
fi
142130

143-
$DAEMON_CMD --command=start
131+
$STARTCMD --command=start
144132
RETVAL=$?
145133
if [ $RETVAL -ne 0 ]; then
146134
log_end_msg 1 "couldn't start"
@@ -150,17 +138,17 @@ do_t2w_start()
150138

151139
do_t2w_stop()
152140
{
153-
$DAEMON_CMD --command=stop
141+
$STARTCMD --command=stop
154142
}
155143

156144
do_t2w_reload()
157145
{
158-
$DAEMON_CMD --command=reload
146+
$STARTCMD --command=reload
159147
}
160148

161149
do_t2w_status()
162150
{
163-
$DAEMON_CMD --command=status
151+
$STARTCMD --command=status
164152
RETVAL=$?
165153
if [ $RETVAL -eq 1 ]; then
166154
log_failure_msg "Tor2web is not running"

0 commit comments

Comments
 (0)