[SCM] Samba Shared Repository - branch v3-2-test updated - release-3-2-0pre2-331-g7dc64d1

Michael Adam obnox at samba.org
Thu Mar 20 14:04:13 GMT 2008


The branch, v3-2-test has been updated
       via  7dc64d1021e0b8f3339f811c8c144f7013a649a8 (commit)
       via  5c3f14e02fa7baf11d9a6531f2de3e6b16d843b0 (commit)
       via  6bac03a2ec6351ab9db457d904b8925c828086e8 (commit)
       via  27d67365ad03f0a0cd86011758a122a97513b82e (commit)
       via  11da885f1e82e7a08fac2bc0ec1515694caa6340 (commit)
       via  504058df9706ee4e4c2e7fb1b1e41710bce2f87d (commit)
       via  59fdd30c789ccfd5cff356e459f1653b065b985c (commit)
       via  8b9cff84d5c39e6d7c315d87ac2fdf7fc0d4e4c4 (commit)
       via  55233f875ebe1d515c65d9322cda69eb52d4c7d5 (commit)
      from  0b54dd097fbd44b53a311f1e8f4716056a96c2d2 (commit)

http://gitweb.samba.org/?p=samba.git;a=shortlog;h=v3-2-test


- Log -----------------------------------------------------------------
commit 7dc64d1021e0b8f3339f811c8c144f7013a649a8
Author: Michael Adam <obnox at samba.org>
Date:   Wed Mar 19 15:18:06 2008 +0100

    loadparm: reenable checking files for updates while in registry configuration.
    
    This is necessary now that includes (to files) are enabled from registry.
    
    Michael

commit 5c3f14e02fa7baf11d9a6531f2de3e6b16d843b0
Author: Michael Adam <obnox at samba.org>
Date:   Wed Mar 19 11:00:29 2008 +0100

    loadparm: remove unneeded include.
    
    libnet.h unneeded after separation of libsmbconf from libnet.
    
    Michael

commit 6bac03a2ec6351ab9db457d904b8925c828086e8
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 20 14:35:41 2008 +0100

    registry: use available string constant in debug statement.
    
    Michael

commit 27d67365ad03f0a0cd86011758a122a97513b82e
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 20 14:33:43 2008 +0100

    registry: in regdb_init, not only complain about INFO/version, store it...
    
    Michael

commit 11da885f1e82e7a08fac2bc0ec1515694caa6340
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 20 14:26:42 2008 +0100

    registry: reformat regdb_init() slightly, breaking long lines.
    
    Michael

commit 504058df9706ee4e4c2e7fb1b1e41710bce2f87d
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 20 14:24:12 2008 +0100

    registry: untangle assignment and if-statement in regdb_init().
    
    Michael

commit 59fdd30c789ccfd5cff356e459f1653b065b985c
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 20 14:08:29 2008 +0100

    registry: separate initialization of registry data from regdb_init().
    
    Leave this to the users (currently registry_init_smbconf() and
    init_registry()) to initialize as much of preliminary registry data
    as needed.
    
    Michael

commit 8b9cff84d5c39e6d7c315d87ac2fdf7fc0d4e4c4
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 20 14:01:13 2008 +0100

    registry: add a transaction wrapper to init_registry_key_internal().
    
    Michael

commit 55233f875ebe1d515c65d9322cda69eb52d4c7d5
Author: Michael Adam <obnox at samba.org>
Date:   Thu Mar 20 13:59:09 2008 +0100

    registry: refactor creation of subkeys out of init_registry_data().
    
    Michael

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

Summary of changes:
 source/param/loadparm.c            |   10 --
 source/registry/reg_backend_db.c   |  236 ++++++++++++++++++++++--------------
 source/registry/reg_init_full.c    |    7 +
 source/registry/reg_init_smbconf.c |    5 +
 4 files changed, 154 insertions(+), 104 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index 9007904..04fade5 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -52,7 +52,6 @@
  */
 
 #include "includes.h"
-#include "libnet/libnet.h"
 
 bool bLoaded = False;
 
