Yedidyah Bar David has uploaded a new change for review.

Change subject: packaging: setup: less strict parsing of pg_hba.conf
......................................................................

packaging: setup: less strict parsing of pg_hba.conf

When checking the 'local' line, do not check exact spaces.

Code partially copied from engine.

Bug-Url: https://bugzilla.redhat.com/1084760
Change-Id: I374d578735c910451bc7698444a446728b33fd58
Signed-off-by: Yedidyah Bar David <[email protected]>
---
M packaging/common_utils.py
1 file changed, 19 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-dwh refs/changes/28/26528/1

diff --git a/packaging/common_utils.py b/packaging/common_utils.py
index fc8d0e1..49f2848 100755
--- a/packaging/common_utils.py
+++ b/packaging/common_utils.py
@@ -1404,28 +1404,31 @@
     with open(FILE_PG_HBA, 'w') as pghba:
         pghba.write('\n'.join(content))
 
+_RE_POSTGRES_PGHBA_LOCAL = re.compile(
+    flags=re.VERBOSE,
+    pattern=r"""
+        ^
+        (?P<host>local)
+        \s+
+        .*
+        \s+
+        (?P<param>\w+)
+        $
+    """,
+)
+
 def configHbaIdent(orig='md5', newval='ident'):
     content = []
     logging.debug('Updating pghba postgres use')
-    contentline = (
-        'local   '
-        'all         '
-        'all                               '
-        '{value}'
-    )
 
     with open(FILE_PG_HBA, 'r') as pghba:
         for line in pghba.read().splitlines():
-            if line.startswith(
-                contentline.format(value=newval)
-            ):
-                return False
-
-            if line.startswith(
-                contentline.format(value=orig)
-            ):
-                line=contentline.format(value=newval)
-
+            matcher = _RE_POSTGRES_PGHBA_LOCAL.match(line)
+            if matcher is not None:
+                if matcher.group('param') == newval:
+                    return False
+                if matcher.group('param') == orig:
+                    line = line.replace(matcher.group('param'), newval)
             content.append(line)
 
     with open(FILE_PG_HBA, 'w') as pghba:


-- 
To view, visit http://gerrit.ovirt.org/26528
To unsubscribe, visit http://gerrit.ovirt.org/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I374d578735c910451bc7698444a446728b33fd58
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-dwh
Gerrit-Branch: ovirt-3.3
Gerrit-Owner: Yedidyah Bar David <[email protected]>
_______________________________________________
Engine-patches mailing list
[email protected]
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to