Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Try connection with specified db when postgres does not work #870

Closed
wants to merge 2 commits into from

8 participants

@eMerzh
Collaborator

SAME AS #867 but for master*

Hi,
here is my attempt to fix #675
the thing is basicaly that we try to connect to 'postgres' db wich is a "protected" db...
from local there is no trouble but from a remote location the postgres db is often no accessible...
so the install fail...

here i change small things to connect to the specified db if the postgres fail

:)

lib/setup.php
@@ -242,7 +242,13 @@ private static function setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbna
$connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'";
$connection = @pg_connect($connection_string);
if(!$connection) {
- throw new Exception('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'";
@bartv2 Collaborator
bartv2 added a note

shouldn't this use e_dbname? (the escaped version)

@eMerzh Collaborator
eMerzh added a note

Yep right! thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
@DeepDiver1975

not tested but looks good :+1:

@jancborchardt
Collaborator

Do we have someone else with Postgres setup or database knowledge who can test this? cc @telepath who filed the original issue.

@telepath

This fix fits our setup exacty. To test it, we'd have to setup a new instance with github code, I don't know when I'll have time for that.

@jancborchardt
Collaborator

@telepath the sooner you have time, the sooner it’s fixed. :)

@telepath

Tested. Still "PostgreSQL username and/or password not valid"

@jancborchardt
Collaborator

@emerzh your turn. :)

@eMerzh
Collaborator

Thanks @telepath for you tests....

grunt ... the problem might be elsewhere then ... i'll have another shot at this

@eMerzh
Collaborator

btw if people are ok i'm still in favor of merging this :) ....

i'm still looking for a fix for the ticket.

@karlitschek
Owner

ping?

@eMerzh
Collaborator

nobody want to add a comment on this?

@Kondou-ger
Collaborator

Merging this would at least make it remotely possible to use remote databases as the code atm explicitly fails if there's no access to the postgres DB, which isn't of course for remote DBs.

@bartv2
Collaborator

+1 change looks good

@MorrisJobke
Collaborator

:+1: Change looks good, untested

@MorrisJobke
Collaborator

closed in favour of #3684

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Dec 13, 2012
  1. @eMerzh
Commits on Dec 14, 2012
  1. @eMerzh

    Correct escaping

    eMerzh authored
This page is out of date. Refresh to see the latest.
Showing with 7 additions and 1 deletion.
  1. +7 −1 lib/setup.php
View
8 lib/setup.php
@@ -242,7 +242,13 @@ private static function setupPostgreSQLDatabase($dbhost, $dbuser, $dbpass, $dbna
$connection_string = "host='$e_host' dbname=postgres user='$e_user' password='$e_password'";
$connection = @pg_connect($connection_string);
if(!$connection) {
- throw new Exception('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='$e_dbname' user='$e_user' password='$e_password'";
+ $connection = @pg_connect($connection_string);
+
+ if(!$connection)
+ throw new Exception('PostgreSQL username and/or password not valid');
}
$e_user = pg_escape_string($dbuser);
//check for roles creation rights in postgresql
Something went wrong with that request. Please try again.