Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fix bug #2605601 Doesn't check if pg_dump_path is valid

  • Loading branch information...
commit a68d3ca4a09e1c8c487a242a3c68e2bd41713f33 1 parent 15413db
Jehan-Guillaume (ioguix) de Rorthais ioguix authored
Showing with 25 additions and 12 deletions.
  1. +21 −12 dbexport.php
  2. +2 −0  lang/english.php
  3. +2 −0  lang/recoded/english.php
33 dbexport.php
View
@@ -13,8 +13,28 @@
$_no_output = true;
include_once('./libraries/lib.inc.php');
+ // Are we doing a cluster-wide dump or just a per-database dump
+ $dumpall = ($_REQUEST['subject'] == 'server');
+
// Check that database dumps are enabled.
- if ($misc->isDumpEnabled()) {
+ if ($misc->isDumpEnabled($dumpall)) {
+
+ $server_info = $misc->getServerInfo();
+
+ // Get the path of the pg_dump/pg_dumpall executable
+ $exe = $misc->escapeShellCmd($server_info[$dumpall ? 'pg_dumpall_path' : 'pg_dump_path']);
+
+ // Obtain the pg_dump version number and check if the path is good
+ $version = array();
+ preg_match("/(\d+(?:\.\d+)?)(?:\.\d+)?.*$/", exec($exe . " --version"), $version);
+
+ if (empty($version)) {
+ if ($dumpall)
+ printf($lang['strbadpgdumpallpath'], $server_info['pg_dumpall_path']);
+ else
+ printf($lang['strbadpgdumppath'], $server_info['pg_dump_path']);
+ exit;
+ }
// Make it do a download, if necessary
switch($_REQUEST['output']){
@@ -40,7 +60,6 @@
}
// Set environmental variables that pg_dump uses
- $server_info = $misc->getServerInfo();
putenv('PGPASSWORD=' . $server_info['password']);
putenv('PGUSER=' . $server_info['username']);
$hostname = $server_info['host'];
@@ -52,12 +71,6 @@
putenv('PGPORT=' . $port);
}
- // Are we doing a cluster-wide dump or just a per-database dump
- $dumpall = ($_REQUEST['subject'] == 'server');
-
- // Get the path og the pg_dump/pg_dumpall executable
- $exe = $misc->escapeShellCmd($server_info[$dumpall ? 'pg_dumpall_path' : 'pg_dump_path']);
-
// Build command for executing pg_dump. '-i' means ignore version differences.
$cmd = $exe . " -i";
@@ -66,10 +79,6 @@
switch ($_REQUEST['subject']) {
case 'table':
case 'view':
- // Obtain the pg_dump version number
- $version = array();
- preg_match("/(\d+(?:\.\d+)?)(?:\.\d+)?.*$/", exec($exe . " --version"), $version);
-
// Starting in 8.2, -n and -t are orthagonal, so we now schema qualify
// the table name in the -t argument and quote both identifiers
if ( ((float) $version[1]) >= 8.2 ) {
2  lang/english.php
View
@@ -180,6 +180,8 @@
$lang['strcannotdumponwindows'] = 'Dumping of complex table and schema names on Windows is not supported.';
$lang['strinvalidserverparam'] = 'Attempt to connect with invalid server parameter, possibly someone is trying to hack your system.';
$lang['strnoserversupplied'] = 'No server supplied!';
+ $lang['strbadpgdumppath'] = 'Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog.';
+ $lang['strbadpgdumpallpath'] = 'Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog.';
// Tables
$lang['strtable'] = 'Table';
2  lang/recoded/english.php
View
@@ -180,6 +180,8 @@
$lang['strcannotdumponwindows'] = 'Dumping of complex table and schema names on Windows is not supported.';
$lang['strinvalidserverparam'] = 'Attempt to connect with invalid server parameter, possibly someone is trying to hack your system.';
$lang['strnoserversupplied'] = 'No server supplied!';
+ $lang['strbadpgdumppath'] = 'Export error: Failed to execute pg_dump (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog.';
+ $lang['strbadpgdumpallpath'] = 'Export error: Failed to execute pg_dumpall (given path in your conf/config.inc.php : %s). Please, fix this path in your configuration and relog.';
// Tables
$lang['strtable'] = 'Table';
Please sign in to comment.
Something went wrong with that request. Please try again.