mirror of
https://github.com/samba-team/samba.git
synced 2025-08-07 09:49:30 +03:00
Samba hasn't used this function for ages - it's now handled deep in the
auth subsystem.
Andrew Bartlett
(This used to be commit 5693730594
)
This commit is contained in:
@ -369,72 +369,3 @@ BOOL unbecome_user(void)
|
||||
return True;
|
||||
}
|
||||
|
||||
/*****************************************************************
|
||||
Convert the supplementary SIDs returned in a netlogon into UNIX
|
||||
group gid_t's. Add to the total group array.
|
||||
*****************************************************************/
|
||||
|
||||
void add_supplementary_nt_login_groups(int *n_groups, gid_t **pp_groups, NT_USER_TOKEN **pptok)
|
||||
{
|
||||
int total_groups;
|
||||
int current_n_groups = *n_groups;
|
||||
gid_t *final_groups = NULL;
|
||||
size_t i;
|
||||
NT_USER_TOKEN *ptok = *pptok;
|
||||
NT_USER_TOKEN *new_tok = NULL;
|
||||
|
||||
if (!ptok || (ptok->num_sids == 0))
|
||||
return;
|
||||
|
||||
new_tok = dup_nt_token(ptok);
|
||||
if (!new_tok) {
|
||||
DEBUG(0,("add_supplementary_nt_login_groups: Failed to malloc new token\n"));
|
||||
return;
|
||||
}
|
||||
/* Leave the allocated space but empty the number of SIDs. */
|
||||
new_tok->num_sids = 0;
|
||||
|
||||
total_groups = current_n_groups + ptok->num_sids;
|
||||
|
||||
final_groups = (gid_t *)malloc(total_groups * sizeof(gid_t));
|
||||
if (!final_groups) {
|
||||
DEBUG(0,("add_supplementary_nt_login_groups: Failed to malloc new groups.\n"));
|
||||
delete_nt_token(&new_tok);
|
||||
return;
|
||||
}
|
||||
|
||||
memcpy(final_groups, *pp_groups, current_n_groups * sizeof(gid_t));
|
||||
for (i = 0; i < ptok->num_sids; i++) {
|
||||
gid_t new_grp;
|
||||
|
||||
if (NT_STATUS_IS_OK(sid_to_gid(&ptok->user_sids[i], &new_grp))) {
|
||||
/*
|
||||
* Don't add the gid_t if it is already in the current group
|
||||
* list. Some UNIXen don't like the same group more than once.
|
||||
*/
|
||||
int j;
|
||||
|
||||
for (j = 0; j < current_n_groups; j++)
|
||||
if (final_groups[j] == new_grp)
|
||||
break;
|
||||
|
||||
if ( j == current_n_groups) {
|
||||
/* Group not already present. */
|
||||
final_groups[current_n_groups++] = new_grp;
|
||||
}
|
||||
} else {
|
||||
/* SID didn't map. Copy to the new token to be saved. */
|
||||
sid_copy(&new_tok->user_sids[new_tok->num_sids++], &ptok->user_sids[i]);
|
||||
}
|
||||
}
|
||||
|
||||
SAFE_FREE(*pp_groups);
|
||||
*pp_groups = final_groups;
|
||||
*n_groups = current_n_groups;
|
||||
|
||||
/* Replace the old token with the truncated one. */
|
||||
delete_nt_token(&ptok);
|
||||
*pptok = new_tok;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user