[SCM] SAMBA-CTDB repository - branch v3-2-ctdb updated - build_3.2.11_ctdb.59-8-g8a75176

Michael Adam obnox at samba.org
Wed Apr 29 09:49:09 GMT 2009


The branch, v3-2-ctdb has been updated
       via  8a75176ef775b0222189ad29d19f43488f412d3b (commit)
       via  e8d8ffa5f926b8beed6049dfed13ecc8b81e669e (commit)
       via  829374538db8733635b4c3848454faddfe87c691 (commit)
      from  993608e2fa84e43b8195a53e2c3f2024f0e92b8e (commit)

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


- Log -----------------------------------------------------------------
commit 8a75176ef775b0222189ad29d19f43488f412d3b
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 29 01:49:53 2009 +0200

    s3:smbd/service: switch load_registry_service/shares to use loadparm routines
    
    instead of reading the registry directly with tdb and activating the
    configure options by hand.
    
    This eliminates the need for repeating checks done in loadparm.
    For instance it disables registry shares without path in the server
    as is the case with text based shares.
    
    Michael
    (cherry picked from commit 077bcc11257697b243916fbb02cd72b3a122b9ba)

commit e8d8ffa5f926b8beed6049dfed13ecc8b81e669e
Author: Michael Adam <obnox at samba.org>
Date:   Wed Apr 29 01:31:03 2009 +0200

    s3:loadparm: refactor process_registry_service out or process_registry_globals
    
    Michael
    (cherry picked from commit fb3b6576127ce837ac711e87c293d1f4cf97473c)

commit 829374538db8733635b4c3848454faddfe87c691
Author: Michael Adam <obnox at samba.org>
Date:   Wed Sep 24 20:31:39 2008 +0200

    loadparm: rename process_registry_service() to process_smbconf_service().
    
    There is nothing registry-specific in that function.
    
    Michael

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

Summary of changes:
 source/param/loadparm.c |   44 ++++++++++++++++++---------
 source/smbd/service.c   |   73 ++---------------------------------------------
 2 files changed, 32 insertions(+), 85 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/param/loadparm.c b/source/param/loadparm.c
index f6f2486..bbdb52c 100644
--- a/source/param/loadparm.c
+++ b/source/param/loadparm.c
@@ -6508,7 +6508,7 @@ static struct smbconf_ctx *lp_smbconf_ctx(void)
 	return conf_ctx;
 }
 
-static bool process_registry_service(struct smbconf_service *service)
+static bool process_smbconf_service(struct smbconf_service *service)
 {
 	uint32_t count;
 	bool ret;
@@ -6535,10 +6535,10 @@ static bool process_registry_service(struct smbconf_service *service)
 	return true;
 }
 
-/*
- * process_registry_globals
+/**
+ * load a service from registry and activate it
  */
-static bool process_registry_globals(void)
+bool process_registry_service(const char *service_name)
 {
 	WERROR werr;
 	struct smbconf_service *service = NULL;
@@ -6550,24 +6550,23 @@ static bool process_registry_globals(void)
 		goto done;
 	}
 
-	ret = do_parameter("registry shares", "yes", NULL);
-	if (!ret) {
-		goto done;
-	}
+	DEBUG(5, ("process_registry_service: service name %s\n", service_name));
 
-	if (!smbconf_share_exists(conf_ctx, GLOBAL_NAME)) {
-		/* nothing to read from the registry yet but make sure lp_load
-		 * doesn't return false */
+	if (!smbconf_share_exists(conf_ctx, service_name)) {
+		/*
+		 * Registry does not contain data for this service (yet),
+		 * but make sure lp_load doesn't return false.
+		 */
 		ret = true;
 		goto done;
 	}
 
-	werr = smbconf_get_share(conf_ctx, mem_ctx, GLOBAL_NAME, &service);
+	werr = smbconf_get_share(conf_ctx, mem_ctx, service_name, &service);
 	if (!W_ERROR_IS_OK(werr)) {
 		goto done;
 	}
 
-	ret = process_registry_service(service);
+	ret = process_smbconf_service(service);
 	if (!ret) {
 		goto done;
 	}
@@ -6580,7 +6579,22 @@ done:
 	return ret;
 }
 
