Add support for sslmode using Eric Kinolik's patch updated for HEAD.
authorxzilla <xzilla>
Mon, 22 May 2006 17:31:22 +0000 (17:31 +0000)
committerxzilla <xzilla>
Mon, 22 May 2006 17:31:22 +0000 (17:31 +0000)
Default is allow SSL connections.
Requires config version bump.
Verified on 8.1 running linux and 8.1 Win32 w/ SSL required connections.

classes/Misc.php
classes/database/Connection.php
conf/config.inc.php-dist
libraries/adodb/drivers/adodb-postgres64.inc.php
libraries/lib.inc.php

index 9837d65bee9ed232b28b41e93ae8480b5269b33f..d1860905d9b0ed77bac8e082ad7a0d759dfcadf2 100644 (file)
@@ -2,7 +2,7 @@
        /**
         * Class to hold various commonly used functions
         *
-        * $Id: Misc.php,v 1.126 2006/04/21 03:31:25 chriskl Exp $
+        * $Id: Misc.php,v 1.127 2006/05/22 17:31:22 xzilla Exp $
         */
         
        class Misc {
                        $_connection = new Connection(
                                $server_info['host'],
                                $server_info['port'],
+                               $server_info['sslmode'],
                                $server_info['username'],
                                $server_info['password'],
                                $database
                        $srvs = isset($_SESSION['webdbLogin']) && is_array($_SESSION['webdbLogin']) ? $_SESSION['webdbLogin'] : array();
 
                        foreach($conf['servers'] as $idx => $info) {
-                               $server_id = $info['host'].':'.$info['port'];
+                               $server_id = $info['host'].':'.$info['port'].':'.$info['sslmode'];
                                
                                if (!isset($srvs[$server_id])) {
                                        $srvs[$server_id] = $info;
                        
                        // Otherwise, look for it in the conf file
                        foreach($conf['servers'] as $idx => $info) {
-                               if ($server_id == $info['host'].':'.$info['port']) {
+                               if ($server_id == $info['host'].':'.$info['port'].':'.$info['sslmode']) {
                                        // Automatically use shared credentials if available
                                        if (!isset($info['username']) && isset($_SESSION['sharedUsername'])) {
                                                $info['username'] = $_SESSION['sharedUsername'];
index 00c8aca89da75ab1a8cb6d7cbfe5267b8a7a772a..632289c90d1e7edddc867c2686e0bdd803897adb 100755 (executable)
@@ -3,7 +3,7 @@
 /**
  * Class to represent a database connection
  *
- * $Id: Connection.php,v 1.12 2005/11/08 02:24:31 chriskl Exp $
+ * $Id: Connection.php,v 1.13 2006/05/22 17:31:23 xzilla Exp $
  */
 
 include_once('./classes/database/ADODB_base.php');
@@ -19,7 +19,7 @@ class Connection {
         * Creates a new connection.  Will actually make a database connection.
         * @param $fetchMode Defaults to associative.  Override for different behaviour
         */
-       function Connection($host, $port, $user, $password, $database, $fetchMode = ADODB_FETCH_ASSOC) {
+       function Connection($host, $port, $sslmode, $user, $password, $database, $fetchMode = ADODB_FETCH_ASSOC) {
                $this->conn = &ADONewConnection('postgres7');
                $this->conn->setFetchMode($fetchMode);
 
@@ -32,6 +32,10 @@ class Connection {
                else
                        $pghost = "{$host}:{$port}";
 
+               // Add sslmode to $pghost if set
+               if ($sslmode !== null && $sslmode != '')
+                       $pghost .= ':'.$sslmode;
+
                $this->conn->connect($pghost, $user, $password, $database);
        }
 
index c53956c33e61f474c92caa880444003fcfe6f47c..65a67693128cfa483054ac0c4c44096dc3c8268e 100644 (file)
@@ -4,7 +4,7 @@
         * Central phpPgAdmin configuration.  As a user you may modify the
         * settings here for your particular configuration.
         *
-        * $Id: config.inc.php-dist,v 1.47 2005/11/18 04:45:52 chriskl Exp $
+        * $Id: config.inc.php-dist,v 1.48 2006/05/22 17:31:23 xzilla Exp $
         */
 
        // An example server.  Create as many of these as you wish,
        // Database port on server (5432 is the PostgreSQL default)
        $conf['servers'][0]['port'] = 5432;
 
+       // Database SSL mode
+       // Possible options: disable, allow, prefer, require
+       $conf['servers'][0]['sslmode'] = 'allow';
+
        // Change the default database only if you cannot connect to template1.
        // For a PostgreSQL 8.1 server, you need to set this to 'postgres'.
        $conf['servers'][0]['defaultdb'] = 'template1';
@@ -39,6 +43,7 @@
        //$conf['servers'][1]['desc'] = 'Test Server';
        //$conf['servers'][1]['host'] = '127.0.0.1';
        //$conf['servers'][1]['port'] = 5432;
+       //$conf['servers'][1]['sslmode'] = 'allow';
        //$conf['servers'][1]['defaultdb'] = 'template1';
        //$conf['servers'][1]['pg_dump_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dump.exe';
        //$conf['servers'][1]['pg_dumpall_path'] = 'C:\\Program Files\\PostgreSQL\\8.0\\bin\\pg_dumpall.exe';
         * Don't modify anything below this line *
         *****************************************/
 
-       $conf['version'] = 15;
+       $conf['version'] = 16;
 
 ?>
index b4a045c64e01576a6aa1962bddee5b3eaa226b2f..469bd463cc028d6c64ffa47e3178befadb041bfd 100644 (file)
@@ -631,6 +631,8 @@ WHERE c2.relname=\'%s\' or c2.relname=lower(\'%s\')';
                                else $str = '';\r
                                if (isset($host[1])) $str .= " port=$host[1]";\r
                                else if (!empty($this->port)) $str .= " port=".$this->port;\r
+                               if (isset($host[2])) $str .= " sslmode=".adodb_addslashes($host[2]);\r
+                               else if (!empty($this->sslmode)) $str .= " sslmode=".$this->sslmode;\r
                        }\r
                                if ($user) $str .= " user=".$user;\r
                                if ($pwd)  $str .= " password=".$pwd;\r
index fbd3029eaa0e867bc1118e98ce43918f664d17b1..5999f5a45517f5b1bc6b63069950f34c132dbd53 100644 (file)
@@ -3,7 +3,7 @@
        /**
         * Function library read in upon startup
         *
-        * $Id: lib.inc.php,v 1.109 2005/12/07 01:31:28 chriskl Exp $
+        * $Id: lib.inc.php,v 1.110 2006/05/22 17:31:23 xzilla Exp $
         */
        include_once('./libraries/decorator.inc.php');
        include_once('./lang/translations.php');
@@ -38,7 +38,7 @@
        // Configuration file version.  If this is greater than that in config.inc.php, then
        // the app will refuse to run.  This and $conf['version'] should be incremented whenever
        // backwards incompatible changes are made to config.inc.php-dist.
-       $conf['base_version'] = 15;
+       $conf['base_version'] = 16;
 
        // Always include english.php, since it's the master language file
        if (!isset($conf['default_lang'])) $conf['default_lang'] = 'english';