From 3e58768b7e571a62d4908dd95ef8f8140cf4d329 Mon Sep 17 00:00:00 2001 From: Takashi Kojo Date: Sat, 29 Jun 2019 13:02:21 +0900 Subject: [PATCH] WS_USER_AUTH_E for wolfSSH_get_error --- examples/echoserver/echoserver.c | 5 +++++ src/internal.c | 2 +- wolfssh/error.h | 3 ++- 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/examples/echoserver/echoserver.c b/examples/echoserver/echoserver.c index 27969ca7..45a4da70 100644 --- a/examples/echoserver/echoserver.c +++ b/examples/echoserver/echoserver.c @@ -391,6 +391,11 @@ static THREAD_RETURN WOLFSSH_THREAD server_worker(void* vArgs) ret = 0; /* don't break out of loop with version miss match */ printf("Unsupported version error\n"); } + else if (ret == WS_FATAL_ERROR && wolfSSH_get_error(threadCtx->ssh) == + WS_USER_AUTH_E) { + ret = 0; /* don't break out of loop with user auth error */ + printf("User Authentication error\n"); + } if (wolfSSH_shutdown(threadCtx->ssh) != WS_SUCCESS) { fprintf(stderr, "Error with SSH shutdown.\n"); diff --git a/src/internal.c b/src/internal.c index f29bb63f..9a245615 100644 --- a/src/internal.c +++ b/src/internal.c @@ -3225,7 +3225,7 @@ static int DoUserAuthRequestPassword(WOLFSSH* ssh, WS_UserAuthData* authData, WLOG(WS_LOG_DEBUG, "DUARPW: password rejected"); ret = SendUserAuthFailure(ssh, 0); if (ret == WS_SUCCESS) - ret = WS_FATAL_ERROR; + ret = WS_USER_AUTH_E; } else { WLOG(WS_LOG_DEBUG, "DUARPW: password check failed, retry"); diff --git a/wolfssh/error.h b/wolfssh/error.h index 4cbd0dfa..05ca9d2f 100644 --- a/wolfssh/error.h +++ b/wolfssh/error.h @@ -105,7 +105,8 @@ enum WS_ErrorCodes { WS_CLOSE_FILE_E = -1065, /* Unable to close local file */ WS_PUBKEY_REJECTED_E = -1066, /* Server public key rejected */ WS_EXTDATA = -1067, /* Extended Data available to be read */ - + WS_USER_AUTH_E = -1068, /* User authentication error */ + WS_LAST_E = -1067 /* Update this to indicate last error */ };