Skip to content

Commit

Permalink
session: avoid printing misleading debug messages
Browse files Browse the repository at this point in the history
... while throwing LIBSSH2_ERROR_EAGAIN out of session_startup()

If the session runs in blocking mode, LIBSSH2_ERROR_EAGAIN never reaches
the libssh2 API boundary and, in non-blocking mode, these messages are
suppressed by the condition in _libssh2_error_flags() anyway.

Closes libssh2#211
  • Loading branch information
kdudka committed Oct 17, 2017
1 parent 1d0e694 commit 712c6cb
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/session.c
Original file line number Diff line number Diff line change
Expand Up @@ -703,7 +703,9 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)

if (session->startup_state == libssh2_NB_state_created) {
rc = banner_send(session);
if (rc) {
if (rc == LIBSSH2_ERROR_EAGAIN)
return rc;
else if (rc) {
return _libssh2_error(session, rc,
"Failed sending banner");
}
Expand All @@ -714,7 +716,9 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
if (session->startup_state == libssh2_NB_state_sent) {
do {
rc = banner_receive(session);
if (rc)
if (rc == LIBSSH2_ERROR_EAGAIN)
return rc;
else if (rc)
return _libssh2_error(session, rc,
"Failed getting banner");
} while(strncmp("SSH-", (char *)session->remote.banner, 4));
Expand All @@ -724,7 +728,9 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)

if (session->startup_state == libssh2_NB_state_sent1) {
rc = _libssh2_kex_exchange(session, 0, &session->startup_key_state);
if (rc)
if (rc == LIBSSH2_ERROR_EAGAIN)
return rc;
else if (rc)
return _libssh2_error(session, rc,
"Unable to exchange encryption keys");

Expand All @@ -749,7 +755,9 @@ session_startup(LIBSSH2_SESSION *session, libssh2_socket_t sock)
rc = _libssh2_transport_send(session, session->startup_service,
sizeof("ssh-userauth") + 5 - 1,
NULL, 0);
if (rc) {
if (rc == LIBSSH2_ERROR_EAGAIN)
return rc;
else if (rc) {
return _libssh2_error(session, rc,
"Unable to ask for ssh-userauth service");
}
Expand Down

0 comments on commit 712c6cb

Please sign in to comment.