Alon Bar-Lev has uploaded a new change for review. Change subject: packaging: setup: database: support ':' within password ......................................................................
packaging: setup: database: support ':' within password at least in rhel postgresql 8.4 the pgpassfile is not read according to documentation, the password is read as plain, postgresql 9 seems to respect the documentation. this behavior is handled by client side postgresql libraries, the simplest way to detect what library we use is to query psql utility version. [1] http://www.postgresql.org/docs/8.4/static/libpq-pgpass.html Bug-Url: https://bugzilla.redhat.com/show_bug.cgi?id=1064428 Change-Id: I866680c853c1e1978d55828ff4efd710a1003f9a Signed-off-by: Alon Bar-Lev <[email protected]> --- M packaging/bin/engine-backup.sh M packaging/setup/ovirt_engine_setup/database.py 2 files changed, 43 insertions(+), 4 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/51/24451/1 diff --git a/packaging/bin/engine-backup.sh b/packaging/bin/engine-backup.sh index 01a931a..18dd4d9 100755 --- a/packaging/bin/engine-backup.sh +++ b/packaging/bin/engine-backup.sh @@ -412,11 +412,26 @@ } generatePgPass() { + local password="${ENGINE_DB_PASSWORD}" MYPGPASS="${TEMP_FOLDER}/.pgpass" + touch "${MYPGPASS}" || logdie "Can't touch ${MYPGPASS}" chmod 0600 "${MYPGPASS}" || logdie "Can't chmod ${MYPGPASS}" + + # + # we need client side psql library + # version as at least in rhel for 8.4 + # the password within pgpassfile is + # not escaped. + # the simplest way is to checkout psql + # utility version. + # + if ! psql -V | grep -q ' 8\.'; then + password="$(echo "${password}" | sed -e 's/\\/\\\\/g' -e 's/:/\\:/g')" + fi + cat > "${MYPGPASS}" << __EOF__ -${ENGINE_DB_HOST}:${ENGINE_DB_PORT}:${ENGINE_DB_DATABASE}:${ENGINE_DB_USER}:${ENGINE_DB_PASSWORD} +${ENGINE_DB_HOST}:${ENGINE_DB_PORT}:${ENGINE_DB_DATABASE}:${ENGINE_DB_USER}:${password} __EOF__ } diff --git a/packaging/setup/ovirt_engine_setup/database.py b/packaging/setup/ovirt_engine_setup/database.py index 6a3b0a8..9be3c58 100644 --- a/packaging/setup/ovirt_engine_setup/database.py +++ b/packaging/setup/ovirt_engine_setup/database.py @@ -304,6 +304,8 @@ @util.export class OvirtUtils(base.Base): + _plainPassword = None + @property def environment(self): return self._environment @@ -332,6 +334,24 @@ self.command.detect('psql') def createPgPass(self): + + # + # we need client side psql library + # version as at least in rhel for 8.4 + # the password within pgpassfile is + # not escaped. + # the simplest way is to checkout psql + # utility version. + # + if type(self)._plainPassword is None: + rc, stdout, stderr = self._plugin.execute( + args=( + self.command.get('psql'), + '-V', + ), + ) + type(self)._plainPassword = ' 8.' in stdout[0] + fd, pgpass = tempfile.mkstemp() atexit.register(os.unlink, pgpass) with os.fdopen(fd, 'w') as f: @@ -344,9 +364,13 @@ port=self.environment[self._dbenvkeys['port']], database=self.environment[self._dbenvkeys['database']], user=self.environment[self._dbenvkeys['user']], - password=outil.escape( - self.environment[self._dbenvkeys['password']], - ':\\', + password=( + self.environment[self._dbenvkeys['password']] + if type(self)._plainPassword + else outil.escape( + self.environment[self._dbenvkeys['password']], + ':\\', + ) ), ), ) -- To view, visit http://gerrit.ovirt.org/24451 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I866680c853c1e1978d55828ff4efd710a1003f9a Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Alon Bar-Lev <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