-static bool process_registry_shares(void)
+/*
+ * process_registry_globals
+ */
+static bool process_registry_globals(void)
+{
+	bool ret;
+
+	ret = do_parameter("registry shares", "yes", NULL);
+	if (!ret) {
+		return ret;
+	}
+
+	return process_registry_service(GLOBAL_NAME);
+}
+
+bool process_registry_shares(void)
 {
 	WERROR werr;
 	uint32_t count;
@@ -6605,7 +6619,7 @@ static bool process_registry_shares(void)
 		if (strequal(service[count]->name, GLOBAL_NAME)) {
 			continue;
 		}
-		ret = process_registry_service(service[count]);
+		ret = process_smbconf_service(service[count]);
 		if (!ret) {
 			goto done;
 		}
diff --git a/source/smbd/service.c b/source/smbd/service.c
index 1c8ffbd..f463e45 100644
--- a/source/smbd/service.c
+++ b/source/smbd/service.c
@@ -221,16 +221,6 @@ bool set_current_service(connection_struct *conn, uint16 flags, bool do_chdir)
 
 static int load_registry_service(const char *servicename)
 {
-	struct registry_key *key;
-	char *path;
-	WERROR err;
-
-	uint32 i;
-	char *value_name;
-	struct registry_value *value;
-
-	int res = -1;
-
 	if (!lp_registry_shares()) {
 		return -1;
 	}
@@ -243,79 +233,22 @@ static int load_registry_service(const char *servicename)
 		return -2;
 	}
 
-	if (asprintf(&path, "%s\\%s", KEY_SMBCONF, servicename) == -1) {
-		return -1;
-	}
-
-	err = reg_open_path(NULL, path, REG_KEY_READ, get_root_nt_token(),
-			    &key);
-	SAFE_FREE(path);
-
-	if (!W_ERROR_IS_OK(err)) {
+	if (!process_registry_service(servicename)) {
 		return -1;
 	}
 
-	res = lp_add_service(servicename, -1);
-	if (res == -1) {
-		goto error;
-	}
-
-	for (i=0;
-	     W_ERROR_IS_OK(reg_enumvalue(key, key, i, &value_name, &value));
-	     i++) {
-		switch (value->type) {
-		case REG_DWORD: { 
-			char *tmp;
-			if (asprintf(&tmp, "%d", value->v.dword) == -1) {
-				continue;
-			}
-			lp_do_parameter(res, value_name, tmp);
-			SAFE_FREE(tmp);
-			break;
-		}
-		case REG_SZ: {
-			lp_do_parameter(res, value_name, value->v.sz.str);
-			break;
-		}
-		default:
-			/* Ignore all the rest */
-			break;
-		}
-
-		TALLOC_FREE(value_name);
-		TALLOC_FREE(value);
-	}
-
- error:
-
-	TALLOC_FREE(key);
-	return res;
+	return lp_servicenumber(servicename);
 }
 
 void load_registry_shares(void)
 {
-	struct registry_key *key;
-	char *name;
-	WERROR err;
-	int i;
-
 	DEBUG(8, ("load_registry_shares()\n"));
 	if (!lp_registry_shares()) {
 		return;
 	}
 
-	err = reg_open_path(NULL, KEY_SMBCONF, REG_KEY_READ,
-			    get_root_nt_token(), &key);
-	if (!(W_ERROR_IS_OK(err))) {
-		return;
-	}
-
-	for (i=0; W_ERROR_IS_OK(reg_enumkey(key, key, i, &name, NULL)); i++) {
-		load_registry_service(name);
-		TALLOC_FREE(name);
-	}
+	process_registry_shares();
 
-	TALLOC_FREE(key);
 	return;
 }
 


-- 
SAMBA-CTDB repository


More information about the samba-cvs mailing list