[SCM] Samba Shared Repository - branch master updated

Michael Adam obnox at samba.org
Mon Mar 20 22:29:02 UTC 2017


The branch, master has been updated
       via  55546fe idmap_autorid: Use idmap_config_int
       via  adbabd3 idmap_rid: Use idmap_config_int
       via  e190eaa winbind: Add idmap_config_int
       via  0b05785 idmap_autorid: Use idmap_config_bool
       via  b6b04b6 idmap_ad: Use idmap_config_bool
       via  3e72603 idmap_rfc2307: Use idmap_config_bool
       via  cdaec3b idmap: Use idmap_config_bool in idmap_init_domain
       via  66f5e7d winbind: Add idmap_config_bool()
       via  644a997 idmap_ad: Use idmap_config_const_string
       via  b0edb06 idmap_rfc2307: Use idmap_config_const_string
       via  166e8fb idmap_ldap: Use idmap_config_const_string
       via  c0bea5d idmap_ldap: Use idmap_config_const_string
       via  9d22e8a winbind: Use idmap_config_const_string in idmap_init_domain
       via  e78d78a winbind: Use idmap_config_const_string in idmap_script_db_init
       via  925335a winbind: Use idmap_config_const_string in idmap_tdb2_db_init
       via  6d33ebd winbind: Use idmap_config_const_string in wb_xids2sids_add_dom
       via  3f4b391 winbind: Use idmap_config_const_string in idmap_init_named_domain
       via  b8e00f0 winbind: Use idmap_config_const_string in domain_has_idmap_config
       via  1c34166 winbind: Add idmap_config_const_string
      from  a181609 lib: Simplify smb_nanosleep

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


- Log -----------------------------------------------------------------
commit 55546fe458a1925e55323411a35be104c071cabb
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 19:06:49 2017 +0100

    idmap_autorid: Use idmap_config_int
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>
    
    Autobuild-User(master): Michael Adam <obnox at samba.org>
    Autobuild-Date(master): Mon Mar 20 23:28:38 CET 2017 on sn-devel-144

commit adbabd3f4cc780061eda1faaff5ca44d7afdb116
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 19:05:10 2017 +0100

    idmap_rid: Use idmap_config_int
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit e190eaa30fcf777ba11a65f11be88390ead7ce0b
Author: Volker Lendecke <vl at samba.org>
Date:   Sun Jan 8 11:52:56 2017 +0000

    winbind: Add idmap_config_int
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 0b05785de6b73a1eb29e21944a7ee6dc3a5ce082
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 19:01:01 2017 +0100

    idmap_autorid: Use idmap_config_bool
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit b6b04b6bd7960f186cff345398d91ff73303eccd
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:59:06 2017 +0100

    idmap_ad: Use idmap_config_bool
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3e72603c1fab8938a60aef31adea7d0ca7771518
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:57:03 2017 +0100

    idmap_rfc2307: Use idmap_config_bool
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit cdaec3be3a1f7c0193de2c97bc6fdbebc3451423
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:53:58 2017 +0100

    idmap: Use idmap_config_bool in idmap_init_domain
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 66f5e7dbdadf1ba9c619739aa772668e70bb1c27
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jan 7 15:10:05 2017 +0000

    winbind: Add idmap_config_bool()
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 644a997144fa890857a012355cbd9d406ccbfd3d
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:50:38 2017 +0100

    idmap_ad: Use idmap_config_const_string
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit b0edb068923a4b974002c6340a82afc028075938
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:48:46 2017 +0100

    idmap_rfc2307: Use idmap_config_const_string
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 166e8fb1c139f638e7ab7f5c95c2ca2bb901c69f
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:40:28 2017 +0100

    idmap_ldap: Use idmap_config_const_string
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit c0bea5d081d224cb6d7ab61acf2097b349bdbaac
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:38:10 2017 +0100

    idmap_ldap: Use idmap_config_const_string
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 9d22e8a99c10de9c272955e4d51fb40e0860503f
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Mar 18 18:34:07 2017 +0100

    winbind: Use idmap_config_const_string in idmap_init_domain
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit e78d78a1ff5b1d759b0fcfdc9dfd27461ec55706
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jan 7 14:55:41 2017 +0000

    winbind: Use idmap_config_const_string in idmap_script_db_init
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 925335a5d443bbcb2f678095b7c3ea74f6617ff3
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jan 7 14:55:41 2017 +0000

    winbind: Use idmap_config_const_string in idmap_tdb2_db_init
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 6d33ebd5806afc430fe99e0a7efdf04a2288d794
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jan 7 14:55:41 2017 +0000

    winbind: Use idmap_config_const_string in wb_xids2sids_add_dom
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 3f4b391daf94a7760a9f91cbeeb16cd567ee2426
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jan 7 14:55:41 2017 +0000

    winbind: Use idmap_config_const_string in idmap_init_named_domain
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit b8e00f01833daa2636f308f7fa8ce44700f0e579
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jan 7 14:55:41 2017 +0000

    winbind: Use idmap_config_const_string in domain_has_idmap_config
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

