Don't open subdirectories rootwrap filter directories
A rootwrap filter directory may contain subdirectories. The rootwrap daemon will crash when it tries to load filters from subdirectories. So subdirectories should be skipped. Change-Id: I4f618734300bf5eb81282fbf8fc213f995a4fe59
This commit is contained in:
parent
1335a543be
commit
0694fbc7a9
@ -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]
|
||||
|
@ -117,9 +117,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)
|
||||
|
Loading…
Reference in New Issue
Block a user