Обсуждение: SSH error messages not shown

Поиск
Список
Период
Сортировка

SSH error messages not shown

От
Jacek Wielemborek
Дата:
Hi,

When an libssh2 call fails, pgAdmin III just shows the error code and
nothing else. Consider the following patch - this is what I created
while wondering why my hostkeys don't work:

diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
index fd80214..e15f764 100644
--- a/pgadmin/utils/sshTunnel.cpp
+++ b/pgadmin/utils/sshTunnel.cpp
@@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
 #endif
                        if (rc)
                        {
-
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d"), rc), GetId());
+                               char* errmsg;
+                               int errmsg_len;
+                               libssh2_session_last_error(m_session,
&errmsg, &errmsg_len, 0);
+                               wxString errmsg_s(errmsg, wxConvLibc);
+
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
GetId());
                                Cleanup();
+                               free(errmsg);
                                return false;
                        }
                }

Perhaps we could use this kind of routines wherever rc is being checked?

Cheers,
d33tah


Вложения

Re: SSH error messages not shown

От
Dave Page
Дата:
Akshay, can you look into this please?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK:http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On 13 Jun 2015, at 16:22, Jacek Wielemborek <d33tah@gmail.com> wrote:

Hi,

When an libssh2 call fails, pgAdmin III just shows the error code and
nothing else. Consider the following patch - this is what I created
while wondering why my hostkeys don't work:

diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
index fd80214..e15f764 100644
--- a/pgadmin/utils/sshTunnel.cpp
+++ b/pgadmin/utils/sshTunnel.cpp
@@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
#endif
                       if (rc)
                       {
-
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d"), rc), GetId());
+                               char* errmsg;
+                               int errmsg_len;
+                               libssh2_session_last_error(m_session,
&errmsg, &errmsg_len, 0);
+                               wxString errmsg_s(errmsg, wxConvLibc);
+
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
GetId());
                               Cleanup();
+                               free(errmsg);
                               return false;
                       }
               }

Perhaps we could use this kind of routines wherever rc is being checked?

Cheers,
d33tah

Re: SSH error messages not shown

От
Akshay Joshi
Дата:
Sure.

On Sun, Jun 14, 2015 at 3:13 PM, Dave Page <dpage@pgadmin.org> wrote:
Akshay, can you look into this please?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK:http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On 13 Jun 2015, at 16:22, Jacek Wielemborek <d33tah@gmail.com> wrote:

Hi,

When an libssh2 call fails, pgAdmin III just shows the error code and
nothing else. Consider the following patch - this is what I created
while wondering why my hostkeys don't work:

diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
index fd80214..e15f764 100644
--- a/pgadmin/utils/sshTunnel.cpp
+++ b/pgadmin/utils/sshTunnel.cpp
@@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
#endif
                       if (rc)
                       {
-
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d"), rc), GetId());
+                               char* errmsg;
+                               int errmsg_len;
+                               libssh2_session_last_error(m_session,
&errmsg, &errmsg_len, 0);
+                               wxString errmsg_s(errmsg, wxConvLibc);
+
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
GetId());
                               Cleanup();
+                               free(errmsg);
                               return false;
                       }
               }

Perhaps we could use this kind of routines wherever rc is being checked?

Cheers,
d33tah




--
Akshay Joshi
Principal Software Engineer 


Phone: +91 20-3058-9517
Mobile: +91 976-788-8246

Re: SSH error messages not shown

От
Akshay Joshi
Дата:
Hi Jacek

On Mon, Jun 15, 2015 at 10:40 AM, Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Sure.

On Sun, Jun 14, 2015 at 3:13 PM, Dave Page <dpage@pgadmin.org> wrote:
Akshay, can you look into this please?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK:http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On 13 Jun 2015, at 16:22, Jacek Wielemborek <d33tah@gmail.com> wrote:

Hi,

When an libssh2 call fails, pgAdmin III just shows the error code and
nothing else. Consider the following patch - this is what I created
while wondering why my hostkeys don't work:

diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
index fd80214..e15f764 100644
--- a/pgadmin/utils/sshTunnel.cpp
+++ b/pgadmin/utils/sshTunnel.cpp
@@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
#endif
                       if (rc)
                       {
-
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d"), rc), GetId());
+                               char* errmsg;
+                               int errmsg_len;
+                               libssh2_session_last_error(m_session,
&errmsg, &errmsg_len, 0);
+                               wxString errmsg_s(errmsg, wxConvLibc);
+
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
GetId());
                               Cleanup();
+                               free(errmsg);
                               return false;
                       }
               }

Perhaps we could use this kind of routines wherever rc is being checked?
       I have reviewed your patch and it looks good to have error message with error number. I have made some changes in the "LogSSHTunnelErrors" function to avoid duplicate logic for each error message. I have added one default parameter of the session object in the "LogSSHTunnelErrors" function. If we would like to log error message with error number, will have to pass session object. Attached is the modified patch, can you please check it is working or not for your test case.   


Cheers,
d33tah




--
Akshay Joshi
Principal Software Engineer 


Phone: +91 20-3058-9517
Mobile: +91 976-788-8246



--
Akshay Joshi
Principal Software Engineer 


Phone: +91 20-3058-9517
Mobile: +91 976-788-8246
Вложения

Re: SSH error messages not shown

От
Akshay Joshi
Дата:
Hi Jacek

Have you test the patch for SSH Tunnel error message?

On Mon, Jun 15, 2015 at 12:17 PM, Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Hi Jacek

On Mon, Jun 15, 2015 at 10:40 AM, Akshay Joshi <akshay.joshi@enterprisedb.com> wrote:
Sure.

On Sun, Jun 14, 2015 at 3:13 PM, Dave Page <dpage@pgadmin.org> wrote:
Akshay, can you look into this please?

-- 
Dave Page
Blog: http://pgsnake.blogspot.com
Twitter: @pgsnake

EnterpriseDB UK:http://www.enterprisedb.com
The Enterprise PostgreSQL Company

On 13 Jun 2015, at 16:22, Jacek Wielemborek <d33tah@gmail.com> wrote:

Hi,

When an libssh2 call fails, pgAdmin III just shows the error code and
nothing else. Consider the following patch - this is what I created
while wondering why my hostkeys don't work:

diff --git a/pgadmin/utils/sshTunnel.cpp b/pgadmin/utils/sshTunnel.cpp
index fd80214..e15f764 100644
--- a/pgadmin/utils/sshTunnel.cpp
+++ b/pgadmin/utils/sshTunnel.cpp
@@ -201,8 +201,13 @@ bool CSSHTunnelThread::Initialize()
#endif
                       if (rc)
                       {
-
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d"), rc), GetId());
+                               char* errmsg;
+                               int errmsg_len;
+                               libssh2_session_last_error(m_session,
&errmsg, &errmsg_len, 0);
+                               wxString errmsg_s(errmsg, wxConvLibc);
+
LogSSHTunnelErrors(wxString::Format(_("SSH error: Authentication by
identity file failed with error code %d [%s]"), rc, errmsg_s.c_str()),
GetId());
                               Cleanup();
+                               free(errmsg);
                               return false;
                       }
               }

Perhaps we could use this kind of routines wherever rc is being checked?
       I have reviewed your patch and it looks good to have error message with error number. I have made some changes in the "LogSSHTunnelErrors" function to avoid duplicate logic for each error message. I have added one default parameter of the session object in the "LogSSHTunnelErrors" function. If we would like to log error message with error number, will have to pass session object. Attached is the modified patch, can you please check it is working or not for your test case.   


Cheers,
d33tah




--
Akshay Joshi
Principal Software Engineer 


Phone: +91 20-3058-9517
Mobile: +91 976-788-8246



--
Akshay Joshi
Principal Software Engineer 


Phone: +91 20-3058-9517
Mobile: +91 976-788-8246



--
Akshay Joshi
Principal Software Engineer 


Phone: +91 20-3058-9517
Mobile: +91 976-788-8246

Re: SSH error messages not shown

От
Jacek Wielemborek
Дата:
W dniu 07.07.2015 o 07:05, Akshay Joshi pisze:
> Hi Jacek
>
> Have you test the patch for SSH Tunnel error message?

Hello,

To be honest, I didn't have time to test the patch for now. I would
welcome anybody else to test it in the meantime or suggest a test case.
Unless just testing if it builds would be enough?

Cheers,
d33tah


Вложения