commit 1c34166c1205328c53fca987e43bb1be6ca13538
Author: Volker Lendecke <vl at samba.org>
Date:   Sat Jan 7 14:53:09 2017 +0000

    winbind: Add idmap_config_const_string
    
    Signed-off-by: Volker Lendecke <vl at samba.org>
    Reviewed-by: Michael Adam <obnox at samba.org>

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

Summary of changes:
 source3/winbindd/idmap.c          | 86 +++++++++++++++++++++++----------------
 source3/winbindd/idmap_ad.c       | 21 +++-------
 source3/winbindd/idmap_autorid.c  |  6 +--
 source3/winbindd/idmap_ldap.c     | 18 ++------
 source3/winbindd/idmap_rfc2307.c  | 43 ++++++++------------
 source3/winbindd/idmap_rid.c      | 16 +-------
 source3/winbindd/idmap_script.c   | 10 +----
 source3/winbindd/idmap_tdb2.c     | 10 +----
 source3/winbindd/wb_xids2sids.c   | 10 +----
 source3/winbindd/winbindd_proto.h |  4 ++
 10 files changed, 88 insertions(+), 136 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/winbindd/idmap.c b/source3/winbindd/idmap.c
index 6a52633..dda8d0a 100644
--- a/source3/winbindd/idmap.c
+++ b/source3/winbindd/idmap.c
@@ -177,10 +177,55 @@ static bool idmap_init(void)
 	return true;
 }
 
+const char *idmap_config_const_string(const char *domname, const char *option,
+				      const char *def)
+{
+	int len = snprintf(NULL, 0, "idmap config %s", domname);
+
+	if (len == -1) {
+		return NULL;
+	}
+	{
+		char config_option[len+1];
+		snprintf(config_option, sizeof(config_option),
+			 "idmap config %s", domname);
+		return lp_parm_const_string(-1, config_option, option, def);
+	}
+}
+
+bool idmap_config_bool(const char *domname, const char *option, bool def)
+{
+	int len = snprintf(NULL, 0, "idmap config %s", domname);
+
+	if (len == -1) {
+		return def;
+	}
+	{
+		char config_option[len+1];
+		snprintf(config_option, sizeof(config_option),
+			 "idmap config %s", domname);
+		return lp_parm_bool(-1, config_option, option, def);
+	}
+}
+
+int idmap_config_int(const char *domname, const char *option, int def)
+{
+	int len = snprintf(NULL, 0, "idmap config %s", domname);
+
+	if (len == -1) {
+		return def;
+	}
+	{
+		char config_option[len+1];
+		snprintf(config_option, sizeof(config_option),
+			 "idmap config %s", domname);
+		return lp_parm_int(-1, config_option, option, def);
+	}
+}
+
 bool domain_has_idmap_config(const char *domname)
 {
 	int i;
-	char *config_option;
 	const char *range = NULL;
 	const char *backend = NULL;
 	bool ok;
@@ -198,23 +243,14 @@ bool domain_has_idmap_config(const char *domname)
 
 	/* fallback: also check loadparm */
 
-	config_option = talloc_asprintf(talloc_tos(), "idmap config %s",
-					domname);
-	if (config_option == NULL) {
-		DEBUG(0, ("out of memory\n"));
-		return false;
-	}
-
-	range = lp_parm_const_string(-1, config_option, "range", NULL);
-	backend = lp_parm_const_string(-1, config_option, "backend", NULL);
+	range = idmap_config_const_string(domname, "range", NULL);
+	backend = idmap_config_const_string(domname, "backend", NULL);
 	if (range != NULL && backend != NULL) {
 		DEBUG(5, ("idmap configuration specified for domain '%s'\n",
 			domname));
-		TALLOC_FREE(config_option);
 		return true;
 	}
 
-	TALLOC_FREE(config_option);
 	return false;
 }
 
