From d61cb264e5c576903e1acdf1a1f7f5058cbc6fa9 Mon Sep 17 00:00:00 2001 From: John Safranek Date: Mon, 19 Sep 2022 09:22:46 -0700 Subject: [PATCH] Clear Alarm 1. Add a user auth result callback function to clear the alarm on successful user authentication. --- apps/wolfsshd/wolfsshd.c | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/apps/wolfsshd/wolfsshd.c b/apps/wolfsshd/wolfsshd.c index 02390a3e..f7b74360 100644 --- a/apps/wolfsshd/wolfsshd.c +++ b/apps/wolfsshd/wolfsshd.c @@ -230,6 +230,11 @@ static byte* getBufferFromFile(const char* fileName, word32* bufSz, void* heap) } #endif /* NO_FILESYSTEM */ + +static int UserAuthResult(byte result, + WS_UserAuthData* authData, void* userAuthResultCtx); + + /* Initializes and sets up the WOLFSSH_CTX struct based on the configure options * return WS_SUCCESS on success */ @@ -252,6 +257,7 @@ static int SetupCTX(WOLFSSHD_CONFIG* conf, WOLFSSH_CTX** ctx) /* setup authority callback for checking peer connections */ if (ret == WS_SUCCESS) { wolfSSH_SetUserAuth(*ctx, DefaultUserAuth); + wolfSSH_SetUserAuthResult(*ctx, UserAuthResult); } /* set banner to display on connection */ @@ -776,6 +782,19 @@ static void alarmCatch(int signum) (void)signum; } +static int UserAuthResult(byte result, + WS_UserAuthData* authData, void* userAuthResultCtx) +{ + (void)authData; + (void)userAuthResultCtx; + + if (result == WOLFSSH_USERAUTH_SUCCESS) { + alarm(0); + } + + return WS_SUCCESS; +} + /* handle wolfSSH accept and directing to correct subsystem */ static void* HandleConnection(void* arg) {