Blame SOURCES/firewalld-0.4.3.2-ifcfg-parser_rhbz#1362171.patch

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