[SCM] SAMBA-CTDB repository - branch v3-4-ctdb updated - 3.4.7-ctdb-9-47-g6b5b882

Michael Adam obnox at samba.org
Thu Sep 30 04:35:07 MDT 2010


The branch, v3-4-ctdb has been updated
       via  6b5b882073fa80c3ea7cbe52546cdc7a23a3444e (commit)
       via  bf0a27edecdfb366217b2e87cb842e598b3ec413 (commit)
       via  ed96d1e748adbbd451093317d2ca5f359b1bcba4 (commit)
       via  db7977b627d91c31f9424e9fde0cb5fcd6054100 (commit)
       via  9c9d57c8e35b66466bd9d39f7695c7821336abcb (commit)
       via  c3bbd35b24b15f067c6e3702e66096d0063b0d92 (commit)
       via  d47ffe981377f03d13c8dc4d9c3f78a445015ece (commit)
       via  33107723f067fdc6cdd9d028d5bf544357f85d6a (commit)
       via  03e54f88c9adc7b206e97aacca4297a2590b7790 (commit)
       via  345589d92fd6d6b980f8fa513c1e0ecb3d693644 (commit)
       via  8d71ca6371583b725bb7d97166592df94d7d6eea (commit)
       via  e5a0fcc0d19e2e7e30d4749abd43dd49b6348d39 (commit)
       via  e9d313880a6596fbf7fea5bda4e147aeaba02eb8 (commit)
       via  e596e2fb6ff7be833110b2095cefe597993b5308 (commit)
      from  2ec067f43fd8844adef8590e605c341449e7be00 (commit)

http://gitweb.samba.org/?p=obnox/samba-ctdb.git;a=shortlog;h=v3-4-ctdb


- Log -----------------------------------------------------------------
commit 6b5b882073fa80c3ea7cbe52546cdc7a23a3444e
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 29 12:17:05 2010 +0200

    s3: Add "smbcontrol winbindd ip-dropped <local-ip>"
    
    This is supposed to improve the winbind reconnect time after an ip address
    has been moved away from a box. Any kind of HA scenario will benefit from
    this, because winbindd does not have to wait for the TCP timeout to kick in
    when a local IP address has been dropped and DC replies are not received
    anymore.

commit bf0a27edecdfb366217b2e87cb842e598b3ec413
Author: Volker Lendecke <vl at samba.org>
Date:   Wed Sep 22 05:23:43 2010 -0700

    s3: Fix a deadlock between notify_onelevel.tdb and notify.tdb
    
    notify_add() locks notify_onlevel.tdb while having notify.tdb locked.
    file_free() calls notify_remove_onelevel(), and due to this talloc hierarchy
    problem the tdb record is not unlocked again timely. Thus notify.tdb will be
    locked while notify_onelevel still has a lock.
    
    Sorry, Ronnie, for causing you some grey hair and thanks for the stacktraces.
    
    Volker

commit ed96d1e748adbbd451093317d2ca5f359b1bcba4
Author: Michael Adam <obnox at samba.org>
Date:   Mon Sep 27 12:43:39 2010 +0200

    libsmbconf: parse an empty share as empty share, not as NULL.
    
    This fixes a segfault in net conf import:
    Importing a text file with an empty share resulted in a segfault.
    Now this creates an empty share in registry config, just as it
    should.
    
    Thanks to Gregor Beck <gbeck at sernet.de> for reporting.
    (cherry picked from commit 84127dd50420a7d0e8f389d4af15d52fca6cd809)

commit db7977b627d91c31f9424e9fde0cb5fcd6054100
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 15:13:55 2010 +0200

    s3-net: add roundtrip tests for registry import/export

commit 9c9d57c8e35b66466bd9d39f7695c7821336abcb
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 15:13:26 2010 +0200

    s3-net: test: make MALLOC_CHECK verbose on failure

commit c3bbd35b24b15f067c6e3702e66096d0063b0d92
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 15:12:49 2010 +0200

    s3-net: add command rpc registry export

commit d47ffe981377f03d13c8dc4d9c3f78a445015ece
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 15:11:49 2010 +0200

    s3-net: add command rpc registry import

commit 33107723f067fdc6cdd9d028d5bf544357f85d6a
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 15:06:05 2010 +0200

    s3-net: add command registry convert

commit 03e54f88c9adc7b206e97aacca4297a2590b7790
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 15:05:21 2010 +0200

    s3-net: add command registry export

