source: trunk/server/libcli/security/secacl.c@ 938

Last change on this file since 938 was 745, checked in by Silvan Scherrer, 13 years ago

Samba Server: updated trunk to 3.6.0

File size: 2.7 KB
Line 
1/*
2 * Unix SMB/Netbios implementation.
3 * SEC_ACL handling routines
4 * Copyright (C) Andrew Tridgell 1992-1998,
5 * Copyright (C) Jeremy R. Allison 1995-2003.
6 * Copyright (C) Luke Kenneth Casson Leighton 1996-1998,
7 * Copyright (C) Paul Ashton 1997-1998.
8 *
9 * This program is free software; you can redistribute it and/or modify
10 * it under the terms of the GNU General Public License as published by
11 * the Free Software Foundation; either version 3 of the License, or
12 * (at your option) any later version.
13 *
14 * This program is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17 * GNU General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this program; if not, see <http://www.gnu.org/licenses/>.
21 */
22
23#include "includes.h"
24#include "librpc/gen_ndr/ndr_security.h"
25#include "libcli/security/secace.h"
26#include "libcli/security/secacl.h"
27
28#define SEC_ACL_HEADER_SIZE (2 * sizeof(uint16_t) + sizeof(uint32_t))
29
30/*******************************************************************
31 Create a SEC_ACL structure.
32********************************************************************/
33
34struct security_acl *make_sec_acl(TALLOC_CTX *ctx,
35 enum security_acl_revision revision,
36 int num_aces, struct security_ace *ace_list)
37{
38 struct security_acl *dst;
39 int i;
40
41 if((dst = talloc_zero(ctx, struct security_acl)) == NULL)
42 return NULL;
43
44 dst->revision = revision;
45 dst->num_aces = num_aces;
46 dst->size = SEC_ACL_HEADER_SIZE;
47
48 /* Now we need to return a non-NULL address for the ace list even
49 if the number of aces required is zero. This is because there
50 is a distinct difference between a NULL ace and an ace with zero
51 entries in it. This is achieved by checking that num_aces is a
52 positive number. */
53
54 if ((num_aces) &&
55 ((dst->aces = talloc_array(dst, struct security_ace, num_aces))
56 == NULL)) {
57 return NULL;
58 }
59
60 for (i = 0; i < num_aces; i++) {
61 dst->aces[i] = ace_list[i]; /* Structure copy. */
62 dst->size += ace_list[i].size;
63 }
64
65 return dst;
66}
67
68/*******************************************************************
69 Duplicate a SEC_ACL structure.
70********************************************************************/
71
72struct security_acl *dup_sec_acl(TALLOC_CTX *ctx, struct security_acl *src)
73{
74 if(src == NULL)
75 return NULL;
76
77 return make_sec_acl(ctx, src->revision, src->num_aces, src->aces);
78}
Note: See TracBrowser for help on using the repository browser.