[Pkg-privacy-commits] [txtorcon] 72/96: HiddenServiceDir should be absolute. Test also added
Jérémy Bobbio
lunar at moszumanska.debian.org
Sun Sep 6 18:33:41 UTC 2015
This is an automated email from the git hooks/post-receive script.
lunar pushed a commit to branch master
in repository txtorcon.
commit 43bbef7cfdabaceecc7604adbe1af52062353c9a
Author: Sambuddha Basu <sambuddhabasu1 at gmail.com>
Date: Sun Feb 15 19:07:19 2015 +0530
HiddenServiceDir should be absolute. Test also added
Updated directory absolute path to work with even one directory
---
test/test_torconfig.py | 5 +++++
txtorcon/torconfig.py | 8 ++++++++
2 files changed, 13 insertions(+)
diff --git a/test/test_torconfig.py b/test/test_torconfig.py
index a431a1e..b037572 100644
--- a/test/test_torconfig.py
+++ b/test/test_torconfig.py
@@ -762,6 +762,11 @@ HiddenServicePort=90 127.0.0.1:2345''')
except RuntimeError, e:
self.assertTrue('parse' in str(e))
+ def test_hidden_service_directory_absolute_path(self):
+ conf = TorConfig(FakeControlProtocol(['config/names=']))
+ conf._setup_hidden_services('HiddenServiceDir=/fake/path/../path')
+ self.assertEqual(len(self.flushWarnings()), 1)
+
def test_multiple_modify_hidden_service(self):
self.protocol.answers.append('HiddenServiceDir=/fake/path\nHiddenServicePort=80 127.0.0.1:1234\n')
diff --git a/txtorcon/torconfig.py b/txtorcon/torconfig.py
index ef3cfe5..784d1e7 100644
--- a/txtorcon/torconfig.py
+++ b/txtorcon/torconfig.py
@@ -6,6 +6,7 @@ import string
import types
import functools
import tempfile
+import warnings
from StringIO import StringIO
import shlex
if sys.platform in ('linux2', 'darwin'):
@@ -1117,6 +1118,13 @@ class TorConfig(object):
)
)
directory = v
+ _directory = directory
+ directory = os.path.abspath(directory)
+ if directory != _directory:
+ warnings.warn(
+ "Directory path: %s changed to absolute path: %s" % (_directory, directory),
+ RuntimeWarning
+ )
ports = []
ver = None
auth = None
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-privacy/packages/txtorcon.git
More information about the Pkg-privacy-commits
mailing list