commit 359f1cd4c874ed23978cbd3d8e3c4aa71178f381
Author: Thomas Woerner <twoerner@redhat.com>
Date: Mon Aug 1 15:19:53 2016 +0200
firewall.core.io.ifcfg.py: Fix ifcfg file reader and writer (RHBZ#1362171)
The reader should not report duplicate settings and also bad settings as
warnings only additionally with a bit more information about beeing an ifcfg
file issue.
The writer should not duplicate lines containing more than one "=".
diff --git a/src/firewall/core/io/ifcfg.py b/src/firewall/core/io/ifcfg.py
index 07864d5..e145f49 100644
--- a/src/firewall/core/io/ifcfg.py
+++ b/src/firewall/core/io/ifcfg.py
@@ -80,17 +80,14 @@ class ifcfg(object):
# get key/value pair
pair = [ x.strip() for x in line.split("=", 1) ]
if len(pair) != 2:
- log.error("Invalid option definition: '%s'", line.strip())
+ log.warning("%: Invalid option definition: '%s'", self.filename, line.strip())
continue
elif pair[1] == '':
continue
elif self._config.get(pair[0]) is not None:
- log.error("Duplicate option definition: '%s'", line.strip())
+ log.warning("%s: Duplicate option definition: '%s'", self.filename, line.strip())
continue
- if pair[1][0] == '"' and pair[1][-1] == '"':
- self._config[pair[0]] = pair[1][1:-1]
- else:
- self._config[pair[0]] = pair[1]
+ self._config[pair[0]] = pair[1]
f.close()
def write(self):
@@ -139,7 +136,7 @@ class ifcfg(object):
temp_file.write(line)
temp_file.write(u"\n")
else:
- p = line.split("=")
+ p = line.split("=", 1)
if len(p) != 2:
empty = False
temp_file.write(line+u"\n")