From edc255421c6b11be90b11d513ab92cac9fd09e1a Mon Sep 17 00:00:00 2001 From: Brice Maron Date: Thu, 13 Dec 2012 19:37:23 +0000 Subject: [PATCH 1/3] Try connection with specified db when postgres does not work Conflicts: lib/setup.php --- lib/setup.php | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/lib/setup.php b/lib/setup.php index 71a2d13937..0db565c6a6 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -320,7 +320,13 @@ class OC_Setup { $connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'"; $connection = @pg_connect($connection_string); if(!$connection) { - throw new DatabaseSetupException($l->t('PostgreSQL username and/or password not valid')); + // Try if we can't connect with the specified DB name + $e_dbname = addslashes($dbname); + $connection_string = "host='$e_host' dbname='$dbname' user='$e_user' password='$e_password'"; + $connection = @pg_connect($connection_string); + + if(!$connection) + throw new DatabaseSetupException($l->t('PostgreSQL username and/or password not valid')); } $e_user = pg_escape_string($dbuser); //check for roles creation rights in postgresql From e33f68ecb6574d0d4675f5989283b08355f9e64c Mon Sep 17 00:00:00 2001 From: eMerzh Date: Fri, 14 Dec 2012 11:10:53 +0100 Subject: [PATCH 2/3] Correct escaping --- lib/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup.php b/lib/setup.php index 0db565c6a6..d7ceb36ae9 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -322,7 +322,7 @@ class OC_Setup { if(!$connection) { // Try if we can't connect with the specified DB name $e_dbname = addslashes($dbname); - $connection_string = "host='$e_host' dbname='$dbname' user='$e_user' password='$e_password'"; + $connection_string = "host='$e_host' dbname='$e_dbname' user='$e_user' password='$e_password'"; $connection = @pg_connect($connection_string); if(!$connection) From 7093b0829f5f603e8ff1de7d5130130d34b6be9a Mon Sep 17 00:00:00 2001 From: Morris Jobke Date: Fri, 14 Jun 2013 11:28:33 +0300 Subject: [PATCH 3/3] improve comment --- lib/setup.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/setup.php b/lib/setup.php index d7ceb36ae9..1cbc83eed9 100644 --- a/lib/setup.php +++ b/lib/setup.php @@ -320,7 +320,7 @@ class OC_Setup { $connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'"; $connection = @pg_connect($connection_string); if(!$connection) { - // Try if we can't connect with the specified DB name + // Try if we can connect to the DB with the specified name $e_dbname = addslashes($dbname); $connection_string = "host='$e_host' dbname='$e_dbname' user='$e_user' password='$e_password'"; $connection = @pg_connect($connection_string);