1 | /* |
---|
2 | * This file contains miscellaneous pieces of code which regfio.c |
---|
3 | * depends upon, from the Samba Subversion tree. See: |
---|
4 | * http://websvn.samba.org/cgi-bin/viewcvs.cgi/trunk/source/ |
---|
5 | * |
---|
6 | * Copyright (C) 2005,2009 Timothy D. Morgan |
---|
7 | * Copyright (C) 1992-2005 Samba development team |
---|
8 | * (see individual files under Subversion for details.) |
---|
9 | * |
---|
10 | * This program is free software; you can redistribute it and/or modify |
---|
11 | * it under the terms of the GNU General Public License as published by |
---|
12 | * the Free Software Foundation; version 3 of the License. |
---|
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, write to the Free Software |
---|
21 | * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. |
---|
22 | * |
---|
23 | * $Id $ |
---|
24 | */ |
---|
25 | |
---|
26 | #include <stdlib.h> |
---|
27 | #include <stdbool.h> |
---|
28 | #include <stdio.h> |
---|
29 | #include <string.h> |
---|
30 | #include <errno.h> |
---|
31 | #include <fcntl.h> |
---|
32 | #include <sys/stat.h> |
---|
33 | #include <sys/types.h> |
---|
34 | #include <unistd.h> |
---|
35 | |
---|
36 | #include "smb_deps.h" |
---|
37 | |
---|
38 | |
---|
39 | /* From smb.h */ |
---|
40 | |
---|
41 | #define MAXSUBAUTHS 15 |
---|
42 | |
---|
43 | typedef struct sid_info |
---|
44 | { |
---|
45 | uint8 sid_rev_num; /**< SID revision number */ |
---|
46 | uint8 num_auths; /**< Number of sub-authorities */ |
---|
47 | uint8 id_auth[6]; /**< Identifier Authority */ |
---|
48 | /* |
---|
49 | * Pointer to sub-authorities. |
---|
50 | * |
---|
51 | * @note The values in these uint32's are in *native* byteorder, not |
---|
52 | * neccessarily little-endian...... JRA. |
---|
53 | */ |
---|
54 | uint32 sub_auths[MAXSUBAUTHS]; |
---|
55 | } DOM_SID; |
---|
56 | |
---|
57 | /* End of stuff from smb.h */ |
---|
58 | |
---|
59 | |
---|
60 | /* From rpc_secdesc.h */ |
---|
61 | |
---|
62 | typedef struct security_info_info |
---|
63 | { |
---|
64 | uint32 mask; |
---|
65 | |
---|
66 | } SEC_ACCESS; |
---|
67 | |
---|
68 | typedef struct security_ace_info |
---|
69 | { |
---|
70 | uint8 type; /* xxxx_xxxx_ACE_TYPE - e.g allowed / denied etc */ |
---|
71 | uint8 flags; /* xxxx_INHERIT_xxxx - e.g OBJECT_INHERIT_ACE */ |
---|
72 | uint16 size; |
---|
73 | |
---|
74 | SEC_ACCESS info; |
---|
75 | |
---|
76 | /* this stuff may be present when type is XXXX_TYPE_XXXX_OBJECT */ |
---|
77 | uint32 obj_flags; /* xxxx_ACE_OBJECT_xxxx e.g present/inherited present etc */ |
---|
78 | struct uuid obj_guid; /* object GUID */ |
---|
79 | struct uuid inh_guid; /* inherited object GUID */ |
---|
80 | /* eof object stuff */ |
---|
81 | |
---|
82 | DOM_SID trustee; |
---|
83 | |
---|
84 | } SEC_ACE; |
---|
85 | |
---|
86 | typedef struct security_acl_info |
---|
87 | { |
---|
88 | uint16 revision; /* 0x0003 */ |
---|
89 | uint16 size; /* size in bytes of the entire ACL structure */ |
---|
90 | uint32 num_aces; /* number of Access Control Entries */ |
---|
91 | |
---|
92 | SEC_ACE *ace; |
---|
93 | |
---|
94 | } SEC_ACL; |
---|
95 | |
---|
96 | typedef struct security_descriptor_info |
---|
97 | { |
---|
98 | uint16 revision; /* 0x0001 */ |
---|
99 | uint16 type; /* SEC_DESC_xxxx flags */ |
---|
100 | |
---|
101 | uint32 off_owner_sid; /* offset to owner sid */ |
---|
102 | uint32 off_grp_sid ; /* offset to group sid */ |
---|
103 | uint32 off_sacl ; /* offset to system list of permissions */ |
---|
104 | uint32 off_dacl ; /* offset to list of permissions */ |
---|
105 | |
---|
106 | SEC_ACL *dacl; /* user ACL */ |
---|
107 | SEC_ACL *sacl; /* system ACL */ |
---|
108 | DOM_SID *owner_sid; |
---|
109 | DOM_SID *grp_sid; |
---|
110 | |
---|
111 | } SEC_DESC; |
---|
112 | |
---|
113 | /* End of stuff from rpc_secdesc.h */ |
---|
114 | |
---|
115 | |
---|
116 | |
---|
117 | /* From rpc_secdes.h */ |
---|
118 | |
---|
119 | #define SEC_DESC_DACL_PRESENT 0x0004 |
---|
120 | #define SEC_DESC_SACL_PRESENT 0x0010 |
---|
121 | #define SEC_DESC_HEADER_SIZE (2 * sizeof(uint16) + 4 * sizeof(uint32)) |
---|
122 | /* thanks for Jim McDonough <jmcd@us.ibm.com> */ |
---|
123 | #define SEC_ACE_OBJECT_PRESENT 0x00000001 |
---|
124 | #define SEC_ACE_OBJECT_INHERITED_PRESENT 0x00000002 |
---|
125 | |
---|
126 | #define SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT 0x5 |
---|
127 | #define SEC_ACE_TYPE_ACCESS_DENIED_OBJECT 0x6 |
---|
128 | #define SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT 0x7 |
---|
129 | #define SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT 0x8 |
---|
130 | |
---|
131 | /* End of stuff from rpc_secdes.h */ |
---|
132 | |
---|
133 | /* From rpc_parse/parse_misc.c */ |
---|
134 | |
---|
135 | bool smb_io_dom_sid(const char *desc, DOM_SID *sid, prs_struct *ps, int depth); |
---|
136 | |
---|
137 | /* End of stuff from rpc_parse/parse_misc.c */ |
---|
138 | |
---|
139 | /* From lib/util_sid.c */ |
---|
140 | |
---|
141 | size_t sid_size(const DOM_SID *sid); |
---|
142 | int sid_compare_auth(const DOM_SID *sid1, const DOM_SID *sid2); |
---|
143 | int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2); |
---|
144 | bool sid_equal(const DOM_SID *sid1, const DOM_SID *sid2); |
---|
145 | |
---|
146 | /* End of stuff from lib/util_sid.c */ |
---|
147 | |
---|
148 | /* From lib/secace.c */ |
---|
149 | |
---|
150 | bool sec_ace_object(uint8 type); |
---|
151 | |
---|
152 | /* End of stuff from lib/secace.c */ |
---|
153 | |
---|
154 | /* From rpc_parse/parse_sec.c */ |
---|
155 | |
---|
156 | bool sec_io_access(const char *desc, SEC_ACCESS *t, prs_struct *ps, int depth); |
---|
157 | bool sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps, int depth); |
---|
158 | bool sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth); |
---|
159 | bool sec_io_desc(const char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth); |
---|
160 | |
---|
161 | /* End of stuff from rpc_parse/parse_sec.c */ |
---|
162 | |
---|
163 | /* From lib/secace.c */ |
---|
164 | |
---|
165 | bool sec_ace_equal(SEC_ACE *s1, SEC_ACE *s2); |
---|
166 | |
---|
167 | /* End of stuff from lib/secace.c */ |
---|
168 | |
---|
169 | /* From lib/secacl.c */ |
---|
170 | |
---|
171 | bool sec_acl_equal(SEC_ACL *s1, SEC_ACL *s2); |
---|
172 | |
---|
173 | /* End of stuff from lib/secacl.c */ |
---|
174 | |
---|
175 | /* From lib/secdesc.c */ |
---|
176 | |
---|
177 | bool sec_desc_equal(SEC_DESC *s1, SEC_DESC *s2); |
---|
178 | |
---|
179 | /* End of stuff from lib/secdesc.c */ |
---|