From 7f5b307413a29502791fb8cbe6209c0b0f5d2006 Mon Sep 17 00:00:00 2001 From: Ian Moffett Date: Thu, 3 Oct 2024 21:22:41 -0500 Subject: server: Fix handling of multiple clients Improve handling of multiple connected clients. This fixes issues related to blocking of one client while another is connected as well as certain race conditions. Signed-off-by: Ian Moffett --- lib/libostp/session.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'lib/libostp/session.c') diff --git a/lib/libostp/session.c b/lib/libostp/session.c index 151cad9..7087cc7 100644 --- a/lib/libostp/session.c +++ b/lib/libostp/session.c @@ -63,7 +63,7 @@ static const char *auth_codestr[] = { }; static int -send_auth(int sockfd, const unsigned char *session_key) +send_auth(int sockfd, const unsigned char *session_key, struct ostp_session *s) { struct session_auth auth; struct termios oldt, newt; @@ -129,6 +129,7 @@ send_auth(int sockfd, const unsigned char *session_key) return -1; } + memcpy(s->username, auth.username, sizeof(auth.username)); return 0; } @@ -260,7 +261,7 @@ session_new(const char *host, struct ostp_session *res) gen_session_key(keypair.privkey, serv_pubkey, &session_key); /* User authentication occurs before sending SPWs */ - if ((error = send_auth(sockfd, session_key)) < 0) { + if ((error = send_auth(sockfd, session_key, res)) < 0) { return error; } -- cgit v1.2.3