diff --git a/apps/wolfsshd/test/sshd_login_grace_test.sh b/apps/wolfsshd/test/sshd_login_grace_test.sh index 9e498d8cd..00b950ba9 100755 --- a/apps/wolfsshd/test/sshd_login_grace_test.sh +++ b/apps/wolfsshd/test/sshd_login_grace_test.sh @@ -47,14 +47,18 @@ if [ "$RESULT" != 0 ]; then exit 1 fi +# attempt clearing out stdin from previous echo/grep +read -t 1 -n 1000 discard + # test grace login timeout by stalling on password prompt -timeout 7 "$TEST_CLIENT" -u "$USER" -h "$TEST_HOST" -p "$TEST_PORT" -t +timeout --foreground 7 "$TEST_CLIENT" -u "$USER" -h "$TEST_HOST" -p "$TEST_PORT" -t popd cat ./log.txt | grep "Failed login within grace period" RESULT=$? if [ "$RESULT" != 0 ]; then echo "FAIL: Grace period not hit" + cat ./log.txt exit 1 fi diff --git a/apps/wolfsshd/wolfsshd.c b/apps/wolfsshd/wolfsshd.c index b8b3673f7..896723e57 100644 --- a/apps/wolfsshd/wolfsshd.c +++ b/apps/wolfsshd/wolfsshd.c @@ -1467,7 +1467,6 @@ static __thread int timeOut = 0; #endif static void alarmCatch(int signum) { - wolfSSH_Log(WS_LOG_ERROR, "[SSHD] Failed login within grace period"); timeOut = 1; (void)signum; } @@ -1553,7 +1552,14 @@ static void* HandleConnection(void* arg) error = WS_FATAL_ERROR; } + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] grace time = %ld timeout = %d", graceTime, timeOut); if (graceTime > 0) { + if (timeOut) { + wolfSSH_Log(WS_LOG_ERROR, + "[SSHD] Failed login within grace period"); + } + #ifdef WIN32 /* @TODO SetTimer(NULL, NULL, graceTime, alarmCatch); */ #else @@ -1564,8 +1570,8 @@ static void* HandleConnection(void* arg) if (ret != WS_SUCCESS && ret != WS_SFTP_COMPLETE && ret != WS_SCP_INIT) { wolfSSH_Log(WS_LOG_ERROR, - "[SSHD] Failed to accept WOLFSSH connection from %s", - conn->ip); + "[SSHD] Failed to accept WOLFSSH connection from %s error %d", + conn->ip, ret); } }