[Pkg-postgresql-public] PgCommon.pm::port_running

Stefan Huehner stefan@huehner.org
Fri, 6 May 2005 16:39:03 +0200


--gatW/ieO32f1wygP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline

Hi,

the port_running function in PgCommon.pm uses psql to connect via tcp
to an instance of postgresql. If used as i.e. root with an standard
pg_hba.conf a postgresql-log entry:

FATAL:  user "root" does not exist

is created as root, as root mustn't connect. Attached patch modifies
this function to connect as the postgres-superuser.

Regards,
Stefan


--gatW/ieO32f1wygP
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment; filename="PgCommon.pm.diff"

--- /usr/share/postgresql-common/PgCommon.pm	2005-04-20 02:33:30.000000000 +0200
+++ PgCommon.pm	2005-05-03 17:29:03.000000000 +0200
@@ -95,7 +94,7 @@
 sub port_running {
     $psql = get_program_path "psql", $_[0];
     die "port_running: invalid port $_[1]" if $_[1] !~ /\d+/;
-    $out = `LANG=C $psql -p $_[1] -l 2>&1 > /dev/null`;
+    $out = `LANG=C $psql -U postgres -p $_[1] -l 2>&1 > /dev/null`;
     return 1 unless $?;
     return (index ($out, "could not connect") < 0);
 }

--gatW/ieO32f1wygP--