I don't think it's necessary to create the folder for the hidden service.
Tor should do that when it starts up (but in your case it did not start
successfully).

I think we just need to add some guard code in case we can't open the
torrc or hidden service folder. (This doesn't solve the Tor configuration
problem but it should allow Plinth to keep working.)

diff --git a/actions/tor b/actions/tor
index f0744cc..955e12a 100755
--- a/actions/tor
+++ b/actions/tor
@@ -190,18 +190,24 @@ def get_hidden_service():
     hs_dir = None
     hs_ports = []
 
-    with open(TOR_CONFIG, 'r') as conf_file:
-        for line in conf_file:
-            if line.startswith('HiddenServiceDir'):
-                hs_dir = line.split()[1]
-            elif line.startswith('HiddenServicePort'):
-                hs_ports.append(line.split()[1])
+    try:
+        with open(TOR_CONFIG, 'r') as conf_file:
+            for line in conf_file:
+                if line.startswith('HiddenServiceDir'):
+                    hs_dir = line.split()[1]
+                elif line.startswith('HiddenServicePort'):
+                    hs_ports.append(line.split()[1])
+    except Exception:
+        return ''
 
     if not hs_dir:
         return ''
 
-    with open(os.path.join(hs_dir, 'hostname'), 'r') as conf_file:
-        hs_hostname = conf_file.read().strip()
+    try:
+        with open(os.path.join(hs_dir, 'hostname'), 'r') as conf_file:
+            hs_hostname = conf_file.read().strip()
+    except Exception:
+        return ''
 
     return hs_hostname + ' ' + ','.join(hs_ports)


-- 
To UNSUBSCRIBE, email to [email protected]
with a subject of "unsubscribe". Trouble? Contact [email protected]

Reply via email to