summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJenkins <jenkins@review.openstack.org>2017-03-02 21:58:29 +0000
committerGerrit Code Review <review@openstack.org>2017-03-02 21:58:29 +0000
commita9ad4ec0f95b82b8a10e1e04917516240840718f (patch)
tree75b4b6494485a3ebafaa35b1e7b1edf1f3c5e391
parent3d3d3237c81ae5a3ae3d49892eb16ad5c949d251 (diff)
parent0694fbc7a965ca3bcadeaadd3897581f07c6c5e9 (diff)
downloadoslo-rootwrap-a9ad4ec0f95b82b8a10e1e04917516240840718f.tar.gz
Merge "Don't open subdirectories rootwrap filter directories"
-rw-r--r--oslo_rootwrap/tests/test_rootwrap.py1
-rw-r--r--oslo_rootwrap/wrapper.py5
2 files changed, 5 insertions, 1 deletions
diff --git a/oslo_rootwrap/tests/test_rootwrap.py b/oslo_rootwrap/tests/test_rootwrap.py
index fb8f804..13c7282 100644
--- a/oslo_rootwrap/tests/test_rootwrap.py
+++ b/oslo_rootwrap/tests/test_rootwrap.py
@@ -46,6 +46,7 @@ class RootwrapLoaderTestCase(testtools.TestCase):
def test_strict_switched_off_in_configparser(self):
temp_dir = self.useFixture(fixtures.TempDir()).path
+ os.mkdir(os.path.join(temp_dir, 'nested'))
temp_file = os.path.join(temp_dir, 'test.conf')
f = open(temp_file, 'w')
f.write("""[Filters]
diff --git a/oslo_rootwrap/wrapper.py b/oslo_rootwrap/wrapper.py
index 49fdac3..6a96e1a 100644
--- a/oslo_rootwrap/wrapper.py
+++ b/oslo_rootwrap/wrapper.py
@@ -120,9 +120,12 @@ def load_filters(filters_path):
continue
for filterfile in filter(lambda f: not f.startswith('.'),
os.listdir(filterdir)):
+ filterfilepath = os.path.join(filterdir, filterfile)
+ if not os.path.isfile(filterfilepath):
+ continue
kwargs = {"strict": False} if six.PY3 else {}
filterconfig = moves.configparser.RawConfigParser(**kwargs)
- filterconfig.read(os.path.join(filterdir, filterfile))
+ filterconfig.read(filterfilepath)
for (name, value) in filterconfig.items("Filters"):
filterdefinition = [s.strip() for s in value.split(',')]
newfilter = build_filter(*filterdefinition)