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, see <http://www.gnu.org/licenses/>.
25 /* function(s) moved from auth/auth_util.c to minimize linker deps */
29 /****************************************************************************
30 Duplicate a SID token.
31 ****************************************************************************/
33 NT_USER_TOKEN
*dup_nt_token(TALLOC_CTX
*mem_ctx
, const NT_USER_TOKEN
*ptoken
)
40 token
= TALLOC_P(mem_ctx
, NT_USER_TOKEN
);
42 DEBUG(0, ("talloc failed\n"));
48 if (ptoken
->user_sids
&& ptoken
->num_sids
) {
49 token
->user_sids
= (DOM_SID
*)talloc_memdup(
50 token
, ptoken
->user_sids
, sizeof(DOM_SID
) * ptoken
->num_sids
);
52 if (token
->user_sids
== NULL
) {
53 DEBUG(0, ("talloc_memdup failed\n"));
57 token
->num_sids
= ptoken
->num_sids
;
60 /* copy the privileges; don't consider failure to be critical here */
62 if ( !se_priv_copy( &token
->privileges
, &ptoken
->privileges
) ) {
63 DEBUG(0,("dup_nt_token: Failure to copy SE_PRIV!. "
64 "Continuing with 0 privileges assigned.\n"));