diff options
| author | Ian Moffett <ian@osmora.org> | 2024-10-03 21:18:12 -0500 | 
|---|---|---|
| committer | Ian Moffett <ian@osmora.org> | 2024-10-03 21:18:12 -0500 | 
| commit | fe5120087d24cdd07ef65d85f60eb11f4ae12cf2 (patch) | |
| tree | c203c7dedfbaf7e4845a16ad865ac08dfbf4bd35 | |
| parent | 57e3f7558ea9aea8b1fbf13a1fa2690e6719ca7e (diff) | |
lib: auth: Keep track of username
Signed-off-by: Ian Moffett <ian@osmora.org>
| -rw-r--r-- | lib/include/session.h | 2 | ||||
| -rw-r--r-- | lib/libostp/auth.c | 5 | 
2 files changed, 7 insertions, 0 deletions
| diff --git a/lib/include/session.h b/lib/include/session.h index 397fa68..39eb1bc 100644 --- a/lib/include/session.h +++ b/lib/include/session.h @@ -30,9 +30,11 @@  #ifndef LIBOSTP_SESSION_H_  #define LIBOSTP_SESSION_H_ +#include <ostp/net/stpsession.h>  #include <stdint.h>  struct ostp_session { +    char username[MAX_USERNAME_LEN];      unsigned char *session_key;      int sockfd;  }; diff --git a/lib/libostp/auth.c b/lib/libostp/auth.c index 5d69009..559e3b3 100644 --- a/lib/libostp/auth.c +++ b/lib/libostp/auth.c @@ -37,6 +37,7 @@  #include <unistd.h>  #include <stdlib.h>  #include <errno.h> +#include <string.h>  struct session_td_args {      struct ostp_client *c; @@ -79,6 +80,7 @@ passwd_auth(struct ostp_client *c, const unsigned char *session_key)  {      int error;      struct session_auth auth; +    struct ostp_session *session;      const size_t LEN = sizeof(auth);      if (!REQUIRE_USER_AUTH) { @@ -106,6 +108,9 @@ passwd_auth(struct ostp_client *c, const unsigned char *session_key)          printf("Failed to ACK user authentication with frame\n");          return error;      } + +    session = &c->session; +    memcpy(session->username, auth.username, sizeof(auth.username));      return 0;  } | 
