2 * Unix SMB/CIFS implementation.
3 * Authentication utility functions
4 * Copyright (C) Andrew Tridgell 1992-1998
5 * Copyright (C) Andrew Bartlett 2001
6 * Copyright (C) Jeremy Allison 2000-2001
7 * Copyright (C) Rafal Szczesniak 2002
8 * Copyright (C) Volker Lendecke 2006
9 * Copyright (C) Michael Adam 2007
11 * This program is free software; you can redistribute it and/or modify
12 * it under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 3 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 /* function(s) moved from auth/auth_util.c to minimize linker deps */
30 /****************************************************************************
31 Duplicate a SID token.
32 ****************************************************************************/
34 NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken)
41 token = TALLOC_P(mem_ctx, NT_USER_TOKEN);
43 DEBUG(0, ("talloc failed\n"));
49 if (ptoken->user_sids && ptoken->num_sids) {
50 token->user_sids = (DOM_SID *)talloc_memdup(
51 token, ptoken->user_sids, sizeof(DOM_SID) * ptoken->num_sids );
53 if (token->user_sids == NULL) {
54 DEBUG(0, ("talloc_memdup failed\n"));
58 token->num_sids = ptoken->num_sids;
61 /* copy the privileges; don't consider failure to be critical here */
63 if ( !se_priv_copy( &token->privileges, &ptoken->privileges ) ) {
64 DEBUG(0,("dup_nt_token: Failure to copy SE_PRIV!. "
65 "Continuing with 0 privileges assigned.\n"));