1 | /*
|
---|
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
|
---|
10 | *
|
---|
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.
|
---|
15 | *
|
---|
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.
|
---|
20 | *
|
---|
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/>.
|
---|
23 | */
|
---|
24 |
|
---|
25 | /* function(s) moved from auth/auth_util.c to minimize linker deps */
|
---|
26 |
|
---|
27 | #include "includes.h"
|
---|
28 |
|
---|
29 | /****************************************************************************
|
---|
30 | Duplicate a SID token.
|
---|
31 | ****************************************************************************/
|
---|
32 |
|
---|
33 | NT_USER_TOKEN *dup_nt_token(TALLOC_CTX *mem_ctx, const NT_USER_TOKEN *ptoken)
|
---|
34 | {
|
---|
35 | NT_USER_TOKEN *token;
|
---|
36 |
|
---|
37 | if (!ptoken)
|
---|
38 | return NULL;
|
---|
39 |
|
---|
40 | token = TALLOC_P(mem_ctx, NT_USER_TOKEN);
|
---|
41 | if (token == NULL) {
|
---|
42 | DEBUG(0, ("talloc failed\n"));
|
---|
43 | return NULL;
|
---|
44 | }
|
---|
45 |
|
---|
46 | ZERO_STRUCTP(token);
|
---|
47 |
|
---|
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 );
|
---|
51 |
|
---|
52 | if (token->user_sids == NULL) {
|
---|
53 | DEBUG(0, ("talloc_memdup failed\n"));
|
---|
54 | TALLOC_FREE(token);
|
---|
55 | return NULL;
|
---|
56 | }
|
---|
57 | token->num_sids = ptoken->num_sids;
|
---|
58 | }
|
---|
59 |
|
---|
60 | /* copy the privileges; don't consider failure to be critical here */
|
---|
61 |
|
---|
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"));
|
---|
65 | }
|
---|
66 |
|
---|
67 | return token;
|
---|
68 | }
|
---|
69 |
|
---|