Skip to content
This repository has been archived by the owner on Sep 15, 2022. It is now read-only.

Commit

Permalink
Ensure backup/restore works with SSL certificate based auth and the m…
Browse files Browse the repository at this point in the history
…aintenance DB is used for global backups.
  • Loading branch information
dpage committed May 17, 2013
1 parent 5a7d5b3 commit 5e733e3
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 3 deletions.
2 changes: 2 additions & 0 deletions CHANGELOG
Expand Up @@ -37,6 +37,8 @@ Changes

Date Dev Ver Change details
---------- --- ------ --------------
2013-05-17 DP 1.16.2 Ensure global backups use the mintenance database to
avoid access issue with postgres or template1.
2013-05-17 DP 1.16.2 Fix SSL certificate authentication.
2013-05-08 DP 1.16.2 Fix renaming and schema changes for stored procedures
in PPAS [Dinesh Kumar].
Expand Down
18 changes: 16 additions & 2 deletions pgadmin/frm/frmBackup.cpp
Expand Up @@ -98,11 +98,25 @@ frmBackup::frmBackup(frmMain *form, pgObject *obj) : ExternProcessDialog(form)
settings->Read(wxT("frmBackup/LastFile"), &val, wxEmptyString);
txtFilename->SetValue(val);

if (!object->GetDatabase()->GetServer()->GetPasswordIsStored())
pgServer *server = object->GetServer();

if (!server->GetPasswordIsStored())
environment.Add(wxT("PGPASSWORD=") + object->GetServer()->GetPassword());

// Pass the SSL mode via the environment
environment.Add(wxT("PGSSLMODE=") + object->GetServer()->GetConnection()->GetSslModeName());
environment.Add(wxT("PGSSLMODE=") + server->GetConnection()->GetSslModeName());

if (server->GetSSLRootCert() != wxEmptyString)
environment.Add(wxT("PGSSLROOTCERT=") + server->GetSSLRootCert());

if (server->GetSSLCert() != wxEmptyString)
environment.Add(wxT("PGSSLCERT=") + server->GetSSLCert());

if (server->GetSSLKey() != wxEmptyString)
environment.Add(wxT("PGSSLKEY=") + server->GetSSLKey());

if (server->GetSSLCrl() != wxEmptyString)
environment.Add(wxT("PGSSLCRL=") + server->GetSSLCrl());

// Icon
SetIcon(*backup_png_ico);
Expand Down
15 changes: 14 additions & 1 deletion pgadmin/frm/frmBackupGlobals.cpp
Expand Up @@ -95,6 +95,18 @@ frmBackupGlobals::frmBackupGlobals(frmMain *form, pgObject *obj) : ExternProcess
// Pass the SSL mode via the environment
environment.Add(wxT("PGSSLMODE=") + server->GetConnection()->GetSslModeName());

if (server->GetSSLRootCert() != wxEmptyString)
environment.Add(wxT("PGSSLROOTCERT=") + server->GetSSLRootCert());

if (server->GetSSLCert() != wxEmptyString)
environment.Add(wxT("PGSSLCERT=") + server->GetSSLCert());

if (server->GetSSLKey() != wxEmptyString)
environment.Add(wxT("PGSSLKEY=") + server->GetSSLKey());

if (server->GetSSLCrl() != wxEmptyString)
environment.Add(wxT("PGSSLCRL=") + server->GetSSLCrl());

// Icon
SetIcon(*backup_png_ico);

Expand Down Expand Up @@ -188,7 +200,8 @@ wxString frmBackupGlobals::getCmdPart1()
cmd += wxT(" --host ") + server->GetName();

cmd += wxT(" --port ") + NumToStr((long)server->GetPort())
+ wxT(" --username ") + commandLineCleanOption(qtIdent(server->GetUsername()));
+ wxT(" --username ") + commandLineCleanOption(qtIdent(server->GetUsername()))
+ wxT(" --database ") + commandLineCleanOption(qtIdent(server->GetDatabaseName()));

if (!cbRolename->GetValue().IsEmpty())
cmd += wxT(" --role ") + commandLineCleanOption(qtIdent(cbRolename->GetValue()));
Expand Down
12 changes: 12 additions & 0 deletions pgadmin/frm/frmRestore.cpp
Expand Up @@ -146,6 +146,18 @@ frmRestore::frmRestore(frmMain *_form, pgObject *obj) : ExternProcessDialog(form
// Pass the SSL mode via the environment
environment.Add(wxT("PGSSLMODE=") + server->GetConnection()->GetSslModeName());

if (server->GetSSLRootCert() != wxEmptyString)
environment.Add(wxT("PGSSLROOTCERT=") + server->GetSSLRootCert());

if (server->GetSSLCert() != wxEmptyString)
environment.Add(wxT("PGSSLCERT=") + server->GetSSLCert());

if (server->GetSSLKey() != wxEmptyString)
environment.Add(wxT("PGSSLKEY=") + server->GetSSLKey());

if (server->GetSSLCrl() != wxEmptyString)
environment.Add(wxT("PGSSLCRL=") + server->GetSSLCrl());

if (!pgAppMinimumVersion(restoreExecutable, 8, 4))
{
chkNoTablespaces->Disable();
Expand Down

0 comments on commit 5e733e3

Please sign in to comment.