commit 345589d92fd6d6b980f8fa513c1e0ecb3d693644
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 15:03:11 2010 +0200

    s3-net: add command registry import

commit 8d71ca6371583b725bb7d97166592df94d7d6eea
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 14:54:15 2010 +0200

    s3-registry: add support for registration entries (.reg) files

commit e5a0fcc0d19e2e7e30d4749abd43dd49b6348d39
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 14:50:33 2010 +0200

    s3-lib: add srprs, primitives to build simple recursive parsers

commit e9d313880a6596fbf7fea5bda4e147aeaba02eb8
Author: Gregor Beck <gbeck at sernet.de>
Date:   Wed Sep 29 14:49:40 2010 +0200

    s3-lib: add cbuf, a talloced character buffer

commit e596e2fb6ff7be833110b2095cefe597993b5308
Author: Günther Deschner <gd at samba.org>
Date:   Fri Sep 25 11:35:46 2009 +0200

    s3-util: use pull_reg_multi_sz in reg_pull_multi_sz.
    
    Guenther

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

Summary of changes:
 lib/smbconf/smbconf_txt.c                 |    6 +-
 source3/Makefile.in                       |    5 +-
 source3/lib/cbuf.c                        |  287 +++++++++
 source3/lib/cbuf.h                        |  235 +++++++
 source3/lib/srprs.c                       |  185 ++++++
 source3/lib/srprs.h                       |  181 ++++++
 source3/lib/util_reg.c                    |   36 +-
 source3/librpc/gen_ndr/messaging.h        |    2 +
 source3/librpc/gen_ndr/ndr_messaging.c    |    1 +
 source3/librpc/idl/messaging.idl          |    1 +
 source3/registry/reg_format.c             |  828 +++++++++++++++++++++++++
 source3/registry/reg_format.h             |  219 +++++++
 source3/registry/reg_import.c             |  296 +++++++++
 source3/registry/reg_import.h             |  199 ++++++
 source3/registry/reg_parse.c              |  958 +++++++++++++++++++++++++++++
 source3/registry/reg_parse.h              |  190 ++++++
 source3/registry/reg_parse_internal.c     |  347 +++++++++++
 source3/registry/reg_parse_internal.h     |  102 +++
 source3/script/tests/test_functions.sh    |    2 +-
 source3/script/tests/test_net_registry.sh |   88 +++
 source3/smbd/notify_internal.c            |    2 +-
 source3/utils/net_registry.c              |  377 +++++++++++-
 source3/utils/net_rpc_registry.c          |  560 +++++++++++++++++-
 source3/utils/smbcontrol.c                |   17 +
 source3/winbindd/winbindd.c               |    4 +
 source3/winbindd/winbindd_cm.c            |   53 ++
 source3/winbindd/winbindd_dual.c          |    4 +
 source3/winbindd/winbindd_proto.h         |   10 +
 28 files changed, 5159 insertions(+), 36 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_internal.c
 create mode 100644 source3/registry/reg_parse_internal.h


Changeset truncated at 500 lines:

diff --git a/lib/smbconf/smbconf_txt.c b/lib/smbconf/smbconf_txt.c
index 501382c..fc6fcca 100644
--- a/lib/smbconf/smbconf_txt.c
+++ b/lib/smbconf/smbconf_txt.c
@@ -452,11 +452,7 @@ static WERROR smbconf_txt_get_share(struct smbconf_ctx *ctx,
 	}
 
 	tmp_service->num_params = count;
-	if (count > 0) {
-		*service = talloc_move(mem_ctx, &tmp_service);
-	} else {
-		*service = NULL;
-	}
+	*service = talloc_move(mem_ctx, &tmp_service);
 
 done:
 	talloc_free(tmp_ctx);
diff --git a/source3/Makefile.in b/source3/Makefile.in
index 4430f0e..521636c 100644
--- a/source3/Makefile.in
+++ b/source3/Makefile.in
@@ -941,7 +941,10 @@ NET_OBJ1 = utils/net.o utils/net_ads.o utils/net_help.o \
 	   auth/token_util.o utils/net_dom.o utils/net_share.o \
 	   utils/net_g_lock.o \
 	   utils/net_serverid.o \
