From 8cfe36eee92255509e61e591761db594de46cdb8 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Fri, 25 May 2018 14:22:43 +0200 Subject: [PATCH] smbd: call set_current_user_info() in change_to_user_internal() and pop_conn_ctx() change_to_user() should be the one and only function for the whole impersonation processing. So we also need to stack the set_current_user_info() information for become_user/unbecome_user. Signed-off-by: Stefan Metzmacher Reviewed-by: Ralph Boehme --- source3/smbd/globals.h | 1 + source3/smbd/uid.c | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/source3/smbd/globals.h b/source3/smbd/globals.h index 69db07a490b..384599be1df 100644 --- a/source3/smbd/globals.h +++ b/source3/smbd/globals.h @@ -89,6 +89,7 @@ extern uint16_t fnf_handle; struct conn_ctx { connection_struct *conn; uint64_t vuid; + userdom_struct user_info; }; /* A stack of current_user connection contexts. */ extern struct conn_ctx conn_ctx_stack[MAX_SEC_CTX_DEPTH]; diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index af8a60d99ee..913d4f3aa0a 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -301,6 +301,10 @@ static bool change_to_user_internal(connection_struct *conn, return true; } + set_current_user_info(session_info->unix_info->sanitized_username, + session_info->unix_info->unix_name, + session_info->info->domain_name); + snum = SNUM(conn); ok = check_user_ok(conn, vuid, session_info, snum); @@ -467,6 +471,7 @@ bool smbd_unbecome_authenticated_pipe_user(void) static void push_conn_ctx(void) { struct conn_ctx *ctx_p; + extern userdom_struct current_user_info; /* Check we don't overflow our stack */ @@ -480,6 +485,7 @@ static void push_conn_ctx(void) ctx_p->conn = current_user.conn; ctx_p->vuid = current_user.vuid; + ctx_p->user_info = current_user_info; DEBUG(4, ("push_conn_ctx(%llu) : conn_ctx_stack_ndx = %d\n", (unsigned long long)ctx_p->vuid, conn_ctx_stack_ndx)); @@ -501,6 +507,9 @@ static void pop_conn_ctx(void) conn_ctx_stack_ndx--; ctx_p = &conn_ctx_stack[conn_ctx_stack_ndx]; + set_current_user_info(ctx_p->user_info.smb_name, + ctx_p->user_info.unix_name, + ctx_p->user_info.domain); current_user.conn = ctx_p->conn; current_user.vuid = ctx_p->vuid;