s3-smbd: Added a become_user_by_session() function.
authorAndreas Schneider <asn@samba.org>
Fri, 1 Apr 2011 09:54:49 +0000 (11:54 +0200)
committerJeremy Allison <jra@samba.org>
Mon, 11 Apr 2011 22:03:38 +0000 (15:03 -0700)
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 <jra@samba.org>
(cherry picked from commit b137156acbf7c39c86f306100cccc65b441a3209)

source3/smbd/proto.h
source3/smbd/uid.c

index f5f65d1ad9290c9c626e70b6136650fd538599e4..2f9d35961fb4a66b8e75eb0659bf1e9ee30330a5 100644 (file)
@@ -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);
index 96c457482792f885902d04672a0929f433e6db5c..b554b36054b9573e71db8a66fe76cd7afb9ce821 100644 (file)
@@ -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();