summaryrefslogtreecommitdiff
path: root/source3/include
diff options
context:
space:
mode:
authorGerald Carter <jerry@samba.org>2005-05-23 16:25:31 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 10:56:57 -0500
commitf0c650a38286c07b9f3e83139c15bfbadc70ad5f (patch)
tree2c63cd42bf12e46c94628a82a40b19db47fd0aae /source3/include
parente2404c81295fe3468c9b635b549f1b16f5c5f323 (diff)
downloadsamba-f0c650a38286c07b9f3e83139c15bfbadc70ad5f.tar.gz
samba-f0c650a38286c07b9f3e83139c15bfbadc70ad5f.tar.bz2
samba-f0c650a38286c07b9f3e83139c15bfbadc70ad5f.zip
r6942: * merging the registry changes back to the 3.0 tree
* removing the testprns tool (This used to be commit 81ffb0dbbbd244623507880c323a3c37e2b8dc4d)
Diffstat (limited to 'source3/include')
-rw-r--r--source3/include/reg_objects.h63
-rw-r--r--source3/include/regfio.h222
-rw-r--r--source3/include/rpc_reg.h88
-rw-r--r--source3/include/rpc_secdes.h44
4 files changed, 344 insertions, 73 deletions
diff --git a/source3/include/reg_objects.h b/source3/include/reg_objects.h
new file mode 100644
index 0000000000..a31f7097d3
--- /dev/null
+++ b/source3/include/reg_objects.h
@@ -0,0 +1,63 @@
+/*
+ Unix SMB/CIFS implementation.
+ SMB parameters and setup
+ Copyright (C) Gerald Carter 2002-2005.
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License for more details.
+
+ You should have received a copy of the GNU General Public License
+ along with this program; if not, write to the Free Software
+ Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+*/
+
+#ifndef _REG_OBJECTS_H /* _REG_OBJECTS_H */
+#define _REG_OBJECTS_H
+
+/* structure to contain registry values */
+
+typedef struct {
+ fstring valuename;
+ uint16 type;
+ uint32 size; /* in bytes */
+ uint8 *data_p;
+} REGISTRY_VALUE;
+
+/* container for registry values */
+
+typedef struct {
+ TALLOC_CTX *ctx;
+ uint32 num_values;
+ REGISTRY_VALUE **values;
+} REGVAL_CTR;
+
+/* container for registry subkey names */
+
+typedef struct {
+ TALLOC_CTX *ctx;
+ uint32 num_subkeys;
+ char **subkeys;
+} REGSUBKEY_CTR;
+
+/* represent a registry key with all its subkeys and values */
+
+struct _regobj_key;
+
+typedef struct _regobj_key {
+ TALLOC_CTX *ctx;
+
+ char *name;
+
+ REGVAL_CTR values;
+ REGSUBKEY_CTR subkeys;
+} REGOBJ_KEY;
+
+#endif /* _REG_OBJECTS_H */
+
diff --git a/source3/include/regfio.h b/source3/include/regfio.h
new file mode 100644
index 0000000000..e088a4a344
--- /dev/null
+++ b/source3/include/regfio.h
@@ -0,0 +1,222 @@
+/*
+ * Unix SMB/CIFS implementation.
+ * Windows NT registry I/O library
+ * Copyright (c) Gerald (Jerry) Carter 2005
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+ */
+
+/************************************************************
+ * Most of this information was obtained from
+ * http://www.wednesday.demon.co.uk/dosreg.html
+ * Thanks Nigel!
+ ***********************************************************/
+
+
+#ifndef _REGFIO_H
+#define _REGFIO_H
+
+/* Macros */
+
+#define REGF_BLOCKSIZE 0x1000
+#define REGF_ALLOC_BLOCK 0x1000
+
+/* header sizes for various records */
+
+#define REGF_HDR_SIZE 4
+#define HBIN_HDR_SIZE 4
+#define HBIN_HEADER_REC_SIZE 0x24
+#define REC_HDR_SIZE 2
+
+#define REGF_OFFSET_NONE 0xffffffff
+
+/* Flags for the vk records */
+
+#define VK_FLAG_NAME_PRESENT 0x0001
+#define VK_DATA_IN_OFFSET 0x80000000
+
+/* NK record macros */
+
+#define NK_TYPE_LINKKEY 0x0010
+#define NK_TYPE_NORMALKEY 0x0020
+#define NK_TYPE_ROOTKEY 0x002c
+
+#define HBIN_STORE_REF(x, y) { x->hbin = y; y->ref_count++ };
+#define HBIN_REMOVE_REF(x, y) { x->hbin = NULL; y->ref_count-- /* if the count == 0; we can clean up */ };
+
+
+/* HBIN block */
+struct regf_hbin;
+typedef struct regf_hbin {
+ struct regf_hbin *prev, *next;
+ uint32 file_off; /* my offset in the registry file */
+ uint32 free_off; /* offset to free space within the hbin record */
+ uint32 free_size; /* amount of data left in the block */
+ int ref_count; /* how many active records are pointing to this block (not used currently) */
+
+ char header[HBIN_HDR_SIZE]; /* "hbin" */
+ uint32 first_hbin_off; /* offset from first hbin block */
+ uint32 block_size; /* block size of this blockually a multiple of 4096Kb) */
+
+ prs_struct ps; /* data */
+
+ BOOL dirty; /* has this hbin block been modified? */
+} REGF_HBIN;
+
+/* ??? List -- list of key offsets and hashed names for consistency */
+
+typedef struct {
+ uint32 nk_off;
+ uint8 keycheck[sizeof(uint32)];
+} REGF_HASH_REC;
+
+typedef struct {
+ REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing this nk record */
+ uint32 hbin_off; /* offset from beginning of this hbin block */
+ uint32 rec_size; /* ((start_offset - end_offset) & 0xfffffff8) */
+
+ char header[REC_HDR_SIZE];
+ uint16 num_keys;
+ REGF_HASH_REC *hashes;
+} REGF_LF_REC;
+
+/* Key Value */
+
+typedef struct {
+ REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing this nk record */
+ uint32 hbin_off; /* offset from beginning of this hbin block */
+ uint32 rec_size; /* ((start_offset - end_offset) & 0xfffffff8) */
+ uint32 rec_off; /* offset stored in the value list */
+
+ char header[REC_HDR_SIZE];
+ char *valuename;
+ uint32 data_size;
+ uint32 data_off;
+ uint8 *data;
+ uint32 type;
+ uint16 flag;
+} REGF_VK_REC;
+
+
+/* Key Security */
+struct _regf_sk_rec;
+
+typedef struct _regf_sk_rec {
+ struct _regf_sk_rec *next, *prev;
+ REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing this nk record */
+ uint32 hbin_off; /* offset from beginning of this hbin block */
+ uint32 rec_size; /* ((start_offset - end_offset) & 0xfffffff8) */
+
+ uint32 sk_off; /* offset parsed from NK record used as a key
+ to lookup reference to this SK record */
+
+ char header[REC_HDR_SIZE];
+ uint32 prev_sk_off;
+ uint32 next_sk_off;
+ uint32 ref_count;
+ uint32 size;
+ SEC_DESC *sec_desc;
+} REGF_SK_REC;
+
+/* Key Name */
+
+typedef struct {
+ REGF_HBIN *hbin; /* pointer to HBIN record (in memory) containing this nk record */
+ uint32 hbin_off; /* offset from beginning of this hbin block */
+ uint32 subkey_index; /* index to next subkey record to return */
+ uint32 rec_size; /* ((start_offset - end_offset) & 0xfffffff8) */
+
+ /* header information */
+
+ char header[REC_HDR_SIZE];
+ uint16 key_type;
+ NTTIME mtime;
+ uint32 parent_off; /* back pointer in registry hive */
+ uint32 classname_off;
+ char *classname;
+ char *keyname;
+
+ /* max lengths */
+
+ uint32 max_bytes_subkeyname; /* max subkey name * 2 */
+ uint32 max_bytes_subkeyclassname; /* max subkey classname length (as if) */
+ uint32 max_bytes_valuename; /* max valuename * 2 */
+ uint32 max_bytes_value; /* max value data size */
+
+ /* unknowns */
+
+ uint32 unk_index; /* nigel says run time index ? */
+
+ /* children */
+
+ uint32 num_subkeys;
+ uint32 subkeys_off; /* hash records that point to NK records */
+ uint32 num_values;
+ uint32 values_off; /* value lists which point to VK records */
+ uint32 sk_off; /* offset to SK record */
+
+ /* link in the other records here */
+
+ REGF_LF_REC subkeys;
+ REGF_VK_REC *values;
+ REGF_SK_REC *sec_desc;
+
+} REGF_NK_REC;
+
+/* REGF block */
+
+typedef struct {
+ /* run time information */
+
+ int fd; /* file descriptor */
+ int open_flags; /* flags passed to the open() call */
+ TALLOC_CTX *mem_ctx; /* memory context for run-time file access information */
+ REGF_HBIN *block_list; /* list of open hbin blocks */
+
+ /* file format information */
+
+ char header[REGF_HDR_SIZE]; /* "regf" */
+ uint32 data_offset; /* offset to record in the first (or any?) hbin block */
+ uint32 last_block; /* offset to last hbin block in file */
+ uint32 checksum; /* XOR of bytes 0x0000 - 0x01FB */
+ NTTIME mtime;
+
+ REGF_SK_REC *sec_desc_list; /* list of security descriptors referenced by NK records */
+
+ /* unknowns used to simply writing */
+
+ uint32 unknown1;
+ uint32 unknown2;
+ uint32 unknown3;
+ uint32 unknown4;
+ uint32 unknown5;
+ uint32 unknown6;
+
+} REGF_FILE;
+
+/* Function Declarations */
+
+REGF_FILE* regfio_open( const char *filename, int flags, int mode );
+int regfio_close( REGF_FILE *r );
+
+REGF_NK_REC* regfio_rootkey( REGF_FILE *file );
+REGF_NK_REC* regfio_fetch_subkey( REGF_FILE *file, REGF_NK_REC *nk );
+REGF_NK_REC* regfio_write_key ( REGF_FILE *file, const char *name,
+ REGVAL_CTR *values, REGSUBKEY_CTR *subkeys,
+ SEC_DESC *sec_desc, REGF_NK_REC *parent );
+
+
+#endif /* _REGFIO_H */
+
diff --git a/source3/include/rpc_reg.h b/source3/include/rpc_reg.h
index f70fb5f03c..2849122667 100644
--- a/source3/include/rpc_reg.h
+++ b/source3/include/rpc_reg.h
@@ -25,6 +25,8 @@
#ifndef _RPC_REG_H /* _RPC_REG_H */
#define _RPC_REG_H
+#include "reg_objects.h"
+
/* RPC opnum */
#define REG_OPEN_HKCR 0x00
@@ -58,12 +60,15 @@
#define HKEY_USERS 0x80000003
#define HKEY_PERFORMANCE_DATA 0x80000004
-#define KEY_HKLM "HKLM"
-#define KEY_HKU "HKU"
-#define KEY_HKCR "HKCR"
-#define KEY_PRINTING "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
-#define KEY_EVENTLOG "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
-#define KEY_TREE_ROOT ""
+#define KEY_HKLM "HKLM"
+#define KEY_HKU "HKU"
+#define KEY_HKCR "HKCR"
+#define KEY_PRINTING "HKLM\\SYSTEM\\CurrentControlSet\\Control\\Print"
+#define KEY_PRINTING_2K "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Print"
+#define KEY_PRINTING_PORTS "HKLM\\SOFTWARE\\Microsoft\\Windows NT\\CurrentVersion\\Ports"
+#define KEY_EVENTLOG "HKLM\\SYSTEM\\CurrentControlSet\\Services\\Eventlog"
+#define KEY_SHARES "HKLM\\SYSTEM\\CurrentControlSet\\Services\\LanmanServer\\Shares"
+#define KEY_TREE_ROOT ""
/* Registry data types */
@@ -80,36 +85,6 @@
#define REG_FULL_RESOURCE_DESCRIPTOR 9
#define REG_RESOURCE_REQUIREMENTS_LIST 10
-/*
- * INTERNAL REGISTRY STRUCTURES
- */
-
-/* structure to contain registry values */
-
-typedef struct {
- fstring valuename;
- uint16 type;
- uint32 size; /* in bytes */
- uint8 *data_p;
-} REGISTRY_VALUE;
-
-/* container for registry values */
-
-typedef struct {
- TALLOC_CTX *ctx;
- uint32 num_values;
- REGISTRY_VALUE **values;
-} REGVAL_CTR;
-
-/* container for registry subkey names */
-
-typedef struct {
- TALLOC_CTX *ctx;
- uint32 num_subkeys;
- char **subkeys;
-} REGSUBKEY_CTR;
-
-
/*
* container for function pointers to enumeration routines
* for vitural registry view
@@ -129,7 +104,6 @@ typedef struct {
} REGISTRY_HOOK;
-
/* structure to store the registry handles */
typedef struct _RegistryKey {
@@ -225,16 +199,16 @@ typedef struct {
UNISTR4 name;
uint32 *type;
REGVAL_BUFFER *value; /* value, in byte buffer */
- uint32 *len_value1;
- uint32 *len_value2;
+ uint32 *buffer_len;
+ uint32 *name_len;
} REG_Q_ENUM_VALUE;
typedef struct {
UNISTR4 name;
uint32 *type;
REGVAL_BUFFER *value;
- uint32 *len_value1;
- uint32 *len_value2;
+ uint32 *buffer_len1;
+ uint32 *buffer_len2;
WERROR status;
} REG_R_ENUM_VALUE;
@@ -377,33 +351,21 @@ typedef struct {
typedef struct {
POLICY_HND pol;
uint32 key_index;
- uint16 key_name_len; /* 0x0000 */
+ uint16 key_name_len;
uint16 unknown_1; /* 0x0414 */
- uint32 ptr1; /* pointer */
+ uint32 ptr1;
uint32 unknown_2; /* 0x0000 020A */
- uint8 pad1[8]; /* padding - zeros */
- uint32 ptr2; /* pointer */
- uint8 pad2[8]; /* padding - zeros */
- uint32 ptr3; /* pointer */
- NTTIME time; /* current time? */
+ uint8 pad1[8];
+ uint32 ptr2;
+ uint8 pad2[8];
+ uint32 ptr3;
+ NTTIME time;
} REG_Q_ENUM_KEY;
typedef struct {
- uint16 key_name_len; /* number of bytes in key name */
- uint16 unknown_1; /* 0x0414 - matches with query unknown_1 */
-
- uint32 ptr1; /* pointer */
- uint32 unknown_2; /* 0x0000 020A */
- uint32 unknown_3; /* 0x0000 0000 */
-
- UNISTR3 key_name;
-
- uint32 ptr2; /* pointer */
- uint8 pad2[8]; /* padding - zeros */
-
- uint32 ptr3; /* pointer */
- NTTIME time; /* current time? */
-
+ UNISTR4 keyname;
+ UNISTR4 *classname;
+ NTTIME *time;
WERROR status; /* return status */
} REG_R_ENUM_KEY;
diff --git a/source3/include/rpc_secdes.h b/source3/include/rpc_secdes.h
index ea987f9e4e..9eb4c9a41e 100644
--- a/source3/include/rpc_secdes.h
+++ b/source3/include/rpc_secdes.h
@@ -22,16 +22,6 @@
#ifndef _RPC_SECDES_H /* _RPC_SECDES_H */
#define _RPC_SECDES_H
-#define SEC_RIGHTS_QUERY_VALUE 0x00000001
-#define SEC_RIGHTS_SET_VALUE 0x00000002
-#define SEC_RIGHTS_CREATE_SUBKEY 0x00000004
-#define SEC_RIGHTS_ENUM_SUBKEYS 0x00000008
-#define SEC_RIGHTS_NOTIFY 0x00000010
-#define SEC_RIGHTS_CREATE_LINK 0x00000020
-#define SEC_RIGHTS_READ 0x00020019
-#define SEC_RIGHTS_FULL_CONTROL 0x000f003f
-#define SEC_RIGHTS_MAXIMUM_ALLOWED 0x02000000
-
/* for ADS */
#define SEC_RIGHTS_LIST_CONTENTS 0x4
#define SEC_RIGHTS_LIST_OBJECT 0x80
@@ -518,5 +508,39 @@ typedef struct standard_mapping {
SC_RIGHT_SVC_INTERROGATE | \
SC_RIGHT_SVC_USER_DEFINED_CONTROL )
+/*
+ * Access Bits for registry ACLS
+ */
+
+/* used by registry ACLs */
+
+#define SEC_RIGHTS_QUERY_VALUE 0x00000001
+#define SEC_RIGHTS_SET_VALUE 0x00000002
+#define SEC_RIGHTS_CREATE_SUBKEY 0x00000004
+#define SEC_RIGHTS_ENUM_SUBKEYS 0x00000008
+#define SEC_RIGHTS_NOTIFY 0x00000010
+#define SEC_RIGHTS_CREATE_LINK 0x00000020
+#define SEC_RIGHTS_MAXIMUM_ALLOWED 0x02000000
+
+
+#define REG_KEY_READ \
+ ( STANDARD_RIGHTS_READ_ACCESS |\
+ SEC_RIGHTS_QUERY_VALUE |\
+ SEC_RIGHTS_ENUM_SUBKEYS |\
+ SEC_RIGHTS_NOTIFY )
+
+#define REG_KEY_EXECUTE REG_KEY_READ
+
+#define REG_KEY_WRITE \
+ ( STANDARD_RIGHTS_READ_ACCESS |\
+ SEC_RIGHTS_SET_VALUE |\
+ SEC_RIGHTS_CREATE_SUBKEY )
+
+#define REG_KEY_ALL \
+ ( STANDARD_RIGHTS_REQUIRED_ACCESS |\
+ REG_KEY_READ |\
+ REG_KEY_WRITE |\
+ SEC_RIGHTS_CREATE_LINK )
+
#endif /* _RPC_SECDES_H */