summaryrefslogtreecommitdiffstats
path: root/base/server/python
diff options
context:
space:
mode:
authorEndi S. Dewata <edewata@redhat.com>2016-05-24 03:13:52 +0200
committerEndi S. Dewata <edewata@redhat.com>2016-05-24 04:03:56 +0200
commitf1eef2654de9d2c32f25db4b2d7dccd7fa49b26a (patch)
tree2999410f3f56c5804cf08253f1c94c221e352b99 /base/server/python
parentc6c1d96a4454ffc3849e8e89c48a1ae74cc345a7 (diff)
downloadpki-f1eef2654de9d2c32f25db4b2d7dccd7fa49b26a.tar.gz
pki-f1eef2654de9d2c32f25db4b2d7dccd7fa49b26a.tar.xz
pki-f1eef2654de9d2c32f25db4b2d7dccd7fa49b26a.zip
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
Diffstat (limited to 'base/server/python')
-rw-r--r--base/server/python/pki/server/__init__.py13
1 files changed, 11 insertions, 2 deletions
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