From b8c675410b5232ab51b7b19fbffe3f9c23fc382d Mon Sep 17 00:00:00 2001 From: Christian Beer Date: Tue, 14 Feb 2017 09:12:15 +0100 Subject: [PATCH 1/2] Manager: fix password lookup in combobox event If the password file is not readable don't set an empty string in the textbox. --- clientgui/DlgSelectComputer.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/clientgui/DlgSelectComputer.cpp b/clientgui/DlgSelectComputer.cpp index 40cbe7a17d..42a4049d40 100644 --- a/clientgui/DlgSelectComputer.cpp +++ b/clientgui/DlgSelectComputer.cpp @@ -236,8 +236,9 @@ void CDlgSelectComputer::OnComputerNameUpdated( wxCommandEvent& WXUNUSED(event) wxString name = m_ComputerNameCtrl->GetValue(); if (pDoc->IsComputerNameLocal(name)) { - pDoc->m_pNetworkConnection->GetLocalPassword(strPassword); - m_ComputerPasswordCtrl->SetValue(strPassword); + if (pDoc->m_pNetworkConnection->GetLocalPassword(strPassword) == 0) { + m_ComputerPasswordCtrl->SetValue(strPassword); + } } } From 4f6d905f74b5072cc1eed8a89ba81ad9b5cb2741 Mon Sep 17 00:00:00 2001 From: Christian Beer Date: Tue, 14 Feb 2017 09:16:21 +0100 Subject: [PATCH 2/2] Manager: fix select computer dialog for localhost The hostname "localhost" was recognized as a special name which always prompted the Manager to try to read contents of gui_rpc_auth.cfg. The Manager used an empty password if the file is not readable but then can't connect because the Client actually uses a password. Any user supplied password was overwritten which made the dialog not work when using "localhost" but work when used with "127.0.0.1". Now the dialog checks if the user has entered an empty password which prompts reading gui_rpc_auth.cfg and uses the user supplied password otherwise. Fixes #1306 --- clientgui/AdvancedFrame.cpp | 40 ++++++++++++++----------------------- 1 file changed, 15 insertions(+), 25 deletions(-) diff --git a/clientgui/AdvancedFrame.cpp b/clientgui/AdvancedFrame.cpp index 15445ec3bc..369b398ba6 100644 --- a/clientgui/AdvancedFrame.cpp +++ b/clientgui/AdvancedFrame.cpp @@ -1434,36 +1434,26 @@ void CAdvancedFrame::OnSelectComputer(wxCommandEvent& WXUNUSED(event)) { wxString password = wxEmptyString; CMainDocument* pDoc = wxGetApp().GetDocument(); long lRetVal = -1; + bool bRetrievePasswordFromFile = FALSE; wxASSERT(pDoc); wxASSERT(wxDynamicCast(pDoc, CMainDocument)); - if (SelectComputer(hostName, portNum, password, false)) { - if (pDoc->IsComputerNameLocal(hostName)) { - lRetVal = pDoc->Connect( - wxT("localhost"), - GUI_RPC_PORT, - wxEmptyString, - TRUE, - TRUE - ); - } else { - // Connect to the remote machine - long lPort = GUI_RPC_PORT; - int iPos = hostName.Find(wxT(":")); - if (iPos != wxNOT_FOUND) { - wxString sPort = hostName.substr(iPos + 1); - if (!sPort.ToLong(&lPort)) lPort = GUI_RPC_PORT; - hostName.erase(iPos); - } - lRetVal = pDoc->Connect( - hostName.c_str(), - portNum, - password.c_str(), - TRUE, - FALSE - ); + if (SelectComputer(hostName, portNum, password, false)) { + // possibly read password from file if local computername AND no password was entered + if (pDoc->IsComputerNameLocal(hostName) && password == wxEmptyString) { + hostName = wxT("localhost"); + bRetrievePasswordFromFile = TRUE; } + // Connect to the specified host + lRetVal = pDoc->Connect( + hostName.c_str(), + portNum, + password.c_str(), + TRUE, + bRetrievePasswordFromFile + ); + if (lRetVal) { ShowConnectionFailedAlert(); }