]> git.sur5r.net Git - bacula/bacula/commitdiff
Fix #4062 on make_catalog_backup.pl script when user/password are empty
authorEric Bollengier <eric@baculasystems.com>
Thu, 12 Apr 2012 12:01:14 +0000 (14:01 +0200)
committerKern Sibbald <kern@sibbald.com>
Sat, 20 Apr 2013 12:50:33 +0000 (14:50 +0200)
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

index f955d93c2c78b8f9af0a411e94b2565682049fe9..efb91fd2616e0b6caa97e897e917aa6244a35411 100644 (file)
@@ -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