Control: tags -1 + patch

I suspect this untested patch will solve the issue.

diff --git a/actions/tor b/actions/tor
index 5e9b49c..03fec5a 100755
--- a/actions/tor
+++ b/actions/tor
@@ -24,10 +24,13 @@ Configuration helper for the Tor service
 import argparse
 import os
 import subprocess
+import pwd
+import grp
 
 SERVICE_CONFIG = '/etc/default/tor'
 TOR_CONFIG = '/etc/tor/torrc'
 
+hiddenpath = "/var/lib/tor/hidden_service"
 
 def parse_arguments():
     """Return parsed command line arguments as dictionary"""
@@ -99,7 +102,7 @@ def subcommand_enable_hs(_):
         lines = conffile.readlines()
 
     lines.append('# Hidden Service configured by Plinth\n')
-    lines.append('HiddenServiceDir /var/lib/tor/hidden_service/\n')
+    lines.append('HiddenServiceDir %s/\n' % hiddenpath)
     lines.append('HiddenServicePort 80 127.0.0.1:80\n')
     lines.append('HiddenServicePort 443 127.0.0.1:443\n')
     lines.append('# end of Plinth Hidden Service config\n')
@@ -107,6 +110,16 @@ def subcommand_enable_hs(_):
     with open(TOR_CONFIG, 'w') as conffile:
         conffile.writelines(lines)
 
+    try:
+        os.makedirs(path, 0700)
+        os.chown(hiddenpath,
+                 getpwnam("debian-tor").pw_uid,
+                 grp.getgrnam("debian-tor").gr_gid=0)
+    except OSError as e:
+        if e.errno == errno.EEXIST and os.path.isdir(path):
+            pass
+        else: raise
+
     subprocess.call(['service', 'tor', 'restart'])
 
 
Is this a good approach for fixing the problem?  An alternative is to
do it in freedombox-setup at build time.

-- 
Happy hacking
Petter Reinholdtsen


-- 
To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org
with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org

Reply via email to