From 596a10d1079f5c4a954108c81efc862c22a11f28 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Mon, 3 Jul 2023 15:08:31 +0200 Subject: [PATCH] s3:lib: let sessionid_traverse_read() report if the session was authenticated MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit BUG: https://bugzilla.samba.org/show_bug.cgi?id=15412 Signed-off-by: Stefan Metzmacher Reviewed-by: Andrew Bartlett Reviewed-by: Günther Deschner --- source3/include/session.h | 1 + source3/lib/sessionid_tdb.c | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/source3/include/session.h b/source3/include/session.h index 40c25e514bb..903208e9b0b 100644 --- a/source3/include/session.h +++ b/source3/include/session.h @@ -39,6 +39,7 @@ struct sessionid { fstring ip_addr_str; time_t connect_start; uint16_t connection_dialect; + bool authenticated; uint8_t encryption_flags; uint16_t cipher; uint16_t signing; diff --git a/source3/lib/sessionid_tdb.c b/source3/lib/sessionid_tdb.c index 53bb9aeebbc..6af2ad9b9e9 100644 --- a/source3/lib/sessionid_tdb.c +++ b/source3/lib/sessionid_tdb.c @@ -25,6 +25,7 @@ #include "util_tdb.h" #include "smbd/globals.h" #include "source3/smbd/smbXsrv_session.h" +#include "../libcli/security/session.h" struct sessionid_traverse_read_state { int (*fn)(const char *key, struct sessionid *session, @@ -49,11 +50,18 @@ static int sessionid_traverse_read_fn(struct smbXsrv_session_global0 *global, }; if (session_info != NULL) { + enum security_user_level ul; + session.uid = session_info->unix_token->uid; session.gid = session_info->unix_token->gid; strncpy(session.username, session_info->unix_info->unix_name, sizeof(fstring)-1); + + ul = security_session_user_level(session_info, NULL); + if (ul >= SECURITY_USER) { + session.authenticated = true; + } } strncpy(session.remote_machine,