Sandro Bonazzola has uploaded a new change for review. Change subject: sos: postgresql: align with upstream master ......................................................................
sos: postgresql: align with upstream master re-sync with upstream sos postgresql plugin, including https://github.com/sosreport/sos/commit/7cdc1deabaeae226b498da74e1f60302f8a68a26 from Bryn M. Reeves. Change-Id: I56129de7f208275495e4643444b3c522cec6aada Signed-off-by: Sandro Bonazzola <[email protected]> --- M src/sos/plugins/postgresql.py 1 file changed, 11 insertions(+), 6 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-log-collector refs/changes/00/32300/1 diff --git a/src/sos/plugins/postgresql.py b/src/sos/plugins/postgresql.py index 5681e40..5f831e9 100644 --- a/src/sos/plugins/postgresql.py +++ b/src/sos/plugins/postgresql.py @@ -47,10 +47,12 @@ class postgresql(sos.plugintools.PluginBase): """PostgreSQL related information""" + password_warn_text = " (password visible in process listings)" + optionList = [ ('pghome', 'PostgreSQL server home directory.', '', '/var/lib/pgsql'), ('username', 'username for pg_dump', '', 'postgres'), - ('password', 'password for pg_dump', '', ''), + ('password', 'password for pg_dump' + password_warn_text, '', ''), ('dbname', 'database name to dump for pg_dump', '', ''), ('dbhost', 'database hostname/IP (do not use unix socket)', '', ''), ('dbport', 'database server port number', '', '5432') @@ -62,8 +64,12 @@ def pg_dump(self): dest_file = os.path.join(self.tmp_dir, "sos_pgdump.tar") - old_env_pgpassword = os.environ.get("PGPASSWORD") - os.environ["PGPASSWORD"] = self.getOption("password") + # We're only modifying this for ourself and our children so there + # is no need to save and restore environment variables if the user + # decided to pass the password on the command line. + if self.getOption("password") is not None: + os.environ["PGPASSWORD"] = self.getOption("password") + if self.getOption("dbhost"): cmd = "pg_dump -U %s -h %s -p %s -w -f %s -F t %s" % ( self.getOption("username"), @@ -78,9 +84,8 @@ dest_file, self.getOption("dbname") ) + (status, output, rtime) = self.callExtProg(cmd) - if old_env_pgpassword is not None: - os.environ["PGPASSWORD"] = str(old_env_pgpassword) if (status == 0): self.addCopySpec(dest_file) else: @@ -93,7 +98,7 @@ def setup(self): if self.getOption("dbname"): - if self.getOption("password"): + if self.getOption("password") or "PGPASSWORD" in os.environ: self.tmp_dir = tempfile.mkdtemp() self.pg_dump() else: -- To view, visit http://gerrit.ovirt.org/32300 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: I56129de7f208275495e4643444b3c522cec6aada Gerrit-PatchSet: 1 Gerrit-Project: ovirt-log-collector Gerrit-Branch: master Gerrit-Owner: Sandro Bonazzola <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