@@ -340,7 +376,6 @@ static struct idmap_domain *idmap_init_domain(TALLOC_CTX *mem_ctx,
 {
 	struct idmap_domain *result;
 	NTSTATUS status;
-	char *config_option = NULL;
 	const char *range;
 	unsigned low_id = 0;
 	unsigned high_id = 0;
@@ -384,17 +419,8 @@ static struct idmap_domain *idmap_init_domain(TALLOC_CTX *mem_ctx,
 	 * load ranges and read only information from the config
 	 */
 
-	config_option = talloc_asprintf(result, "idmap config %s",
-					result->name);
-	if (config_option == NULL) {
-		DEBUG(0, ("Out of memory!\n"));
-		goto fail;
-	}
-
-	result->read_only = lp_parm_bool(-1, config_option, "read only", false);
-	range = lp_parm_const_string(-1, config_option, "range", NULL);
-
-	talloc_free(config_option);
+	result->read_only = idmap_config_bool(result->name, "read only", false);
+	range = idmap_config_const_string(result->name, "range", NULL);
 
 	if (range == NULL) {
 		if (check_range) {
@@ -448,7 +474,6 @@ static struct idmap_domain *idmap_init_named_domain(TALLOC_CTX *mem_ctx,
 						    const char *domname)
 {
 	struct idmap_domain *result = NULL;
-	char *config_option;
 	const char *backend;
 	bool ok;
 
@@ -457,14 +482,7 @@ static struct idmap_domain *idmap_init_named_domain(TALLOC_CTX *mem_ctx,
 		return NULL;
 	}
 
-	config_option = talloc_asprintf(talloc_tos(), "idmap config %s",
-					domname);
-	if (config_option == NULL) {
-		DEBUG(0, ("talloc failed\n"));
-		goto fail;
-	}
-
-	backend = lp_parm_const_string(-1, config_option, "backend", NULL);
+	backend = idmap_config_const_string(domname, "backend", NULL);
 	if (backend == NULL) {
 		DEBUG(10, ("no idmap backend configured for domain '%s'\n",
 			   domname));
@@ -476,11 +494,9 @@ static struct idmap_domain *idmap_init_named_domain(TALLOC_CTX *mem_ctx,
 		goto fail;
 	}
 
-	TALLOC_FREE(config_option);
 	return result;
 
 fail:
-	TALLOC_FREE(config_option);
 	TALLOC_FREE(result);
 	return NULL;
 }
diff --git a/source3/winbindd/idmap_ad.c b/source3/winbindd/idmap_ad.c
index 5039e9b..1dbc3e4 100644
--- a/source3/winbindd/idmap_ad.c
+++ b/source3/winbindd/idmap_ad.c
@@ -357,7 +357,6 @@ static NTSTATUS idmap_ad_context_create(TALLOC_CTX *mem_ctx,
 					struct idmap_ad_context **pctx)
 {
 	struct idmap_ad_context *ctx;
-	char *schema_config_option;
 	const char *schema_mode;
 	NTSTATUS status;
 	TLDAPRC rc;
@@ -385,21 +384,13 @@ static NTSTATUS idmap_ad_context_create(TALLOC_CTX *mem_ctx,
 		return status;
 	}
 
-	schema_config_option = talloc_asprintf(
-		ctx, "idmap config %s", domname);
-	if (schema_config_option == NULL) {
-		TALLOC_FREE(ctx);
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	ctx->unix_primary_group = lp_parm_bool(
-		-1, schema_config_option, "unix_primary_group", false);
-	ctx->unix_nss_info = lp_parm_bool(
-		-1, schema_config_option, "unix_nss_info", false);
+	ctx->unix_primary_group = idmap_config_bool(
+		domname, "unix_primary_group", false);
+	ctx->unix_nss_info = idmap_config_bool(
+		domname, "unix_nss_info", false);
 
-	schema_mode = lp_parm_const_string(
-		-1, schema_config_option, "schema_mode", "rfc2307");
-	TALLOC_FREE(schema_config_option);
+	schema_mode = idmap_config_const_string(
+		domname, "schema_mode", "rfc2307");
 
 	rc = get_posix_schema_names(ctx->ld, schema_mode, ctx, &ctx->schema);
 	if (!TLDAP_RC_IS_SUCCESS(rc)) {
diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index ab89d35..9793bfe 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -844,8 +844,7 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
 	commonconfig->private_data = config;
 
 	config->minvalue = dom->low_id;
-	config->rangesize = lp_parm_int(-1, "idmap config *",
-					"rangesize", 100000);
+	config->rangesize = idmap_config_int("*", "rangesize", 100000);
 
 	config->maxranges = (dom->high_id - dom->low_id + 1) /
 	    config->rangesize;
@@ -869,8 +868,7 @@ static NTSTATUS idmap_autorid_initialize(struct idmap_domain *dom)
 	DEBUG(5, ("%d domain ranges with a size of %d are available\n",
 		  config->maxranges, config->rangesize));
 
-	ignore_builtin = lp_parm_bool(-1, "idmap config *",
-				      "ignore builtin", false);
+	ignore_builtin = idmap_config_bool("*", "ignore builtin", false);
 
 	/* fill the TDB common configuration */
 
diff --git a/source3/winbindd/idmap_ldap.c b/source3/winbindd/idmap_ldap.c
index 0520f21..041152c 100644
--- a/source3/winbindd/idmap_ldap.c
+++ b/source3/winbindd/idmap_ldap.c
@@ -64,7 +64,6 @@ struct idmap_ldap_context {
 
 static NTSTATUS get_credentials( TALLOC_CTX *mem_ctx,
 				 struct smbldap_state *ldap_state,
-				 const char *config_option,
 				 struct idmap_domain *dom,
 				 char **dn )
 {
@@ -76,7 +75,7 @@ static NTSTATUS get_credentials( TALLOC_CTX *mem_ctx,
 
 	/* assume anonymous if we don't have a specified user */
 
-	tmp = lp_parm_const_string(-1, config_option, "ldap_user_dn", NULL);
+	tmp = idmap_config_const_string(dom->name, "ldap_user_dn", NULL);
 
 	if ( tmp ) {
 		if (!dom) {
@@ -417,7 +416,6 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
 {
 	NTSTATUS ret;
 	struct idmap_ldap_context *ctx = NULL;
-	char *config_option = NULL;
 	const char *tmp = NULL;
 
 	/* Only do init if we are online */
@@ -431,14 +429,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	config_option = talloc_asprintf(ctx, "idmap config %s", dom->name);
-	if (!config_option) {
-		DEBUG(0, ("Out of memory!\n"));
-		ret = NT_STATUS_NO_MEMORY;
-		goto done;
-	}
-
-	tmp = lp_parm_const_string(-1, config_option, "ldap_url", NULL);
+	tmp = idmap_config_const_string(dom->name, "ldap_url", NULL);
 
 	if ( ! tmp) {
 		DEBUG(1, ("ERROR: missing idmap ldap url\n"));
@@ -450,7 +441,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
 
 	trim_char(ctx->url, '\"', '\"');
 
-	tmp = lp_parm_const_string(-1, config_option, "ldap_base_dn", NULL);
+	tmp = idmap_config_const_string(dom->name, "ldap_base_dn", NULL);
 	if ( ! tmp || ! *tmp) {
 		tmp = lp_ldap_idmap_suffix(talloc_tos());
 		if ( ! tmp) {
@@ -478,7 +469,7 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
 		goto done;
 	}
 
-	ret = get_credentials( ctx, ctx->smbldap_state, config_option,
+	ret = get_credentials( ctx, ctx->smbldap_state,
 			       dom, &ctx->user_dn );
 	if ( !NT_STATUS_IS_OK(ret) ) {
 		DEBUG(1,("idmap_ldap_db_init: Failed to get connection "
@@ -501,7 +492,6 @@ static NTSTATUS idmap_ldap_db_init(struct idmap_domain *dom)
 		goto done;
 	}
 
-	talloc_free(config_option);
 	return NT_STATUS_OK;
 
 /*failed */
diff --git a/source3/winbindd/idmap_rfc2307.c b/source3/winbindd/idmap_rfc2307.c
index 34cc5cd..340757a 100644
--- a/source3/winbindd/idmap_rfc2307.c
+++ b/source3/winbindd/idmap_rfc2307.c
@@ -109,15 +109,15 @@ static NTSTATUS idmap_rfc2307_ads_search(struct idmap_rfc2307_context *ctx,
 }
 
 static NTSTATUS idmap_rfc2307_init_ads(struct idmap_rfc2307_context *ctx,
-				       const char *cfg_opt)
+				       const char *domain_name)
 {
 	const char *ldap_domain;
 
 	ctx->search = idmap_rfc2307_ads_search;
 	ctx->check_connection = idmap_rfc2307_ads_check_connection;
 
-	ldap_domain = lp_parm_const_string(-1, cfg_opt, "ldap_domain",
-					      NULL);
+	ldap_domain = idmap_config_const_string(domain_name, "ldap_domain",
+						NULL);
 	if (ldap_domain) {
 		ctx->ldap_domain = talloc_strdup(ctx, ldap_domain);
 		if (ctx->ldap_domain == NULL) {
@@ -167,8 +167,7 @@ static bool idmap_rfc2307_get_uint32(LDAP *ldap, LDAPMessage *entry,
 }
 
 static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx,
-					struct idmap_domain *dom,
-					const char *config_option)
+					const char *domain_name)
 {
 	NTSTATUS ret;
 	char *url;
@@ -176,7 +175,7 @@ static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx,
 	const char *ldap_url, *user_dn;
 	TALLOC_CTX *mem_ctx = ctx;
 
-	ldap_url = lp_parm_const_string(-1, config_option, "ldap_url", NULL);
+	ldap_url = idmap_config_const_string(domain_name, "ldap_url", NULL);
 	if (!ldap_url) {
 		DEBUG(1, ("ERROR: missing idmap ldap url\n"));
 		return NT_STATUS_UNSUCCESSFUL;
@@ -184,9 +183,9 @@ static NTSTATUS idmap_rfc2307_init_ldap(struct idmap_rfc2307_context *ctx,
 
 	url = talloc_strdup(talloc_tos(), ldap_url);
 
-	user_dn = lp_parm_const_string(-1, config_option, "ldap_user_dn", NULL);
+	user_dn = idmap_config_const_string(domain_name, "ldap_user_dn", NULL);
 	if (user_dn) {
-		secret = idmap_fetch_secret("ldap", dom->name, user_dn);
+		secret = idmap_fetch_secret("ldap", domain_name, user_dn);
 		if (!secret) {
 			ret = NT_STATUS_ACCESS_DENIED;
 			goto done;
@@ -764,7 +763,6 @@ static int idmap_rfc2307_context_destructor(struct idmap_rfc2307_context *ctx)
 static NTSTATUS idmap_rfc2307_initialize(struct idmap_domain *domain)
 {
 	struct idmap_rfc2307_context *ctx;
-	char *cfg_opt;
 	const char *bind_path_user, *bind_path_group, *ldap_server, *realm;
 	NTSTATUS status;
 
@@ -774,14 +772,8 @@ static NTSTATUS idmap_rfc2307_initialize(struct idmap_domain *domain)
 	}
 	talloc_set_destructor(ctx, idmap_rfc2307_context_destructor);
 
-	cfg_opt = talloc_asprintf(ctx, "idmap config %s", domain->name);
-	if (cfg_opt == NULL) {
-		status = NT_STATUS_NO_MEMORY;
-		goto err;
-	}
-
-	bind_path_user = lp_parm_const_string(-1, cfg_opt, "bind_path_user",
-					      NULL);
+	bind_path_user = idmap_config_const_string(
+		domain->name, "bind_path_user", NULL);
 	if (bind_path_user) {
 		ctx->bind_path_user = talloc_strdup(ctx, bind_path_user);
 		if (ctx->bind_path_user == NULL) {
@@ -793,8 +785,8 @@ static NTSTATUS idmap_rfc2307_initialize(struct idmap_domain *domain)
 		goto err;
 	}
 
-	bind_path_group = lp_parm_const_string(-1, cfg_opt, "bind_path_group",
-					       NULL);
+	bind_path_group = idmap_config_const_string(
+		domain->name, "bind_path_group", NULL);
 	if (bind_path_group) {
 		ctx->bind_path_group = talloc_strdup(ctx, bind_path_group);
 		if (ctx->bind_path_group == NULL) {
@@ -806,17 +798,18 @@ static NTSTATUS idmap_rfc2307_initialize(struct idmap_domain *domain)
 		goto err;
 	}
 
-	ldap_server = lp_parm_const_string(-1, cfg_opt, "ldap_server", NULL);
+	ldap_server = idmap_config_const_string(
+		domain->name, "ldap_server", NULL);
 	if (!ldap_server) {
 		status = NT_STATUS_INVALID_PARAMETER;
 		goto err;
 	}
 
 	if (strcmp(ldap_server, "stand-alone") == 0) {
-		status = idmap_rfc2307_init_ldap(ctx, domain, cfg_opt);
+		status = idmap_rfc2307_init_ldap(ctx, domain->name);
 
 	} else if (strcmp(ldap_server, "ad") == 0) {
-		status = idmap_rfc2307_init_ads(ctx, cfg_opt);
+		status = idmap_rfc2307_init_ads(ctx, domain->name);
 
 	} else {
 		status = NT_STATUS_INVALID_PARAMETER;
@@ -826,7 +819,7 @@ static NTSTATUS idmap_rfc2307_initialize(struct idmap_domain *domain)
 		goto err;
 	}
 
-	realm = lp_parm_const_string(-1, cfg_opt, "realm", NULL);
+	realm = idmap_config_const_string(domain->name, "realm", NULL);
 	if (realm) {
 		ctx->realm = talloc_strdup(ctx, realm);
 		if (ctx->realm == NULL) {
@@ -835,14 +828,12 @@ static NTSTATUS idmap_rfc2307_initialize(struct idmap_domain *domain)
 		}
 	}
 
-	ctx->user_cn = lp_parm_bool(-1, cfg_opt, "user_cn", false);
+	ctx->user_cn = idmap_config_bool(domain->name, "user_cn", false);
 
 	domain->private_data = ctx;
-	talloc_free(cfg_opt);
 	return NT_STATUS_OK;
 
 err:
-	talloc_free(cfg_opt);
 	talloc_free(ctx);
 	return status;
 }
diff --git a/source3/winbindd/idmap_rid.c b/source3/winbindd/idmap_rid.c
index ac53705..8cf1f03 100644
--- a/source3/winbindd/idmap_rid.c
+++ b/source3/winbindd/idmap_rid.c
@@ -37,9 +37,7 @@ struct idmap_rid_context {
 
 static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom)
 {
-	NTSTATUS ret;
 	struct idmap_rid_context *ctx;
-	char *config_option = NULL;
 
 	ctx = talloc_zero(dom, struct idmap_rid_context);
 	if (ctx == NULL) {
@@ -47,23 +45,11 @@ static NTSTATUS idmap_rid_initialize(struct idmap_domain *dom)
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	config_option = talloc_asprintf(ctx, "idmap config %s", dom->name);
-	if ( ! config_option) {
-		DEBUG(0, ("Out of memory!\n"));
-		ret = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
-
-	ctx->base_rid = lp_parm_int(-1, config_option, "base_rid", 0);
+	ctx->base_rid = idmap_config_int(dom->name, "base_rid", 0);
 
 	dom->private_data = ctx;
 
-	talloc_free(config_option);
 	return NT_STATUS_OK;
-
-failed:
-	talloc_free(ctx);
-	return ret;
 }
 
 static NTSTATUS idmap_rid_id_to_sid(struct idmap_domain *dom, struct id_map *map)
diff --git a/source3/winbindd/idmap_script.c b/source3/winbindd/idmap_script.c
index 75eabdf..4faf2d5 100644
--- a/source3/winbindd/idmap_script.c
+++ b/source3/winbindd/idmap_script.c
@@ -582,7 +582,6 @@ static NTSTATUS idmap_script_db_init(struct idmap_domain *dom)
 {
 	NTSTATUS ret;
 	struct idmap_script_context *ctx;
-	char *config_option = NULL;
 	const char * idmap_script = NULL;
 
 	DEBUG(10, ("%s called ...\n", __func__));
@@ -594,14 +593,7 @@ static NTSTATUS idmap_script_db_init(struct idmap_domain *dom)
 		goto failed;
 	}
 
-	config_option = talloc_asprintf(ctx, "idmap config %s", dom->name);
-	if (config_option == NULL) {
-		DEBUG(0, ("Out of memory!\n"));
-		ret = NT_STATUS_NO_MEMORY;
-		goto failed;
-	}
-	ctx->script = lp_parm_const_string(-1, config_option, "script", NULL);
-	talloc_free(config_option);
+	ctx->script = idmap_config_const_string(dom->name, "script", NULL);
 
 	/* Do we even need to handle this? */
 	idmap_script = lp_parm_const_string(-1, "idmap", "script", NULL);
diff --git a/source3/winbindd/idmap_tdb2.c b/source3/winbindd/idmap_tdb2.c
index fdcd44e..72c5b9e 100644
--- a/source3/winbindd/idmap_tdb2.c
+++ b/source3/winbindd/idmap_tdb2.c
@@ -533,7 +533,6 @@ static NTSTATUS idmap_tdb2_db_init(struct idmap_domain *dom)
 	NTSTATUS ret;
 	struct idmap_tdb_common_context *commonctx;
 	struct idmap_tdb2_context *ctx;
-	char *config_option = NULL;
 	const char * idmap_script = NULL;


-- 
Samba Shared Repository



More information about the samba-cvs mailing list