printing: use housekeeping period that matches cache time
[vlendec/samba-autobuild/.git] / libcli / security / secdesc.h
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.
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 #ifndef _SECDESC_H_
24 #define _SECDESC_H_
25
26 /* The following definitions come from libcli/security/secdesc.c  */
27 #include "librpc/gen_ndr/security.h"
28
29 /*******************************************************************
30  Given a security_descriptor return the sec_info.
31 ********************************************************************/
32 uint32_t get_sec_info(const struct security_descriptor *sd);
33
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);
40
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);
49
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);
56
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);
63
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);
69
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);
75
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);
81
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);
86
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);
91
92 bool sd_has_inheritable_components(const struct security_descriptor *parent_ctr, bool container);
93 NTSTATUS se_create_child_secdesc(TALLOC_CTX *ctx,
94                                         struct security_descriptor **ppsd,
95                                         size_t *psize,
96                                         const struct security_descriptor *parent_ctr,
97                                         const struct dom_sid *owner_sid,
98                                         const struct dom_sid *group_sid,
99                                         bool container);
100 NTSTATUS se_create_child_secdesc_buf(TALLOC_CTX *ctx,
101                                         struct sec_desc_buf **ppsdb,
102                                         const struct security_descriptor *parent_ctr,
103                                         bool container);
104
105 #endif /* _SECDESC_H_ */