[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Tue Sep 21 22:32:59 MDT 2010


The branch, master has been updated
       via  cb5c86e s3:net: add subcommand net registry deletekey_recursive
       via  7a25d13 s3:registry: remove unneeded TALLOC_CTX argument from reg_deletekey_recursive
       via  a2ea85b s3:tests: fix misplaced '...' for grep pattern in test_net_registry.sh
       via  a52b7e7 s3-net: add command rpc registry import
       via  96ba0cb s3-net: add command rpc registry export
       via  0afc83c s3-net: add command registry convert
       via  e7c2724 s3-net: add command registry export
       via  2a10fd7 s3-net: add command registry import
       via  44d10d0 s3-net: let rpccli_winreg_Connect optionally return WERROR
       via  47313af s3-registry: handle registration entries (.reg) files
       via  f760494 s3-lib: add srprs, primitives to build simple recursive parsers
       via  e5bbc2b s3-lib: add cbuf, a talloced character buffer
       via  9c2e89d s3-docs: document net registry
      from  a233c0c s3-lsa: Fix sid in DEBUG in_lsa_EnumAccountRights.

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=master


- Log -----------------------------------------------------------------
commit cb5c86e5027fd7bca73e855bcf433846a7c680f3
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 22 06:27:49 2010 +0200

    s3:net: add subcommand net registry deletekey_recursive
    
    to delete a key including subkeys

commit 7a25d13742fe190e2b8b97f62d7db85db4e816e9
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 22 06:21:38 2010 +0200

    s3:registry: remove unneeded TALLOC_CTX argument from reg_deletekey_recursive

commit a2ea85b68d86ed3651f00626b837cfa8184cc21b
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 22 06:00:00 2010 +0200

    s3:tests: fix misplaced '...' for grep pattern in test_net_registry.sh

commit a52b7e7229174500c8b8d5e52206e68749b99e2b
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 15:32:02 2010 +0200

    s3-net: add command rpc registry import
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 96ba0cb8f2a02a5f991ef92ed9eeb81d1a42216b
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 16:45:57 2010 +0200

    s3-net: add command rpc registry export
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 0afc83c25556fc8162415738d1e8743009c4837c
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 15:01:40 2010 +0200

    s3-net: add command registry convert
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit e7c2724c8148d837d60b5e6cb6204ac5ea28164c
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 15:01:01 2010 +0200

    s3-net: add command registry export
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 2a10fd769b3e2695433f579cd28c1a6f3bbce26e
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 14:54:30 2010 +0200

    s3-net: add command registry import
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 44d10d05464b16082d318b0e7001432484013a29
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 15:24:03 2010 +0200

    s3-net: let rpccli_winreg_Connect optionally return WERROR
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 47313afe97973e1293af2f1ab0d08ecaedb74e1e
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 14:46:25 2010 +0200

    s3-registry: handle registration entries (.reg) files
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit f76049422899dc19abe597d990e6ca9ec391c962
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 14:37:07 2010 +0200

    s3-lib: add srprs, primitives to build simple recursive parsers
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit e5bbc2be05f1d35bebbaea3b120d699467a30304
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 14:33:21 2010 +0200

    s3-lib: add cbuf, a talloced character buffer
    
    Signed-off-by: Michael Adam <obnox at samba.org>

commit 9c2e89da1011fdeb82bcf53a69781c07d18df728
Author: Gregor Beck <gbeck at sernet.de>
Date:   Mon Sep 20 14:24:00 2010 +0200

    s3-docs: document net registry
    
    Signed-off-by: Michael Adam <obnox at samba.org>

-----------------------------------------------------------------------

Summary of changes:
 docs-xml/manpages-3/net.8.xml             |  158 +++
 source3/Makefile.in                       |    6 +-
 source3/lib/cbuf.c                        |  287 ++++++
 source3/lib/cbuf.h                        |  235 +++++
 source3/lib/smbconf/smbconf_reg.c         |    5 +-
 source3/lib/srprs.c                       |  185 ++++
 source3/lib/srprs.h                       |  181 ++++
 source3/libgpo/gpext/scripts.c            |    2 +-
 source3/libgpo/gpo_reg.c                  |    4 +-
 source3/registry/reg_api.c                |   30 +-
 source3/registry/reg_api.h                |    6 +-
 source3/registry/reg_format.c             |  808 +++++++++++++++
 source3/registry/reg_format.h             |  219 ++++
 source3/registry/reg_import.c             |  290 ++++++
 source3/registry/reg_import.h             |  199 ++++
 source3/registry/reg_parse.c              |  958 ++++++++++++++++++
 source3/registry/reg_parse.h              |  190 ++++
 source3/registry/reg_parse_dox.cfg        | 1562 +++++++++++++++++++++++++++++
 source3/registry/reg_parse_internal.c     |  346 +++++++
 source3/registry/reg_parse_internal.h     |  102 ++
 source3/script/tests/test_net_registry.sh |    2 +-
 source3/utils/net_registry.c              |  408 ++++++++-
 source3/utils/net_rpc_registry.c          |  584 +++++++++++-
 23 files changed, 6719 insertions(+), 48 deletions(-)
 create mode 100644 source3/lib/cbuf.c
 create mode 100644 source3/lib/cbuf.h
 create mode 100644 source3/lib/srprs.c
 create mode 100644 source3/lib/srprs.h
 create mode 100644 source3/registry/reg_format.c
 create mode 100644 source3/registry/reg_format.h
 create mode 100644 source3/registry/reg_import.c
 create mode 100644 source3/registry/reg_import.h
 create mode 100644 source3/registry/reg_parse.c
 create mode 100644 source3/registry/reg_parse.h
 create mode 100644 source3/registry/reg_parse_dox.cfg
 create mode 100644 source3/registry/reg_parse_internal.c
 create mode 100644 source3/registry/reg_parse_internal.h


Changeset truncated at 500 lines:

diff --git a/docs-xml/manpages-3/net.8.xml b/docs-xml/manpages-3/net.8.xml
index c5fbc7d..d648d5c 100644
--- a/docs-xml/manpages-3/net.8.xml
+++ b/docs-xml/manpages-3/net.8.xml
@@ -1617,6 +1617,164 @@ Delete the list of includes from the provided section (global or share).
 </refsect2>
 
 <refsect2>
+<title>REGISTRY</title>
+<para>
+Manipulate Samba's registry.
+</para>
+
+<para>The registry commands are:
+<simplelist>
+<member>net registry enumerate   - Enumerate registry keys and values.</member>
+<member>net registry createkey   - Create a new registry key.</member>
+<member>net registry deletekey   - Delete a registry key.</member>
+<member>net registry getvalue    - Print a registry value.</member>
+<member>net registry getvalueraw - Print a registry value (raw format).</member>
+<member>net registry setvalue    - Set a new registry value.</member>
+<member>net registry increment   - Increment a DWORD registry value under a lock.
+</member>
+<member>net registry deletevalue - Delete a registry value.</member>
+<member>net registry getsd       - Get security descriptor.</member>
+<member>net registry getsd_sdd1  - Get security descriptor in sddl format.
+</member>
+<member>net registry setsd_sdd1  - Set security descriptor from sddl format
+string.</member>
+<member>net registry import      - Import a registration entries (.reg) file.
+</member>
+<member>net registry export      - Export a registration entries (.reg) file.
+</member>
+<member>net registry convert     - Convert a registration entries (.reg) file.
+</member>
+</simplelist>
+</para>
+
+<refsect3>
+  <title>REGISTRY ENUMERATE <replaceable>key</replaceable> </title>
+  <para>Enumerate subkeys and values of <emphasis>key</emphasis>
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY CREATEKEY <replaceable>key</replaceable> </title>
+  <para>Create a new <emphasis>key</emphasis> if not yet existing.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY DELETEKEY <replaceable>key</replaceable> </title>
+  <para>Delete the given <emphasis>key</emphasis> and all of its
+  subkeys and values from the registry.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY GETVALUE <replaceable>key</replaceable> <!--
+  --><replaceable>name</replaceable></title>
+
+  <para>Output type and actual value of the value <emphasis>name</emphasis>
+  of the given <emphasis>key</emphasis>.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY GETVALUERAW <replaceable>key</replaceable> <!--
+  --><replaceable>name</replaceable></title>
+  <para>Output the actual value of the value <emphasis>name</emphasis>
+  of the given <emphasis>key</emphasis>.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY SETVALUE <replaceable>key</replaceable> <!--
+  --><replaceable>name</replaceable> <replaceable>type</replaceable> <!--
+  --><replaceable>value</replaceable> ...<!--
+  --></title>
+
+  <para>Set the value <emphasis>name</emphasis>
+  of an existing <emphasis>key</emphasis>.
+  <emphasis>type</emphasis> may be one of
+  <emphasis>sz</emphasis>, <emphasis>multi_sz</emphasis> or
+  <emphasis>dword</emphasis>.
+  In case of <emphasis>multi_sz</emphasis> <replaceable>value</replaceable> may
+  be given multiple times.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY INCREMENT <replaceable>key</replaceable> <!--
+  --><replaceable>name</replaceable> <replaceable>[inc]</replaceable><!--
+  --></title>
+
+  <para>Increment the DWORD value <emphasis>name</emphasis>
+  of <emphasis>key</emphasis> by <replaceable>inc</replaceable>
+  while holding a g_lock.
+  <emphasis>inc</emphasis> defaults to 1.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY DELETEVALUE <replaceable>key</replaceable> <!--
+  --><replaceable>name</replaceable></title>
+
+  <para>Delete the value <emphasis>name</emphasis>
+  of the given <emphasis>key</emphasis>.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY GETSD <replaceable>key</replaceable></title>
+
+  <para>Get the security descriptor of the given <emphasis>key</emphasis>.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY GETSD_SDDL <replaceable>key</replaceable></title>
+
+  <para>Get the security descriptor of the given <emphasis>key</emphasis> as a
+  Security Descriptor Definition Language (SDDL) string.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY SETSD_SDDL <replaceable>key</replaceable><!--
+  --><replaceable>sd</replaceable></title>
+
+  <para>Set the security descriptor of the given <emphasis>key</emphasis> from a
+  Security Descriptor Definition Language (SDDL) string <emphasis>sd</emphasis>.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY IMPORT <replaceable>file</replaceable><!--
+  --><replaceable>[opt]</replaceable></title>
+
+  <para>Import a registration entries (.reg) <emphasis>file</emphasis>.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY EXPORT <replaceable>key</replaceable><!--
+  --><replaceable>file</replaceable><!--
+  --><replaceable>[opt]</replaceable></title>
+
+  <para>Export a <emphasis>key</emphasis> to a registration entries (.reg)
+  <emphasis>file</emphasis>.
+  </para>
+</refsect3>
+
+<refsect3>
+  <title>REGISTRY CONVERT <replaceable>in</replaceable> <!--
+  --><replaceable>out</replaceable> <!--
+  --><replaceable>[[inopt] outopt]</replaceable></title>
+
+  <para>Convert a registration entries (.reg) file <emphasis>in</emphasis>.
+  </para>
+</refsect3>
+
+
+</refsect2>
+
+<refsect2>
 <title>EVENTLOG</title>
 
 <para>Starting with version 3.4.0 net can read, dump, import and export native
diff --git a/source3/Makefile.in b/source3/Makefile.in
index c72a6c3..256d799 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -1150,8 +1150,10 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
 	   $(LIBCLI_NETLOGON_OBJ) \
 	   $(RPC_CLIENT_SCHANNEL_OBJ) \
 	   rpc_client/init_netlogon.o \
-	   rpc_client/init_samr.o
-
+	   rpc_client/init_samr.o \
+	   registry/reg_parse.o registry/reg_format.o \
+	   registry/reg_parse_internal.o registry/reg_import.o \
+	   lib/cbuf.o lib/srprs.o
 
 # these are not processed by make proto
 NET_OBJ2 = utils/net_registry_util.o utils/net_help_common.o
diff --git a/source3/lib/cbuf.c b/source3/lib/cbuf.c
new file mode 100644
index 0000000..85d1c14
--- /dev/null
+++ b/source3/lib/cbuf.c
@@ -0,0 +1,287 @@
+/*
+ * Samba Unix/Linux SMB client library
+ *
+ * Copyright (C) Gregor Beck 2010
+ *
+ * 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 3 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, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file   cbuf.c
+ * @author Gregor Beck <gb at sernet.de>
+ * @date   Aug 2010
+ *
+ * @brief  A talloced character buffer.
+ *
+ */
+
+
+#include <assert.h>
+#include "includes.h"
+#include "cbuf.h"
+
+
+struct cbuf {
+	char*  buf;
+	size_t pos;
+	size_t size;
+};
+
+
+cbuf* cbuf_clear(cbuf* b)
+{
+	cbuf_setpos(b, 0);
+	return b;
+}
+
+cbuf* cbuf_new(const void* ctx)
+{
+	cbuf* s = talloc(ctx, cbuf);
+	if (s == NULL)
+		return NULL;
+	s->size = 32;
+	s->buf  = talloc_size(s, s->size);
+	if (s->size && (s->buf == NULL)) {
+		talloc_free(s);
+		return NULL;
+	}
+	return cbuf_clear(s);
+}
+
+cbuf* cbuf_copy(const cbuf* b)
+{
+	cbuf* s = talloc(talloc_parent(b), cbuf);
+	if (s == NULL) {
+		return NULL;
+	}
+
+	s->buf = talloc_memdup(s, b->buf, b->size); /* only up to pos? */
+
+	/* XXX shallow did not work, because realloc */
+	/* fails with multiple references */
+	/* s->buf = talloc_reference(s, b->buf); */
+
+	if (s->buf == NULL) {
+		cbuf_delete(s);
+		return NULL;
+	}
+	s->size = b->size;
+	s->pos  = b->pos;
+	return s;
+}
+
+void cbuf_delete(cbuf* b)
+{
+	talloc_free(b);
+}
+
+#define SWAP(A,B,T) do {			\
+		T tmp = A; A = B; B = tmp;	\
+	} while(0)
+
+
+void cbuf_swap(cbuf* b1, cbuf* b2)
+{
+	if (b1 == b2) {
+		return;
+	}
+	talloc_reparent(b1, b2, b1->buf);
+	talloc_reparent(b2, b1, b2->buf);
+	SWAP(b1->buf,  b2->buf, char*);
+	SWAP(b1->pos,  b2->pos, size_t);
+	SWAP(b1->size, b2->size, size_t);
+}
+
+
+
+cbuf* cbuf_takeover(cbuf* b1, cbuf* b2)
+{
+	talloc_reparent(b2, b1, b2->buf);
+	b1->buf = b2->buf;
+	b1->pos = b2->pos;
+	b1->size = b2->size;
+	cbuf_delete(b2);
+	return b1;
+}
+
+cbuf* cbuf_swapptr(cbuf* b, char** ptr, size_t len)
+{
+	SWAP(b->buf, *ptr, char*);
+	talloc_steal(b, b->buf);
+	b->size = talloc_get_size(b->buf);
+	b->pos  = (len == -1) ? strlen(b->buf) : len;
+
+	assert(b->pos <= b->size);
+	return b;
+}
+
+cbuf* cbuf_resize(cbuf* b, size_t size)
+{
+	char* save_buf = b->buf;
+	b->buf = talloc_realloc(b, b->buf, char, size);
+	if (b->buf == NULL) {
+		talloc_free(save_buf);
+		b->size = 0;
+	} else {
+		b->size = size;
+	}
+	b->pos  = MIN(b->pos, b->size);
+	return b->buf ? b : NULL;
+}
+
+char* cbuf_reserve(cbuf* b, size_t len)
+{
+	if(b->size < b->pos + len)
+		cbuf_resize(b, MAX(2*b->size, b->pos + len));
+	return b->buf ? b->buf + b->pos : NULL;
+}
+
+int cbuf_puts(cbuf* b, const char* str, size_t len)
+{
+	char* dst;
+
+	if (b == NULL)
+		return 0;
+
+	if (len == -1) {
+		len=strlen(str);
+	}
+
+	dst = cbuf_reserve(b, len+1);
+	if (dst == NULL)
+		return -1;
+
+	memcpy(dst, str, len);
+	dst[len] = '\0'; /* just to ease debugging */
+
+	b->pos += len;
+	assert(b->pos < b->size);
+
+	return len;
+}
+
+int cbuf_putc(cbuf* b, char c) {
+	char* dst;
+
+	if (b == NULL)
+		return 0;
+
+	dst = cbuf_reserve(b, 2);
+	if (dst == NULL) {
+		return -1;
+	}
+
+	dst[0] = c;
+	dst[1] = '\0'; /* just to ease debugging */
+
+	b->pos++;
+	assert(b->pos < b->size);
+
+	return 1;
+}
+
+int cbuf_putdw(cbuf* b, uint32_t u) {
+	char* dst;
+	static const size_t LEN = sizeof(uint32_t);
+
+	if (b == NULL)
+		return 0;
+
+	dst = cbuf_reserve(b, LEN);
+	if (dst == NULL) {
+		return -1;
+	}
+
+	SIVAL(dst, 0, u);
+
+	b->pos += LEN;
+	assert(b->pos <= b->size); /* no NULL termination*/
+
+	return LEN;
+}
+
+size_t cbuf_getpos(const cbuf* b) {
+	assert(b->pos <= b->size);
+	return b->pos;
+}
+
+void cbuf_setpos(cbuf* b, size_t pos) {
+	assert(pos <= b->size);
+	b->pos = pos;
+	if (pos < b->size)
+		b->buf[pos] = '\0'; /* just to ease debugging */
+}
+
+char* cbuf_gets(cbuf* b, size_t idx) {
+	assert(idx <= b->pos);
+
+	if (cbuf_reserve(b, 1) == NULL)
+		return NULL;
+
+	b->buf[b->pos] = '\0';
+	return b->buf + idx;
+}
+
+int cbuf_printf(cbuf* b, const char* fmt, ...)
+{
+	va_list args, args2;
+	int len;
+	char* dst = b->buf + b->pos;
+	const int avail = b->size - b->pos;
+	assert(avail >= 0);
+
+	va_start(args, fmt);
+	va_copy(args2, args);
+
+	len = vsnprintf(dst, avail, fmt, args);
+
+	if (len >= avail) {
+		dst = cbuf_reserve(b, len+1);
+		len = (dst != NULL) ? vsnprintf(dst, len+1, fmt, args2) : -1;
+	}
+
+	if (len > 0) {
+		b->pos += len;
+	}
+
+	va_end(args);
+	va_end(args2);
+	assert(b->pos <= b->size);
+
+	return len;
+}
+
+int cbuf_print_quoted_string(cbuf* ost, const char* s)
+{
+	int n = 1;
+	cbuf_putc(ost,'"');
+
+	while(true) {
+		switch (*s) {
+		case '\0':
+			cbuf_putc(ost, '"');
+			return n+1;
+
+		case '"':
+		case '\\':
+			cbuf_putc(ost, '\\');
+		        n++;
+			/* no break */
+		default:
+			cbuf_putc(ost, *s);
+			n++;
+		}
+		s++;
+	}
+}
diff --git a/source3/lib/cbuf.h b/source3/lib/cbuf.h
new file mode 100644
index 0000000..ffb52d7
--- /dev/null
+++ b/source3/lib/cbuf.h
@@ -0,0 +1,235 @@
+/*
+ * Samba Unix/Linux SMB client library
+ * Copyright (C) Gregor Beck 2010
+ *
+ * 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 3 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


-- 
Samba Shared Repository


More information about the samba-cvs mailing list