1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-24 21:34:56 +03:00

Add accessor functions for current uid, gid, unix token, NT token and vuid.

Jeremy.
This commit is contained in:
Jeremy Allison 2010-03-15 10:45:15 -07:00
parent 1332ce52b7
commit 5d6610a215
2 changed files with 48 additions and 0 deletions

View 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 */

View 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;
}