[SCM] Samba Shared Repository - branch v3-2-test updated - initial-v3-2-unstable-1047-g77713e7

Michael Adam obnox at samba.org
Thu Jan 3 14:33:39 GMT 2008


The branch, v3-2-test has been updated
       via  77713e776405800ac54c692a77cd4efd153042cb (commit)
       via  5d557e3f95b8d53114c25ba7fa3e564a50be9e05 (commit)
      from  4c404d627ccfaf1c17f4b6b1ebab6fce357d9ab1 (commit)

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


- Log -----------------------------------------------------------------
commit 77713e776405800ac54c692a77cd4efd153042cb
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 3 15:33:09 2008 +0100

    Make libnet_conf handle opening/initialization of the registry.
    
    Open state is currently tracked by a global variable
    to avoid double initialization.
    
    Later, this can possibly be replaced by a conf-context
    created by an initialization function and passed around
    to the other api functions.
    
    Michael

commit 5d557e3f95b8d53114c25ba7fa3e564a50be9e05
Author: Michael Adam <obnox at samba.org>
Date:   Thu Jan 3 14:34:31 2008 +0100

    Add a comment header and do some slight reformatting.
    
    Michael

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

Summary of changes:
 source/libnet/libnet_conf.c |   44 ++++++++++++++++++++++++++++++++++++++----
 source/utils/net_conf.c     |    5 ----
 2 files changed, 39 insertions(+), 10 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/libnet/libnet_conf.c b/source/libnet/libnet_conf.c
index ea3f708..6652617 100644
--- a/source/libnet/libnet_conf.c
+++ b/source/libnet/libnet_conf.c
@@ -21,6 +21,11 @@
 #include "includes.h"
 #include "libnet/libnet.h"
 
+/*
+ * yuck - static variable to keep track of the registry initialization. 
+ */
+static bool registry_initialized = false;
+
 /**********************************************************************
  *
  * Helper functions (mostly registry related)
@@ -54,6 +59,26 @@ static WERROR libnet_conf_add_string_to_array(TALLOC_CTX *mem_ctx,
 	return WERR_OK;
 }
 
+static WERROR libnet_conf_reg_initialize(void)
+{
+	WERROR werr = WERR_OK;
+
+	if (registry_initialized) {
+		goto done;
+	}
+
+	if (!registry_init_regdb()) {
+		/* proper error code? */
+		werr = WERR_GENERAL_FAILURE;
+		goto done;
+	}
+
+	registry_initialized = true;
+
+done:
+	return werr;
+}
+
 /**
  * Open a registry key specified by "path"
  */
@@ -78,6 +103,13 @@ static WERROR libnet_conf_reg_open_path(TALLOC_CTX *mem_ctx,
 		goto done;
 	}
 
+	werr = libnet_conf_reg_initialize();
+	if (!W_ERROR_IS_OK(werr)) {
+		DEBUG(1, ("Error initializing registry: %s\n",
+			  dos_errstr(werr)));
+		goto done;
+	}
+
 	token = registry_create_admin_token(tmp_ctx);
 	if (token == NULL) {
 		DEBUG(1, ("Error creating admin token\n"));
@@ -124,7 +156,7 @@ done:
 	return werr;
 }
 
-/*
+/**
  * open the base key KEY_SMBCONF
  */
 static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx,
@@ -134,6 +166,9 @@ static WERROR libnet_conf_reg_open_base_key(TALLOC_CTX *ctx,
 	return libnet_conf_reg_open_path(ctx, KEY_SMBCONF, desired_access, key);
 }
 
+/**
+ * check if a value exists in a given registry key
+ */
 static bool libnet_conf_value_exists(struct registry_key *key,
 				     const char *param)
 {
@@ -151,7 +186,7 @@ static bool libnet_conf_value_exists(struct registry_key *key,
 	return ret;
 }
 
-/*
+/**
  * create a subkey of KEY_SMBCONF
  */
 static WERROR libnet_conf_reg_create_service_key(TALLOC_CTX *ctx,
@@ -193,7 +228,7 @@ done:
 	return werr;
 }
 
-/*
+/**
  * add a value to a key.
  */
 static WERROR libnet_conf_reg_set_value(struct registry_key *key,
@@ -792,8 +827,7 @@ done:
  *
  **********************************************************************/
 
-WERROR libnet_conf_set_global_parameter(const char *param,
-					const char *val)
+WERROR libnet_conf_set_global_parameter(const char *param, const char *val)
 {
 	return libnet_conf_set_parameter(GLOBAL_NAME, param, val);
 }
diff --git a/source/utils/net_conf.c b/source/utils/net_conf.c
index 2d4b3f4..a758391 100644
--- a/source/utils/net_conf.c
+++ b/source/utils/net_conf.c
@@ -852,11 +852,6 @@ int net_conf(int argc, const char **argv)
 		{NULL, NULL, NULL}
 	};
 
-	if (!registry_init_regdb()) {
-		d_fprintf(stderr, "Error initializing the registry!\n");
-		goto done;
-	}
-
 	ret = net_run_function2(argc, argv, "net conf", func);
 
 	regdb_close();


-- 
Samba Shared Repository


More information about the samba-cvs mailing list