source: releases/0.2/include/smb_deps.h @ 79

Last change on this file since 79 was 42, checked in by tim, 19 years ago

Changed to a CSV-like output format to accommodate extended fields

Added mtime output for keys

Added security descriptor columns (probably broken right now)

  • Property svn:keywords set to Id
File size: 11.6 KB
Line 
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 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 2 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: smb_deps.h 42 2005-08-04 02:41:25Z tim $
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 "byteorder.h"
37
38#define DEBUG(lvl,body) 0
39
40void* zalloc(size_t size);
41void* zcalloc(size_t size, unsigned int count);
42
43/* From includes.h */
44
45#define uint8 unsigned char
46#define int16 short
47#define uint16 unsigned short
48#define int32 int
49#define uint32 unsigned int
50
51#define SMB_STRUCT_STAT struct stat
52#define QSORT_CAST (int (*)(const void *, const void *))
53
54#define MIN(a,b) ((a)<(b)?(a):(b))
55#define MAX(a,b) ((a)>(b)?(a):(b))
56
57extern int DEBUGLEVEL;
58
59#define DLIST_ADD(list, p) \
60{ \
61        if (!(list)) { \
62                (list) = (p); \
63                (p)->next = (p)->prev = NULL; \
64        } else { \
65                (list)->prev = (p); \
66                (p)->next = (list); \
67                (p)->prev = NULL; \
68                (list) = (p); \
69        }\
70}
71
72/* End of stuff from includes.h */
73
74/* From smb.h */
75
76#define MAXSUBAUTHS 15
77
78typedef struct sid_info
79{
80  uint8  sid_rev_num;             /**< SID revision number */
81  uint8  num_auths;               /**< Number of sub-authorities */
82  uint8  id_auth[6];              /**< Identifier Authority */
83  /*
84   *  Pointer to sub-authorities.
85   *
86   * @note The values in these uint32's are in *native* byteorder, not
87   * neccessarily little-endian...... JRA.
88   */
89  uint32 sub_auths[MAXSUBAUTHS];
90} DOM_SID;
91
92typedef struct nttime_info
93{
94  uint32 low;
95  uint32 high;
96} NTTIME;
97
98/* End of stuff from smb.h */
99
100/* From smb_macros.h */
101
102#define TALLOC_ZERO_P(ctx, type) (type *)_talloc_zero(ctx, sizeof(type), #type)
103#define SMB_MALLOC_P(type) (type *)malloc_(sizeof(type))
104#define TALLOC_ARRAY(ctx, type, count) (type *)_talloc_array(ctx, sizeof(type), count, #type)
105#define TALLOC_ZERO_ARRAY(ctx, type, count) (type *)_talloc_zero_array(ctx, sizeof(type), count, #type)
106#define SAFE_FREE(x) do { if ((x) != NULL) {free(x); x=NULL;} } while(0)
107
108/* End of stuff from smb_macros.h */
109
110/* From ntdomain.h */
111
112struct uuid {
113       uint32 time_low;
114       uint16 time_mid;
115       uint16 time_hi_and_version;
116       uint8  clock_seq[2];
117       uint8  node[6];
118};
119
120typedef struct _prs_struct {
121        bool io; /* parsing in or out of data stream */
122        /*
123         * If the (incoming) data is big-endian. On output we are
124          * always little-endian.
125           */ 
126           bool bigendian_data;
127           uint8 align; /* data alignment */
128           bool is_dynamic; /* Do we own this memory or not ? */
129           uint32 data_offset; /* Current working offset into data. */
130           uint32 buffer_size; /* Current allocated size of the buffer. */
131           uint32 grow_size; /* size requested via prs_grow() calls */
132           char *data_p; /* The buffer itself. */
133           void *mem_ctx; /* When unmarshalling, use this.... */
134} prs_struct;
135
136#define MARSHALL 0
137#define UNMARSHALL 1
138
139#define RPC_LITTLE_ENDIAN  0
140#define RPC_PARSE_ALIGN    4
141
142
143/* End of stuff from ntdomain.h */
144
145/* From nt_status.h */
146
147typedef uint32 NTSTATUS;
148typedef uint32 WERROR;
149
150/* End of stuff from nt_status.h */
151
152/* From lib/time.c */
153
154#define CHAR_BIT 8
155#define TIME_T_MIN ((time_t)0 < (time_t) -1 ? (time_t) 0 \
156                    : ~ (time_t) 0 << (sizeof (time_t) * CHAR_BIT - 1))
157#define TIME_T_MAX (~ (time_t) 0 - TIME_T_MIN)
158#define TIME_FIXUP_CONSTANT (369.0*365.25*24*60*60-(3.0*24*60*60+6.0*60*60))
159
160void unix_to_nt_time(NTTIME *nt, time_t t);
161time_t nt_time_to_unix(NTTIME *nt);
162
163/* End of stuff from lib/time.c */
164
165/* From rpc_dce.h */
166
167#define MAX_PDU_FRAG_LEN 0x10b8 /* this is what w2k sets */
168
169/* End of stuff from rpc_dce.h */
170
171/* From parse_prs.h */
172
173bool prs_grow(prs_struct *ps, uint32 extra_space);
174bool prs_align(prs_struct *ps);
175bool prs_init(prs_struct *ps, uint32 size, void *ctx, bool io);
176char *prs_mem_get(prs_struct *ps, uint32 extra_size);
177bool prs_uint32(const char *name, prs_struct *ps, int depth, uint32 *data32);
178bool prs_uint32s(bool charmode, const char *name, prs_struct *ps, 
179                 int depth, uint32 *data32s, int len);
180bool prs_uint16(const char *name, prs_struct *ps, int depth, uint16 *data16);
181bool prs_uint16_pre(const char *name, prs_struct *ps, int depth, 
182                    uint16 *data16, uint32 *offset);
183bool prs_uint16_post(const char *name, prs_struct *ps, int depth, 
184                     uint16 *data16, uint32 ptr_uint16, uint32 start_offset);
185bool prs_uint8(const char *name, prs_struct *ps, int depth, uint8 *data8);
186bool prs_uint8s(bool charmode, const char *name, prs_struct *ps, int depth, uint8 *data8s, int len);
187bool prs_set_offset(prs_struct *ps, uint32 offset);
188
189/* End of stuff from parse_prs.h */
190
191
192
193/* buffer used by \winreg\ calls to fill in arbitrary REG_XXX values.
194   It *may* look like a UNISTR2 but it is *not*.  This is not a goof
195   by the winreg developers.  It is a generic buffer.  buffer length
196   is stored in bytes (not # of uint16's) */
197
198typedef struct {
199        uint32 buf_max_len;
200        uint32 offset;
201        uint32 buf_len;
202        uint16 *buffer;
203} REGVAL_BUFFER;
204
205typedef struct {
206        uint32 buf_len;
207        uint16 *buffer; /* data */
208} BUFFER5;
209
210
211/**********************************************************************
212 * UNICODE string variations
213 **********************************************************************/
214
215
216typedef struct {                /* UNISTR - unicode string size and buffer */
217        uint16 *buffer;         /* unicode characters. ***MUST*** be
218                                   little-endian. ***MUST*** be null-terminated */
219} UNISTR;
220
221typedef struct {                /* UNISTR2 - unicode string size (in
222                                   uint16 unicode chars) and buffer */
223        uint32 uni_max_len;
224        uint32 offset;
225        uint32 uni_str_len;
226        uint16 *buffer;         /* unicode characters. ***MUST*** be little-endian.
227                                  **must** be null-terminated and the uni_str_len
228                                  should include the NULL character */
229} UNISTR2;
230
231/* i think this is the same as a BUFFER5 used in the spoolss code --jerry */
232/* not sure about how the termination matches between the uint16 buffers thought */
233
234typedef struct {                /* UNISTR3 - XXXX not sure about this structure */
235        uint32 uni_str_len;
236        UNISTR str;
237} UNISTR3;
238
239typedef struct {                /* Buffer wrapped around a UNISTR2 */
240        uint16 length;          /* number of bytes not counting NULL terminatation */
241        uint16 size;            /* number of bytes including NULL terminatation */
242        UNISTR2 *string;
243} UNISTR4;
244
245typedef struct {
246        uint32 count;
247        UNISTR4 *strings;
248} UNISTR4_ARRAY;
249
250
251/**********************************************************************
252 * String variations
253 **********************************************************************/
254
255typedef struct {                /* STRING2 - string size (in uint8 chars) and buffer */
256        uint32 str_max_len;
257        uint32 offset;
258        uint32 str_str_len;
259        uint8  *buffer;         /* uint8 characters. **NOT** necessarily null-terminated */
260} STRING2;
261
262
263/* From rpc_secdesc.h */
264
265typedef struct security_info_info
266{
267        uint32 mask;
268
269} SEC_ACCESS;
270
271typedef struct security_ace_info
272{
273        uint8 type;  /* xxxx_xxxx_ACE_TYPE - e.g allowed / denied etc */
274        uint8 flags; /* xxxx_INHERIT_xxxx - e.g OBJECT_INHERIT_ACE */
275        uint16 size;
276
277        SEC_ACCESS info;
278
279        /* this stuff may be present when type is XXXX_TYPE_XXXX_OBJECT */
280        uint32  obj_flags; /* xxxx_ACE_OBJECT_xxxx e.g present/inherited present etc */
281        struct uuid obj_guid;  /* object GUID */
282        struct uuid inh_guid;  /* inherited object GUID */             
283        /* eof object stuff */
284
285        DOM_SID trustee;
286
287} SEC_ACE;
288
289typedef struct security_acl_info
290{
291        uint16 revision; /* 0x0003 */
292        uint16 size; /* size in bytes of the entire ACL structure */
293        uint32 num_aces; /* number of Access Control Entries */
294
295        SEC_ACE *ace;
296
297} SEC_ACL;
298
299typedef struct security_descriptor_info
300{
301        uint16 revision; /* 0x0001 */
302        uint16 type;     /* SEC_DESC_xxxx flags */
303
304        uint32 off_owner_sid; /* offset to owner sid */
305        uint32 off_grp_sid  ; /* offset to group sid */
306        uint32 off_sacl     ; /* offset to system list of permissions */
307        uint32 off_dacl     ; /* offset to list of permissions */
308
309        SEC_ACL *dacl; /* user ACL */
310        SEC_ACL *sacl; /* system ACL */
311        DOM_SID *owner_sid; 
312        DOM_SID *grp_sid;
313
314} SEC_DESC;
315
316/* End of stuff from rpc_secdesc.h */
317
318
319/* From pstring.h */
320
321#define PSTRING_LEN 1024
322#define FSTRING_LEN 256
323
324typedef char pstring[PSTRING_LEN];
325typedef char fstring[FSTRING_LEN];
326
327/* End of stuff from pstring.h */
328
329/* From reg_objects.h */
330
331typedef struct _REGISTRY_VALUE {
332        fstring         valuename;
333        uint16          type;
334        /* this should be encapsulated in an RPC_DATA_BLOB */
335        uint32          size;   /* in bytes */
336        uint8           *data_p;
337} REGISTRY_VALUE;
338
339/* container for registry values */
340typedef struct {
341        void      *ctx;
342        uint32          num_values;
343        REGISTRY_VALUE  **values;
344} REGVAL_CTR;
345
346/* container for registry subkey names */
347typedef struct {
348        void    *ctx;
349        uint32          num_subkeys;
350        char            **subkeys;
351} REGSUBKEY_CTR;
352
353/* represent a registry key with all its subkeys and values */
354struct _regobj_key;
355
356typedef struct _regobj_key {
357        void *ctx;
358
359        char *name;
360
361        REGVAL_CTR values;
362        REGSUBKEY_CTR subkeys;
363} REGOBJ_KEY;
364
365/* End of stuff from reg_objects.h */
366
367/* From rpc_secdes.h */
368
369#define SEC_DESC_DACL_PRESENT           0x0004
370#define SEC_DESC_SACL_PRESENT           0x0010
371#define  SEC_DESC_HEADER_SIZE (2 * sizeof(uint16) + 4 * sizeof(uint32))
372   /* thanks for Jim McDonough <jmcd@us.ibm.com> */
373#define SEC_ACE_OBJECT_PRESENT        0x00000001
374#define SEC_ACE_OBJECT_INHERITED_PRESENT 0x00000002
375
376#define SEC_ACE_TYPE_ACCESS_ALLOWED_OBJECT      0x5
377#define SEC_ACE_TYPE_ACCESS_DENIED_OBJECT       0x6
378#define SEC_ACE_TYPE_SYSTEM_AUDIT_OBJECT        0x7
379#define SEC_ACE_TYPE_SYSTEM_ALARM_OBJECT        0x8
380
381/* End of stuff from rpc_secdes.h */
382
383/* From rpc_parse/parse_misc.c */
384
385bool smb_io_uuid(const char *desc, struct uuid *uuid, 
386                 prs_struct *ps, int depth);
387bool smb_io_time(const char *desc, NTTIME *nttime, prs_struct *ps, int depth);
388bool smb_io_dom_sid(const char *desc, DOM_SID *sid, prs_struct *ps, int depth);
389
390/* End of stuff from rpc_parse/parse_misc.c */
391
392/* From lib/util_sid.c */
393
394size_t sid_size(const DOM_SID *sid);
395int sid_compare_auth(const DOM_SID *sid1, const DOM_SID *sid2);
396int sid_compare(const DOM_SID *sid1, const DOM_SID *sid2);
397bool sid_equal(const DOM_SID *sid1, const DOM_SID *sid2);
398
399/* End of stuff from lib/util_sid.c */
400
401/* From lib/secace.c */
402
403bool sec_ace_object(uint8 type);
404
405/* End of stuff from lib/secace.c */
406
407/* From rpc_parse/parse_sec.c */
408
409bool sec_io_access(const char *desc, SEC_ACCESS *t, prs_struct *ps, int depth);
410bool sec_io_ace(const char *desc, SEC_ACE *psa, prs_struct *ps, int depth);
411bool sec_io_acl(const char *desc, SEC_ACL **ppsa, prs_struct *ps, int depth);
412bool sec_io_desc(const char *desc, SEC_DESC **ppsd, prs_struct *ps, int depth);
413
414/* End of stuff from rpc_parse/parse_sec.c */
415
416/* From lib/secace.c */
417
418bool sec_ace_equal(SEC_ACE *s1, SEC_ACE *s2);
419
420/* End of stuff from lib/secace.c */
421
422/* From lib/secacl.c */
423
424bool sec_acl_equal(SEC_ACL *s1, SEC_ACL *s2);
425
426/* End of stuff from lib/secacl.c */
427
428/* From lib/secdesc.c */
429
430bool sec_desc_equal(SEC_DESC *s1, SEC_DESC *s2);
431
432/* End of stuff from lib/secdesc.c */
Note: See TracBrowser for help on using the repository browser.