Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

print out log on fail #631

Merged
merged 1 commit into from
Jan 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 5 additions & 1 deletion apps/wolfsshd/test/sshd_login_grace_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
12 changes: 9 additions & 3 deletions apps/wolfsshd/wolfsshd.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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
Expand All @@ -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);
}
}

Expand Down
Loading