diff --git a/pgadmin/frm/frmPgpassConfig.cpp b/pgadmin/frm/frmPgpassConfig.cpp index 19ed7db..438eb3f 100644 --- a/pgadmin/frm/frmPgpassConfig.cpp +++ b/pgadmin/frm/frmPgpassConfig.cpp @@ -61,12 +61,12 @@ frmPgpassConfig::frmPgpassConfig(frmMain *parent) lastPath = sysSettings::GetConfigFile(sysSettings::PGPASS); wxFile f; - if (!f.Exists(lastPath)) - f.Create(lastPath, false, wxS_DEFAULT); - - OpenLastFile(); - - helpMenu->Enable(MNU_HINT, false); + if (f.Exists(lastPath)) + { + OpenLastFile(); + } + + helpMenu->Enable(MNU_HINT, false); toolBar->EnableTool(MNU_HINT, false); } diff --git a/pgadmin/schema/pgServer.cpp b/pgadmin/schema/pgServer.cpp index caba8b1..3e302e7 100644 --- a/pgadmin/schema/pgServer.cpp +++ b/pgadmin/schema/pgServer.cpp @@ -610,12 +610,11 @@ void pgServer::StorePassword() { wxString fname = passwordFilename(); - wxUtfFile file; if (!wxFile::Exists(fname)) { - file.Create(fname, false, S_IREAD | S_IWRITE); + return; } - + wxUtfFile file; // Don't try to read and write in one OP - it doesn't work well wxString before; file.Open(fname, wxFile::read, wxFONTENCODING_SYSTEM); diff --git a/pgadmin/utils/sysSettings.cpp b/pgadmin/utils/sysSettings.cpp index e9f270c..61a9e05 100644 --- a/pgadmin/utils/sysSettings.cpp +++ b/pgadmin/utils/sysSettings.cpp @@ -762,6 +762,7 @@ void sysSettings::SetCanonicalLanguage(const wxLanguage &lang) ////////////////////////////////////////////////////////////////////////// wxString sysSettings::GetConfigFile(configFileName cfgname) { + wxASSERT_MSG(cfgname == sysSettings::PGPASS,wxT("Handles only pgpass configuration")); if (cfgname == PGPASS) { #if wxCHECK_VERSION(2, 9, 5) @@ -769,27 +770,28 @@ wxString sysSettings::GetConfigFile(configFileName cfgname) #else wxStandardPaths stdp; #endif - wxString fname = stdp.GetUserConfigDir(); + wxString fname; + bool bpsfile = wxGetEnv(wxT("PGPASSFILE"),&fname); + if (!bpsfile) + { + fname = stdp.GetUserConfigDir(); #ifdef WIN32 - fname += wxT("\\postgresql"); - if (!wxDirExists(fname)) + fname += wxT("\\postgresql"); + if (!wxDirExists(fname)) wxMkdir(fname); - switch(cfgname) - { - case PGPASS: - fname += wxT("\\pgpass.conf"); - break; + fname += wxT("\\pgpass.conf"); } #else - switch(cfgname) - { - case PGPASS: - fname += wxT("/.pgpass"); - break; + fname += wxT("/.pgpass"); } #endif + wxFile f; + if (!f.Exists(fname)) + f.Create(fname, false, wxS_DEFAULT); + return fname; } + return wxT(""); }