-	   utils/net_eventlog.o
+	   utils/net_eventlog.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..3cd164a
--- /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_steal(b2, b1->buf);
+	talloc_steal(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_steal(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
+ * along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ */
+
+/**
+ * @file   cbuf.h
+ * @author Gregor Beck <gb at sernet.de>
+ * @date   Aug 2010
+ *
+ * @brief  A talloced character buffer.
+ *
+ * A cbuf carries a write position and keeps track of its size.
+ */
+
+#ifndef __CBUF_H
+#define __CBUF_H
+
+#include <stddef.h>
+#include <stdbool.h>
+#include <stdint.h>
+
+
+struct cbuf;
+typedef struct cbuf cbuf;
+
+/**
+ * Create a new character buffer.
+ *
+ * @param talloc_ctx the talloc parent
+ *
+ * @return a new cbuf object, NULL on error
+ */
+cbuf* cbuf_new(const void* talloc_ctx);
+
+/**
+ * Create a copy of a character buffer.
+ *
+ * @param b the cbuf to copy
+ * @return a new cbuf object, NULL on error
+ */
+cbuf* cbuf_copy(const cbuf* b);
+
+/**
+ * Delete a character buffer.
+ * This invalidates b and free's the memory allocated.
+ * @warning don't talloc_free b directly, however freeing
+ *          the parent works as expected
+ * @param b the cbuf to delete
+ */
+void  cbuf_delete(cbuf* b);
+
+/**
+ * Reset the buffer to initial state.
+ * Set the write positon to the start of buffer, effectivly
+ * clearing its contents. Doesn't free memory.
+ *
+ * @param b the buffer to clear
+ *
+ * @return b
+ */
+cbuf* cbuf_clear(cbuf* b);
+
+/**
+ * Swap the contents of two buffers in O(1).
+ *
+ * @param b1 a character buffer
+ * @param b2 another character buffer
+ */
+void cbuf_swap(cbuf* b1, cbuf* b2);
+
+/**
+ * Swap the contents of a buffer with a talloced string.
+ *
+ * @param b a character buffer
+ * @param ptr a pointer to a talloced string
+ * @param len size of string, -1 means strlen(*ptr)
+ *
+ * @return b
+ */
+cbuf* cbuf_swapptr(cbuf* b, char** ptr, size_t len);
+
+/**
+ * Let a character buffer takeover the contents of another.
+ * This is equivalent to @code
+ *   cbuf_swap(b1, b2);
+ *   cbuf_delete(b2);
+ * @endcode
+ * @param b1 the destination
+ * @param b2 the victim
+ *
+ * @return b1
+ */
+cbuf* cbuf_takeover(cbuf* b1, cbuf* b2);
+
+/**
+ * Resize a character buffer.
+ * This may free allocated memory.
+ *
+ * @param b the character buffer.
+ * @param size the new size
+ *
+ * @return b, NULL on error
+ */
+cbuf* cbuf_resize(cbuf* b, size_t size);
+
+/**
+ * Reserve space in a character buffer.
+ * Assert there are at least len bytes following the current write position.
+ *
+ * @param b a character buffer
+ * @param len number of bytes to reserve.
+ *
+ * @return a pointer to the current write position, NULL on error
+ */
+char* cbuf_reserve(cbuf* b, size_t len);
+
+/**
+ * Put a character into the buffer.
+ *
+ * @param b a charcter buffer, may be NULL.
+ * @param c a character
+ * @return number of charcters written ((b==NULL) ? 0 : 1)
+ *
+ * @retval -1 on error
+ */
+int cbuf_putc(cbuf* b, char c);
+
+/**
+ * Put a string into the buffer.
+ *
+ * @param b a character buffer, may be NULL
+ * @param str a string
+ * @param len number of bytes to write, -1 means strlen(str)
+ *
+ * @return number of characters written, -1 on error
+ */
+int cbuf_puts(cbuf* b, const char* str, size_t len);
+
+/* /\** */
+/*  * Put a string into the buffer, changing case. */
+/*  * */
+/*  * @param b a character buffer, may be NULL */
+/*  * @param str a string */
+/*  * @param len number of bytes to write, -1 means strlen(str) */
+/*  * @param c   a character specifying case: */
+/*  *        @li 'U' upper case */
+/*  *        @li 'L' lower case */
+/*  *        @li 'T' title case */
+/*  *        @li 'P' preserve case */
+/*  * @return number of characters written, -1 on error */
+/*  *\/ */
+/* int cbuf_puts_case(cbuf* b, const char* str, size_t len, char c); */
+
+


-- 
SAMBA-CTDB repository


More information about the samba-cvs mailing list