From f1eef2654de9d2c32f25db4b2d7dccd7fa49b26a Mon Sep 17 00:00:00 2001 From: "Endi S. Dewata" Date: Tue, 24 May 2016 03:13:52 +0200 Subject: Ignoring blank and comment lines in configuration files. The PKISubsystem.load() and PKIInstance.load() have been modified to ignore blank and comment lines in CS.cfg and password.conf. If the code fails to parse a line it will throw an exception showing the location of the invalid line. https://fedorahosted.org/pki/ticket/2314 --- base/server/python/pki/server/__init__.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'base/server/python') diff --git a/base/server/python/pki/server/__init__.py b/base/server/python/pki/server/__init__.py index 1c590c37e..47f6aa5b4 100644 --- a/base/server/python/pki/server/__init__.py +++ b/base/server/python/pki/server/__init__.py @@ -123,8 +123,12 @@ class PKISubsystem(object): lines = open(self.cs_conf).read().splitlines() - for line in lines: + for index, line in enumerate(lines): + if not line or line.startswith('#'): + continue parts = line.split('=', 1) + if len(parts) < 2: + raise Exception('Missing delimiter in %s line %d' % (self.cs_conf, index + 1)) name = parts[0] value = parts[1] self.config[name] = value @@ -473,8 +477,13 @@ class PKIInstance(object): lines = open(self.password_conf).read().splitlines() - for line in lines: + for index, line in enumerate(lines): + if not line or line.startswith('#'): + continue parts = line.split('=', 1) + if len(parts) < 2: + raise Exception('Missing delimiter in %s line %d' % + (self.password_conf, index + 1)) name = parts[0] value = parts[1] self.passwords[name] = value -- cgit