From d328db5e82f0aa5468c3780515fed9d99e8202f5 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Fri, 1 Apr 2011 11:54:49 +0200 Subject: [PATCH] s3-smbd: Added a become_user_by_session() function. This uses the provided session_info instead of searching the user via the vuid. This is useful to work with fake connnection you need to create if someone connects directly to a rpc service. Signed-off-by: Jeremy Allison (cherry picked from commit b137156acbf7c39c86f306100cccc65b441a3209) (cherry picked from commit 71885207ea6453f75d383a0265c73195df048dbf) --- source3/smbd/proto.h | 2 ++ source3/smbd/uid.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+) diff --git a/source3/smbd/proto.h b/source3/smbd/proto.h index f5f65d1ad92..2f9d35961fb 100644 --- a/source3/smbd/proto.h +++ b/source3/smbd/proto.h @@ -1059,6 +1059,8 @@ bool unbecome_authenticated_pipe_user(void); void become_root(void); void unbecome_root(void); bool become_user(connection_struct *conn, uint16 vuid); +bool become_user_by_session(connection_struct *conn, + const struct auth_serversupplied_info *session_info); bool unbecome_user(void); uid_t get_current_uid(connection_struct *conn); gid_t get_current_gid(connection_struct *conn); diff --git a/source3/smbd/uid.c b/source3/smbd/uid.c index 96c45748279..b554b36054b 100644 --- a/source3/smbd/uid.c +++ b/source3/smbd/uid.c @@ -528,6 +528,23 @@ bool become_user(connection_struct *conn, uint16 vuid) return True; } +bool become_user_by_session(connection_struct *conn, + const struct auth_serversupplied_info *session_info) +{ + if (!push_sec_ctx()) + return false; + + push_conn_ctx(); + + if (!change_to_user_by_session(conn, session_info)) { + pop_sec_ctx(); + pop_conn_ctx(); + return false; + } + + return true; +} + bool unbecome_user(void) { pop_sec_ctx(); -- 2.11.4.GIT