@@ -6622,15 +6621,6 @@ bool lp_file_list_changed(void)
 				     (unsigned long long)conf_last_seqnum,
 				     (unsigned long long)conf_cur_seqnum));
 			return true;
-		} else {
-			/*
-			 * Don't check files when config_backend is registry.
-			 * Remove this to obtain checking of files even with
-			 * registry config backend. That would enable switching
-			 * off registry configuration by changing smb.conf even
-			 * without restarting smbd.
-			 */
-			return false;
 		}
 	}
 
diff --git a/source/registry/reg_backend_db.c b/source/registry/reg_backend_db.c
index 07aaf68..e0be8f3 100644
--- a/source/registry/reg_backend_db.c
+++ b/source/registry/reg_backend_db.c
@@ -87,115 +87,159 @@ static struct builtin_regkey_value builtin_registry_values[] = {
 	{ NULL, NULL, 0, { NULL } }
 };
 
-/***********************************************************************
- Open the registry data in the tdb
- ***********************************************************************/
-
-static bool init_registry_data(void)
+/**
+ * Initialize a key in the registry:
+ * create each component key of the specified path.
+ */
+static bool init_registry_key_internal(const char *add_path)
 {
+	bool ret = false;
+	TALLOC_CTX *frame = talloc_stackframe();
 	char *path = NULL;
 	char *base = NULL;
 	char *remaining = NULL;
-	TALLOC_CTX *frame = NULL;
 	char *keyname;
 	char *subkeyname;
 	REGSUBKEY_CTR *subkeys;
-	REGVAL_CTR *values;
-	int i;
 	const char *p, *p2;
-	UNISTR2 data;
 
-	/*
-	 * There are potentially quite a few store operations which are all
-	 * indiviually wrapped in tdb transactions. Wrapping them in a single
-	 * transaction gives just a single transaction_commit() to actually do
-	 * its fsync()s. See tdb/common/transaction.c for info about nested
-	 * transaction behaviour.
-	 */
+	DEBUG(6, ("init_registry_key: Adding [%s]\n", add_path));
 
-	if (regdb->transaction_start(regdb) == -1) {
-		DEBUG(0, ("init_registry_data: tdb_transaction_start "
-			  "failed\n"));
-		return false;
+	path = talloc_strdup(frame, add_path);
+	base = talloc_strdup(frame, "");
+	if (!path || !base) {
+		goto fail;
 	}
+	p = path;
 
-	/* loop over all of the predefined paths and add each component */
-
-	for (i=0; builtin_registry_paths[i] != NULL; i++) {
-
-		frame = talloc_stackframe();
-
-		DEBUG(6, ("init_registry_data: Adding [%s]\n",
-			  builtin_registry_paths[i]));
-
-		path = talloc_strdup(frame, builtin_registry_paths[i]);
-		base = talloc_strdup(frame, "");
-		if (!path || !base) {
-			goto fail;
-		}
-		p = path;
+	while (next_token_talloc(frame, &p, &keyname, "\\")) {
 
-		while (next_token_talloc(frame, &p, &keyname, "\\")) {
+		/* build up the registry path from the components */
 
-			/* build up the registry path from the components */
-
-			if (*base) {
-				base = talloc_asprintf(frame, "%s\\", base);
-				if (!base) {
-					goto fail;
-				}
-			}
-			base = talloc_asprintf_append(base, "%s", keyname);
+		if (*base) {
+			base = talloc_asprintf(frame, "%s\\", base);
 			if (!base) {
 				goto fail;
 			}
+		}
+		base = talloc_asprintf_append(base, "%s", keyname);
+		if (!base) {
+			goto fail;
+		}
 
-			/* get the immediate subkeyname (if we have one ) */
+		/* get the immediate subkeyname (if we have one ) */
 
-			subkeyname = talloc_strdup(frame, "");
-			if (!subkeyname) {
+		subkeyname = talloc_strdup(frame, "");
+		if (!subkeyname) {
+			goto fail;
+		}
+		if (*p) {
+			remaining = talloc_strdup(frame, p);
+			if (!remaining) {
 				goto fail;
 			}
-			if (*p) {
-				remaining = talloc_strdup(frame, p);
-				if (!remaining) {
+			p2 = remaining;
+
+			if (!next_token_talloc(frame, &p2,
+						&subkeyname, "\\"))
+			{
+				subkeyname = talloc_strdup(frame,p2);
+				if (!subkeyname) {
 					goto fail;
 				}
-				p2 = remaining;
-
-				if (!next_token_talloc(frame, &p2,
-							&subkeyname, "\\"))
-				{
-					subkeyname = talloc_strdup(frame,p2);
-					if (!subkeyname) {
-						goto fail;
-					}
-				}
 			}
+		}
 
-			DEBUG(10,("init_registry_data: Storing key [%s] with "
-				  "subkey [%s]\n", base,
-				  *subkeyname ? subkeyname : "NULL"));
+		DEBUG(10,("init_registry_key: Storing key [%s] with "
+			  "subkey [%s]\n", base,
+			  *subkeyname ? subkeyname : "NULL"));
 
-			/* we don't really care if the lookup succeeds or not
-			 * since we are about to update the record.
-			 * We just want any subkeys already present */
+		/* we don't really care if the lookup succeeds or not
+		 * since we are about to update the record.
+		 * We just want any subkeys already present */
 
-			if (!(subkeys = TALLOC_ZERO_P(frame, REGSUBKEY_CTR))) {
-				DEBUG(0,("talloc() failure!\n"));
-				goto fail;
-			}
+		if (!(subkeys = TALLOC_ZERO_P(frame, REGSUBKEY_CTR))) {
+			DEBUG(0,("talloc() failure!\n"));
+			goto fail;
+		}
 
-			regdb_fetch_keys(base, subkeys);
-			if (*subkeyname) {
-				regsubkey_ctr_addkey( subkeys, subkeyname);
-			}
-			if (!regdb_store_keys( base, subkeys)) {
-				goto fail;
-			}
+		regdb_fetch_keys(base, subkeys);
+		if (*subkeyname) {
+			regsubkey_ctr_addkey( subkeys, subkeyname);
 		}
+		if (!regdb_store_keys( base, subkeys)) {
+			goto fail;
+		}
+	}
 
-		TALLOC_FREE(frame);
+	ret = true;
+fail:
+	TALLOC_FREE(frame);
+	return ret;
+}
+
+/**
+ * Initialize a key in the registry:
+ * create each component key of the specified path,
+ * wrapped in one db transaction.
+ */
+bool init_registry_key(const char *add_path)
+{
+	if (regdb->transaction_start(regdb) == -1) {
+		DEBUG(0, ("init_registry_key: transaction_start failed\n"));
+		return false;
+	}
+
+	if (!init_registry_key_internal(add_path)) {
+		goto fail;
+	}
+
+	if (regdb->transaction_commit(regdb) == -1) {
+		DEBUG(0, ("init_registry_key: Could not commit transaction\n"));
+		return false;
+	}
+
+	return true;
+
+fail:
+	if (regdb->transaction_cancel(regdb) == -1) {
+		smb_panic("init_registry_key: transaction_cancel failed\n");
+	}
+
+	return false;
+}
+
+/***********************************************************************
+ Open the registry data in the tdb
+ ***********************************************************************/
+
+bool init_registry_data(void)
+{
+	TALLOC_CTX *frame = NULL;
+	REGVAL_CTR *values;
+	int i;
+	UNISTR2 data;
+
+	/*
+	 * There are potentially quite a few store operations which are all
+	 * indiviually wrapped in tdb transactions. Wrapping them in a single
+	 * transaction gives just a single transaction_commit() to actually do
+	 * its fsync()s. See tdb/common/transaction.c for info about nested
+	 * transaction behaviour.
+	 */
+
+	if (regdb->transaction_start(regdb) == -1) {
+		DEBUG(0, ("init_registry_data: tdb_transaction_start "
+			  "failed\n"));
+		return false;
+	}
+
+	/* loop over all of the predefined paths and add each component */
+
+	for (i=0; builtin_registry_paths[i] != NULL; i++) {
+		if (!init_registry_key_internal(builtin_registry_paths[i])) {
+			goto fail;
+		}
 	}
 
 	/* loop over all of the predefined values and add each component */
@@ -274,21 +318,24 @@ static bool init_registry_data(void)
  Open the registry database
  ***********************************************************************/
  
-bool regdb_init( void )
+bool regdb_init(void)
 {
 	const char *vstring = "INFO/version";
 	uint32 vers_id;
 
-	if ( regdb ) {
-		DEBUG(10,("regdb_init: incrementing refcount (%d)\n", regdb_refcount));
+	if (regdb) {
+		DEBUG(10, ("regdb_init: incrementing refcount (%d)\n",
+			  regdb_refcount));
 		regdb_refcount++;
 		return true;
 	}
 
-	if ( !(regdb = db_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR, 0600)) )
-	{
-		regdb = db_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
-		if ( !regdb ) {
+	regdb = db_open(NULL, state_path("registry.tdb"), 0, REG_TDB_FLAGS,
+			O_RDWR, 0600);
+	if (!regdb) {
+		regdb = db_open(NULL, state_path("registry.tdb"), 0,
+				REG_TDB_FLAGS, O_RDWR|O_CREAT, 0600);
+		if (!regdb) {
 			DEBUG(0,("regdb_init: Failed to open registry %s (%s)\n",
 				state_path("registry.tdb"), strerror(errno) ));
 			return false;
@@ -303,15 +350,16 @@ bool regdb_init( void )
 
 	if ( vers_id != REGVER_V1 ) {
 		/* any upgrade code here if needed */
-		DEBUG(10, ("regdb_init: got INFO/version = %d != %d\n",
+		DEBUG(10, ("regdb_init: got %s = %d != %d\n", vstring,
 			   vers_id, REGVER_V1));
-	}
-
-	/* always setup the necessary keys and values */
-
-	if ( !init_registry_data() ) {
-		DEBUG(0,("regdb_init: Failed to initialize data in registry!\n"));
-		return false;
+		if (dbwrap_store_int32(regdb, vstring, REGVER_V1) != 0) {
+			DEBUG(0, ("regdb_init: error storing %s = %d\n",
+				  vstring, REGVER_V1));
+			return false;
+		} else {
+			DEBUG(10, ("regdb_init: stored %s = %d\n",
+				  vstring, REGVER_V1));
+		}
 	}
 
 	return true;
diff --git a/source/registry/reg_init_full.c b/source/registry/reg_init_full.c
index b6a644b..5c59c6b 100644
--- a/source/registry/reg_init_full.c
+++ b/source/registry/reg_init_full.c
@@ -74,6 +74,13 @@ bool init_registry( void )
 		goto fail;
 	}
 
+	/* setup the necessary keys and values */
+
+	if ( !init_registry_data() ) {
+		DEBUG(0,("regdb_init: Failed to initialize data in registry!\n"));
+		return false;
+	}
+
 	/* build the cache tree of registry hooks */
 	
 	reghook_cache_init();
diff --git a/source/registry/reg_init_smbconf.c b/source/registry/reg_init_smbconf.c
index b7e6add..1b17852 100644
--- a/source/registry/reg_init_smbconf.c
+++ b/source/registry/reg_init_smbconf.c
@@ -84,6 +84,11 @@ bool registry_init_smbconf(void)
 		DEBUGADD(1, (".\n"));
 		goto done;
 	}
+	if (!init_registry_key(KEY_SMBCONF)) {
+		DEBUG(1, ("Could not initialize registry key '%s'\n",
+			  KEY_SMBCONF));
+		goto done;
+	}
 	reghook_cache_init();
 	if (!reghook_cache_add(&smbconf_reg_hook)) {
 		DEBUG(1, ("Error adding smbconf reghooks to reghook cache.\n"));


-- 
Samba Shared Repository


More information about the samba-cvs mailing list