Package: tor
Version: 0.2.3.25-1
Severity: wishlist
File: /etc/init.d/tor
Tags: patch

Dear Maintainer (you are awesome),

So I run /var/log on a tmpfs, which means at restart, it is empty. Most
programs will recreate their logfiles in the absence of any old files or
directories, but Tor will fail with the following error

> Starting tor daemon...
> [warn] Couldn't open file for 'Log notice file /var/log/tor/notice.log': No 
> such file or directory
> [warn] Failed to parse/validate config: Failed to init Log options. See logs 
> for details.
> [err] Reading config failed--see warnings above.
 
Tor's init.d script already handles a missing /var/run/tor/ directory by
creating a new one, so I thought it might be useful for the same script
to re-create a missing /var/log/tor directory. Patch is included below.

The additional function is based on the /var/run/tor action.

d.

-- System Information:
Debian Release: 7.0
  APT prefers testing
  APT policy: (500, 'testing'), (500, 'stable')
Architecture: amd64 (x86_64)
Foreign Architectures: i386

Kernel: Linux 3.11-2-amd64 (SMP w/4 CPU cores)
Locale: LANG=en_US.utf8, LC_CTYPE=en_US.utf8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/dash

Versions of packages tor depends on:
ii  adduser         3.113+nmu3
ii  libc6           2.17-2
ii  libevent-2.0-5  2.0.19-stable-3
ii  libssl1.0.0     1.0.1e-2
ii  lsb-base        4.1+Debian9
ii  zlib1g          1:1.2.7.dfsg-13

Versions of packages tor recommends:
ii  logrotate    3.8.3-3
ii  tor-geoipdb  0.2.3.25-1
ii  torsocks     1.2-3

Versions of packages tor suggests:
pn  apparmor-utils     <none>
pn  mixmaster          <none>
ii  privoxy            3.0.20-1
ii  socat              1.7.1.3-1.4
pn  tor-arm            <none>
ii  xul-ext-torbutton  1.4.6.3-1

-- Configuration Files:
/etc/init.d/tor changed 

-- no debconf information
--- /home/danny/tmp/tor	2013-12-18 13:41:17.884898842 -0800
+++ /etc/init.d/tor	2013-12-18 13:38:14.321388245 -0800
@@ -24,6 +24,7 @@
 DAEMON=/usr/sbin/tor
 NAME=tor
 DESC="tor daemon"
+TORLOGDIR=/var/log/tor
 TORPIDDIR=/var/run/tor
 TORPID=$TORPIDDIR/tor.pid
 DEFAULTSFILE=/etc/default/$NAME
@@ -108,6 +109,15 @@
 	fi
 }
 
+check_torlogdir () {
+	if test ! -d $TORLOGDIR; then
+		mkdir -m 02750 "$TORLOGDIR"
+		chown debian-tor:adm "$TORLOGDIR"
+		! [ -x /sbin/restorecon ] || /sbin/restorecon "$TORPIDDIR"
+	fi
+}
+
+
 check_config () {
 	if ! $DAEMON $VERIFY_ARGS > /dev/null; then
 		log_failure_msg "Checking if $NAME configuration is valid"
@@ -134,6 +144,7 @@
 	fi
 
 	check_torpiddir
+	check_torlogdir
 	check_config
 
 	log_action_begin_msg "Starting $DESC"

Reply via email to