s3: winbindd: Old NT Domain code sets struct winbind_domain->alt_name to be NULL...
[Samba.git] / libcli / security / secdesc.h
blob4c96ccde555f40799c36b4a43acad0c210d68ad7
1 /*
2 * Unix SMB/Netbios implementation.
3 * SEC_DESC handling functions
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.
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.
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.
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/>.
23 #ifndef _SECDESC_H_
24 #define _SECDESC_H_
26 /* The following definitions come from libcli/security/secdesc.c */
27 #include "librpc/gen_ndr/security.h"
29 /*******************************************************************
30 Given a security_descriptor return the sec_info.
31 ********************************************************************/
32 uint32_t get_sec_info(const struct security_descriptor *sd);
34 /*******************************************************************
35 Merge part of security descriptor old_sec in to the empty sections of
36 security descriptor new_sec.
37 ********************************************************************/
38 struct sec_desc_buf *sec_desc_merge_buf(TALLOC_CTX *ctx, struct sec_desc_buf *new_sdb, struct sec_desc_buf *old_sdb);
39 struct security_descriptor *sec_desc_merge(TALLOC_CTX *ctx, struct security_descriptor *new_sdb, struct security_descriptor *old_sdb);
41 /*******************************************************************
42 Creates a struct security_descriptor structure
43 ********************************************************************/
44 struct security_descriptor *make_sec_desc(TALLOC_CTX *ctx,
45 enum security_descriptor_revision revision,
46 uint16_t type,
47 const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
48 struct security_acl *sacl, struct security_acl *dacl, size_t *sd_size);
50 /*******************************************************************
51 Convert a secdesc into a byte stream
52 ********************************************************************/
53 NTSTATUS marshall_sec_desc(TALLOC_CTX *mem_ctx,
54 const struct security_descriptor *secdesc,
55 uint8_t **data, size_t *len);
57 /*******************************************************************
58 Convert a secdesc_buf into a byte stream
59 ********************************************************************/
60 NTSTATUS marshall_sec_desc_buf(TALLOC_CTX *mem_ctx,
61 const struct sec_desc_buf *secdesc_buf,
62 uint8_t **data, size_t *len);
64 /*******************************************************************
65 Parse a byte stream into a secdesc
66 ********************************************************************/
67 NTSTATUS unmarshall_sec_desc(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
68 struct security_descriptor **psecdesc);
70 /*******************************************************************
71 Parse a byte stream into a sec_desc_buf
72 ********************************************************************/
73 NTSTATUS unmarshall_sec_desc_buf(TALLOC_CTX *mem_ctx, uint8_t *data, size_t len,
74 struct sec_desc_buf **psecdesc_buf);
76 /*******************************************************************
77 Creates a struct security_descriptor structure with typical defaults.
78 ********************************************************************/
79 struct security_descriptor *make_standard_sec_desc(TALLOC_CTX *ctx, const struct dom_sid *owner_sid, const struct dom_sid *grp_sid,
80 struct security_acl *dacl, size_t *sd_size);
82 /*******************************************************************
83 Creates a struct sec_desc_buf structure.
84 ********************************************************************/
85 struct sec_desc_buf *make_sec_desc_buf(TALLOC_CTX *ctx, size_t len, struct security_descriptor *sec_desc);
87 /*******************************************************************
88 Duplicates a struct sec_desc_buf structure.
89 ********************************************************************/
90 struct sec_desc_buf *dup_sec_desc_buf(TALLOC_CTX *ctx, struct sec_desc_buf *src);
92 /*******************************************************************
93 Modify a SID's permissions in a struct security_descriptor.
94 ********************************************************************/
95 NTSTATUS sec_desc_mod_sid(struct security_descriptor *sd, struct dom_sid *sid, uint32_t mask);
97 bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container);
98 NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
99 struct security_descriptor **ppsd,
100 size_t *psize,
101 const struct security_descriptor *parent_ctr,
102 const struct dom_sid *owner_sid,
103 const struct dom_sid *group_sid,
104 bool container);
105 NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
106 struct sec_desc_buf **ppsdb,
107 const struct security_descriptor *parent_ctr,
108 bool container);
110 #endif /* _SECDESC_H_ */