From: Greg Sabino Mullane Date: Fri, 2 May 2008 13:53:48 +0000 (-0400) Subject: Fix problem with dbpass defined but no length X-Git-Tag: 2.9.0~354 X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=a182f68d1913344b5afcc200a3828490365bd21d;p=check_postgres.git Fix problem with dbpass defined but no length Better initial debug output for psql location and version. --- diff --git a/check_postgres.pl b/check_postgres.pl index e53ec5467..f76b70578 100755 --- a/check_postgres.pl +++ b/check_postgres.pl @@ -278,7 +278,9 @@ if (! defined $PSQL or ! length $PSQL) { -x $PSQL or ndie qq{The file "$PSQL" does not appear to be executable\n}; $res = qx{$PSQL --version}; $res =~ /^psql \(PostgreSQL\) (\d+\.\d+)/ or ndie qq{Could not determine psql version\n}; -my $psql_version = int $1; +my $psql_version = $1; + +$VERBOSE >= 1 and warn qq{psql=$PSQL version=$psql_version\n}; $opt{defaultdb} = $psql_version >= 7.4 ? 'postgres' : 'template1'; @@ -770,7 +772,7 @@ sub run_command { } push @args => '-p', $db->{port}; - if (defined $db->{dbpass}) { + if (defined $db->{dbpass} and length $db->{dbpass}) { ## Make a custom PGPASSFILE. Far better to simply use your own .pgpass of course ($passfh,$passfile) = tempfile('nagios.XXXXXXXX', SUFFIX => '.tmp', DIR => $tempdir); $VERBOSE >= 3 and warn "Created temporary pgpass file $passfile\n";