summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2016-12-23 05:00:55 +0000
committerGerrit Code Review <review@openstack.org>2016-12-23 05:00:55 +0000
commit698ce0b5161e0fa4453d41eb5af05174ddfb283a (patch)
tree9da0596c4b4efd598479d34e28d9c686c607843f
parent9e9631369082485823259e5cd14f99701cca6f26 (diff)
parent7a2610d6d61529e653697117e829312b230a001a (diff)
downloadoslo-rootwrap-698ce0b5161e0fa4453d41eb5af05174ddfb283a.tar.gz
Merge "Relax default strict option under python3.x for configparser"5.4.05.3.1
-rw-r--r--oslo_rootwrap/tests/test_rootwrap.py12
-rw-r--r--oslo_rootwrap/wrapper.py4
2 files changed, 15 insertions, 1 deletions
diff --git a/oslo_rootwrap/tests/test_rootwrap.py b/oslo_rootwrap/tests/test_rootwrap.py
index 200c4f0..fb8f804 100644
--- a/oslo_rootwrap/tests/test_rootwrap.py
+++ b/oslo_rootwrap/tests/test_rootwrap.py
@@ -44,6 +44,18 @@ class RootwrapLoaderTestCase(testtools.TestCase):
self.assertEqual(["/fake/privsep-helper", "--context", "foo"],
filtermatch.get_command(privsep))
+ def test_strict_switched_off_in_configparser(self):
+ temp_dir = self.useFixture(fixtures.TempDir()).path
+ temp_file = os.path.join(temp_dir, 'test.conf')
+ f = open(temp_file, 'w')
+ f.write("""[Filters]
+privsep: PathFilter, privsep-helper, root
+privsep: PathFilter, privsep-helper, root
+""")
+ f.close()
+ filterlist = wrapper.load_filters([temp_dir])
+ self.assertIsNotNone(filterlist)
+
class RootwrapTestCase(testtools.TestCase):
if os.path.exists('/sbin/ip'):
diff --git a/oslo_rootwrap/wrapper.py b/oslo_rootwrap/wrapper.py
index cd7a253..998beae 100644
--- a/oslo_rootwrap/wrapper.py
+++ b/oslo_rootwrap/wrapper.py
@@ -19,6 +19,7 @@ import os
import pwd
import signal
+import six
from six import moves
from oslo_rootwrap import filters
@@ -116,7 +117,8 @@ def load_filters(filters_path):
continue
for filterfile in filter(lambda f: not f.startswith('.'),
os.listdir(filterdir)):
- filterconfig = moves.configparser.RawConfigParser()
+ kwargs = {"strict": False} if six.PY3 else {}
+ filterconfig = moves.configparser.RawConfigParser(**kwargs)
filterconfig.read(os.path.join(filterdir, filterfile))
for (name, value) in filterconfig.items("Filters"):
filterdefinition = [s.strip() for s in value.split(',')]