Add accessor functions for current uid, gid, unix token, NT token and vuid.
authorJeremy Allison <jra@samba.org>
Mon, 15 Mar 2010 17:45:15 +0000 (10:45 -0700)
committerJeremy Allison <jra@samba.org>
Mon, 15 Mar 2010 21:49:06 +0000 (14:49 -0700)
Jeremy.

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

index 453f8e99df5aaf3d13227e44b2efe6eb1dcbd8f4..54500009c4d06c1ca94197e636edeb7094dcdf61 100644 (file)
@@ -7117,6 +7117,11 @@ void become_root(void);
 void unbecome_root(void);
 bool become_user(connection_struct *conn, uint16 vuid);
 bool unbecome_user(void);
+uid_t get_current_uid(connection_struct *conn);
+gid_t get_current_gid(connection_struct *conn);
+const UNIX_USER_TOKEN *get_current_utok(connection_struct *conn);
+const NT_USER_TOKEN *get_current_nttok(connection_struct *conn);
+uint16_t get_current_vuid(connection_struct *conn);
 
 /* The following definitions come from smbd/utmp.c  */
 
index 706f8c9f6affcaead0e1432addc2bf379f79c75c..5e3b84da50060d170cff437a259bd7efe4cf27ac 100644 (file)
@@ -505,3 +505,46 @@ bool unbecome_user(void)
        pop_conn_ctx();
        return True;
 }
+
+/****************************************************************************
+ Return the current user we are running effectively as on this connection.
+ I'd like to make this return conn->server_info->utok.uid, but become_root()
+ doesn't alter this value.
+****************************************************************************/
+
+uid_t get_current_uid(connection_struct *conn)
+{
+       return current_user.ut.uid;
+}
+
+/****************************************************************************
+ Return the current group we are running effectively as on this connection.
+ I'd like to make this return conn->server_info->utok.gid, but become_root()
+ doesn't alter this value.
+****************************************************************************/
+
+gid_t get_current_gid(connection_struct *conn)
+{
+       return current_user.ut.gid;
+}
+
+/****************************************************************************
+ Return the UNIX token we are running effectively as on this connection.
+ I'd like to make this return &conn->server_info->utok, but become_root()
+ doesn't alter this value.
+****************************************************************************/
+
+const UNIX_USER_TOKEN *get_current_utok(connection_struct *conn)
+{
+       return &current_user.ut;
+}
+
+const NT_USER_TOKEN *get_current_nttok(connection_struct *conn)
+{
+       return current_user.nt_user_token;
+}
+
+uint16_t get_current_vuid(connection_struct *conn)
+{
+       return current_user.vuid;
+}