summaryrefslogtreecommitdiff
path: root/source3/smbd/password.c
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2000-08-03 22:38:43 +0000
committerJeremy Allison <jra@samba.org>2000-08-03 22:38:43 +0000
commitf87399915b009f88c41cb75a583c2972fe3daf30 (patch)
tree874d5861eba4e7ba655f2d94d6b7a8c1e37bfdfc /source3/smbd/password.c
parent468af1937d327cc579dbbdae6e4a9b030998f049 (diff)
downloadsamba-f87399915b009f88c41cb75a583c2972fe3daf30.tar.gz
samba-f87399915b009f88c41cb75a583c2972fe3daf30.tar.bz2
samba-f87399915b009f88c41cb75a583c2972fe3daf30.zip
Added an NT_USER_TOKEN structure that is copied/passed around associated
with the current user. This will allow se_access_check() to quickly do a SD check without having to translate uid/gid's to SIDs. Still needs work on pipe calls. Jeremy. (This used to be commit e28d01b744b3dbd33e0e54af4e7f426fa8c082b8)
Diffstat (limited to 'source3/smbd/password.c')
-rw-r--r--source3/smbd/password.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/source3/smbd/password.c b/source3/smbd/password.c
index 0372e7a0f9..9af7d3b1e9 100644
--- a/source3/smbd/password.c
+++ b/source3/smbd/password.c
@@ -113,16 +113,6 @@ user_struct *get_valid_user_struct(uint16 vuid)
}
/****************************************************************************
- Delete the SID list for this user.
-****************************************************************************/
-
-static void delete_nt_token(NT_USER_TOKEN *token)
-{
- safe_free( token->user_sids );
- ZERO_STRUCTP(token);
-}
-
-/****************************************************************************
invalidate a uid
****************************************************************************/
void invalidate_vuid(uint16 vuid)
@@ -146,7 +136,6 @@ void invalidate_vuid(uint16 vuid)
delete_nt_token(&vuser->nt_user_token);
}
-
/****************************************************************************
return a validated username
****************************************************************************/
@@ -192,15 +181,21 @@ int initialize_groups(char *user, uid_t uid, gid_t gid)
Create the SID list for this user.
****************************************************************************/
-void setup_nt_token(NT_USER_TOKEN *token, uid_t uid, gid_t gid, int ngroups, gid_t *groups)
+NT_USER_TOKEN *create_nt_token(uid_t uid, gid_t gid, int ngroups, gid_t *groups)
{
+ NT_USER_TOKEN *token;
DOM_SID *psids;
int i;
+ if ((token = (NT_USER_TOKEN *)malloc( sizeof(NT_USER_TOKEN) ) ) == NULL)
+ return NULL;
+
ZERO_STRUCTP(token);
- if ((token->user_sids = (DOM_SID *)malloc( (ngroups + 2)*sizeof(DOM_SID))) == NULL)
- return;
+ if ((token->user_sids = (DOM_SID *)malloc( (ngroups + 2)*sizeof(DOM_SID))) == NULL) {
+ free(token);
+ return NULL;
+ }
psids = token->user_sids;
@@ -211,6 +206,8 @@ void setup_nt_token(NT_USER_TOKEN *token, uid_t uid, gid_t gid, int ngroups, gid
for (i = 0; i < ngroups; i++)
gid_to_sid( &psids[i+2], groups[i]);
+
+ return token;
}
/****************************************************************************
@@ -258,7 +255,7 @@ uint16 register_vuid(uid_t uid,gid_t gid, char *unix_name, char *requested_name,
get_current_groups( &vuser->n_groups, &vuser->groups);
/* Create an NT_USER_TOKEN struct for this user. */
- setup_nt_token(&vuser->nt_user_token, uid,gid, vuser->n_groups, vuser->groups);
+ vuser->nt_user_token = create_nt_token(uid,gid, vuser->n_groups, vuser->groups);
DEBUG(3,("uid %d registered to name %s\n",(int)uid,unix_name));