Alon Bar-Lev has uploaded a new change for review.

Change subject: packaging: setup: postgres provision: generate only ASCII 
password
......................................................................

packaging: setup: postgres provision: generate only ASCII password

python string module is locale aware, so generating letter in non
unicode locale will result non unicode password, unreadable by java.

instead of using the string module, use hardcoded known good characters.

Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1035932
Change-Id: I1b27d8eb26c777617ff3bf625b979a75bc3225c6
Signed-off-by: Alon Bar-Lev <alo...@redhat.com>
---
M packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py
1 file changed, 7 insertions(+), 5 deletions(-)


  git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/63/21863/1

diff --git 
a/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py 
b/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py
index bf4d665..5e438fc 100644
--- a/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py
+++ b/packaging/setup/plugins/ovirt-engine-setup/provisioning/postgres.py
@@ -25,7 +25,6 @@
 import random
 import datetime
 import time
-import string
 import gettext
 _ = lambda m: gettext.dgettext(message=m, domain='ovirt-engine-setup')
 
@@ -46,6 +45,12 @@
 @util.export
 class Plugin(plugin.PluginBase):
     """Local Postgres plugin."""
+
+    _PASSWORD_CHARS = (
+        '0123456789' +
+        'ABCDEFGHIJKLMNOPQRSTUVWXYZ' +
+        'abcdefghijklmnopqrstuvwxyz'
+    )
 
     _RE_POSTGRES_PGHBA_LOCAL = re.compile(
         flags=re.VERBOSE,
@@ -71,10 +76,7 @@
             os.seteuid(os.getuid())
 
     def _generatePassword(self):
-        return '%s%s' % (
-            ''.join([random.choice(string.digits) for i in range(4)]),
-            ''.join([random.choice(string.letters) for i in range(4)]),
-        )
+        return ''.join([random.choice(self._PASSWORD_CHARS) for i in range(8)])
 
     def _initDB(self):
         self.logger.info(_('Initializing PostgreSQL'))


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

Gerrit-MessageType: newchange
Gerrit-Change-Id: I1b27d8eb26c777617ff3bf625b979a75bc3225c6
Gerrit-PatchSet: 1
Gerrit-Project: ovirt-engine
Gerrit-Branch: ovirt-engine-3.3.2
Gerrit-Owner: Alon Bar-Lev <alo...@redhat.com>
_______________________________________________
Engine-patches mailing list
Engine-patches@ovirt.org
http://lists.ovirt.org/mailman/listinfo/engine-patches

Reply via email to