From 4c15171459a2a23d3a542ec63eff51f6b4246885 Mon Sep 17 00:00:00 2001 From: Eric Bollengier Date: Thu, 12 Apr 2012 14:01:14 +0200 Subject: [PATCH] Fix #4062 on make_catalog_backup.pl script when user/password are empty The make_catalog_backup.pl sets PGUSER and PGPASSWORD env vars even if they are not set in the bacula config. This leads to an error if postgresql is used with IDENT authentification. The following error message is printed: --- pg_dump: [archiver (db)] connection to database "bacula" failed: FATAL: no PostgreSQL user name specified in startup packet --- bacula/src/cats/make_catalog_backup.pl.in | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/bacula/src/cats/make_catalog_backup.pl.in b/bacula/src/cats/make_catalog_backup.pl.in index f955d93c2c..efb91fd261 100644 --- a/bacula/src/cats/make_catalog_backup.pl.in +++ b/bacula/src/cats/make_catalog_backup.pl.in @@ -69,10 +69,13 @@ sub dump_pgsql if ($args{db_port}) { $ENV{PGPORT}=$args{db_port}; } - + if ($args{db_user}) { + $ENV{PGUSER}=$args{db_user}; + } + if ($args{db_password}) { + $ENV{PGPASSWORD}=$args{db_password}; + } $ENV{PGDATABASE}=$args{db_name}; - $ENV{PGUSER}=$args{db_user}; - $ENV{PGPASSWORD}=$args{db_password}; exec("HOME='$wd' pg_dump -c > '$wd/$args{db_name}.sql'"); print "Error while executing postgres dump $!\n"; return 1; # in case of error -- 2.39.5