[SCM] Samba Shared Repository - branch v3-6-test updated

Volker Lendecke vlendec at samba.org
Fri Mar 18 10:34:54 MDT 2011


The branch, v3-6-test has been updated
       via  1279cee s3:autorid make sure we set the mapping status correct on early exit
       via  d8e64e9 idmap-autorid: Slightly simplify idmap_autorid_get_domainrange
       via  1cc00aa idmap-autorid: Slightly simplify idmap_autorid_get_domainrange
       via  ea026e4 idmap-autorid: Remove an unused variable
       via  d4c4c79 idmap-autorid: Use talloc_tos() in idmap_autorid_id_to_sid
       via  4f9ddbd idmap-autorid: Remove an else branch
       via  ba1879b idmap-autorid: Remove an unused variable
       via  ee5b57f idmap-autorid: Remove an unused parameter
       via  10191a7 idmap-autorid: Use talloc_tos() in idmap_autorid_sids_to_unixids
       via  d596aa3 idmap-autorid: Not necessary to talloc domaincfg
       via  beafee2 idmap-autorid: Not necessary to talloc domainsid
      from  69631fe s3: Cope with 192.168.1.1/24 in smbcontrol ip-dropped

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


- Log -----------------------------------------------------------------
commit 1279cee650d7f05c58353fe2c361d8a01d1b9c99
Author: Christian Ambach <christian.ambach at de.ibm.com>
Date:   Fri Mar 18 14:46:47 2011 +0100

    s3:autorid make sure we set the mapping status correct on early exit
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>
    
    Autobuild-User: Volker Lendecke <vlendec at samba.org>
    Autobuild-Date: Fri Mar 18 16:30:36 CET 2011 on sn-devel-104

commit d8e64e994c3310c75714a4df6830ae87bfc40c57
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:55:58 2011 +0100

    idmap-autorid: Slightly simplify idmap_autorid_get_domainrange
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit 1cc00aa7bd52391044dd52a309909ffb57a14816
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:53:22 2011 +0100

    idmap-autorid: Slightly simplify idmap_autorid_get_domainrange
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit ea026e461a040c901b74303a97a4205ca5382fe0
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:48:44 2011 +0100

    idmap-autorid: Remove an unused variable
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit d4c4c7913f88b181bea5d1d3167d89858629efa9
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:47:41 2011 +0100

    idmap-autorid: Use talloc_tos() in idmap_autorid_id_to_sid
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit 4f9ddbd445f2f0c9b95a8782e3aa9da20a455464
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:45:02 2011 +0100

    idmap-autorid: Remove an else branch
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit ba1879b997e480756af3a143d22d5ec204386f7a
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:38:21 2011 +0100

    idmap-autorid: Remove an unused variable
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit ee5b57f76760808c05f64085e33c9094eb51a663
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:36:54 2011 +0100

    idmap-autorid: Remove an unused parameter
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit 10191a7e75159fc522503f43a2e0b6f0eae8e9c9
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:33:58 2011 +0100

    idmap-autorid: Use talloc_tos() in idmap_autorid_sids_to_unixids
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit d596aa322ba9adbe5f4c90a02a1ac6549a692fa1
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:25:40 2011 +0100

    idmap-autorid: Not necessary to talloc domaincfg
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

commit beafee2bbfff08f10df2c7ba725c29e8bb181aff
Author: Volker Lendecke <vl at samba.org>
Date:   Tue Mar 8 21:17:37 2011 +0100

    idmap-autorid: Not necessary to talloc domainsid
    
    Signed-off-by: Christian Ambach <christian.ambach at de.ibm.com>

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

Summary of changes:
 source3/winbindd/idmap_autorid.c |  115 ++++++++++++++------------------------
 1 files changed, 43 insertions(+), 72 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/winbindd/idmap_autorid.c b/source3/winbindd/idmap_autorid.c
index f720a46..ff33a5d 100644
--- a/source3/winbindd/idmap_autorid.c
+++ b/source3/winbindd/idmap_autorid.c
@@ -54,15 +54,12 @@ static NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
 {
 	NTSTATUS ret;
 	uint32_t domainnum, hwm;
-	char *sidstr, *numstr;
+	fstring sidstr;
+	char *numstr;
 	struct autorid_domain_config *cfg;
 
 	cfg = (struct autorid_domain_config *)private_data;
-	sidstr = dom_sid_string(talloc_tos(), &(cfg->sid));
-
-	if (!sidstr) {
-		return NT_STATUS_NO_MEMORY;
-	}
+	dom_sid_string_buf(&(cfg->sid), sidstr, sizeof(sidstr));
 
 	if (!dbwrap_fetch_uint32(db, sidstr, &domainnum)) {
 		DEBUG(10, ("Acquiring new range for domain %s\n", sidstr));
@@ -107,13 +104,12 @@ static NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
 		ret = dbwrap_trans_store_bystring(db, numstr,
 						  string_term_tdb_data(sidstr),
 						  TDB_INSERT);
+		talloc_free(numstr);
 		if (!NT_STATUS_IS_OK(ret)) {
-			talloc_free(numstr);
 			DEBUG(1, ("Fatal error while storing "
 				  "new domain->range assignment!\n"));
 			goto error;
 		}
-		talloc_free(numstr);
 		DEBUG(5, ("Acquired new range #%d for domain %s\n",
 			  domainnum, sidstr));
 	}
@@ -121,17 +117,14 @@ static NTSTATUS idmap_autorid_get_domainrange(struct db_context *db,
 	DEBUG(10, ("Using range #%d for domain %s\n", domainnum, sidstr));
 	cfg->domainnum = domainnum;
 
-	talloc_free(sidstr);
 	return NT_STATUS_OK;
 
       error:
-	talloc_free(sidstr);
 	return ret;
 
 }
 
-static NTSTATUS idmap_autorid_id_to_sid(TALLOC_CTX * memctx,
-					struct autorid_global_config *cfg,
+static NTSTATUS idmap_autorid_id_to_sid(struct autorid_global_config *cfg,
 					struct id_map *map)
 {
 	uint32_t range;
@@ -157,30 +150,34 @@ static NTSTATUS idmap_autorid_id_to_sid(TALLOC_CTX * memctx,
 	/* determine the range of this uid */
 	range = ((map->xid.id - cfg->minvalue) / cfg->rangesize);
 
-	keystr = talloc_asprintf(memctx, "%u", range);
+	keystr = talloc_asprintf(talloc_tos(), "%u", range);
 	if (!keystr) {
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	data = dbwrap_fetch_bystring(autorid_db, memctx, keystr);
+	data = dbwrap_fetch_bystring(autorid_db, talloc_tos(), keystr);
+	TALLOC_FREE(keystr);
 
 	if (!data.dptr) {
 		DEBUG(4, ("id %d belongs to range %d which does not have "
 			  "domain mapping, ignoring mapping request\n",
 			  map->xid.id, range));
-	} else {
-		string_to_sid(&sid, (const char *)data.dptr);
+		map->status = ID_UNKNOWN;
+		return NT_STATUS_OK;
+	}
 
-		sid_compose(map->sid, &sid,
-			    (map->xid.id - cfg->minvalue -
-			     range * cfg->rangesize));
+	string_to_sid(&sid, (const char *)data.dptr);
+	TALLOC_FREE(data.dptr);
 
-		/* We **really** should have some way of validating
-		   the SID exists and is the correct type here.  But
-		   that is a deficiency in the idmap_rid design. */
+	sid_compose(map->sid, &sid,
+		    (map->xid.id - cfg->minvalue -
+		     range * cfg->rangesize));
 
-		map->status = ID_MAPPED;
-	}
+	/* We **really** should have some way of validating
+	   the SID exists and is the correct type here.  But
+	   that is a deficiency in the idmap_rid design. */
+
+	map->status = ID_MAPPED;
 	return NT_STATUS_OK;
 }
 
@@ -188,8 +185,7 @@ static NTSTATUS idmap_autorid_id_to_sid(TALLOC_CTX * memctx,
  Single sid to id lookup function.
 **********************************/
 
-static NTSTATUS idmap_autorid_sid_to_id(TALLOC_CTX * memctx,
-					struct autorid_global_config *global,
+static NTSTATUS idmap_autorid_sid_to_id(struct autorid_global_config *global,
 					struct autorid_domain_config *domain,
 					struct id_map *map)
 {
@@ -224,7 +220,6 @@ static NTSTATUS idmap_autorid_unixids_to_sids(struct idmap_domain *dom,
 					      struct id_map **ids)
 {
 	struct autorid_global_config *globalcfg;
-	TALLOC_CTX *ctx;
 	NTSTATUS ret;
 	int i;
 
@@ -236,15 +231,9 @@ static NTSTATUS idmap_autorid_unixids_to_sids(struct idmap_domain *dom,
 	globalcfg = talloc_get_type(dom->private_data,
 				    struct autorid_global_config);
 
-	ctx = talloc_new(dom);
-	if (!ctx) {
-		DEBUG(0, ("Out of memory!\n"));
-		return NT_STATUS_NO_MEMORY;
-	}
-
 	for (i = 0; ids[i]; i++) {
 
-		ret = idmap_autorid_id_to_sid(ctx, globalcfg, ids[i]);
+		ret = idmap_autorid_id_to_sid(globalcfg, ids[i]);
 
 		if ((!NT_STATUS_IS_OK(ret)) &&
 		    (!NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED))) {
@@ -254,14 +243,10 @@ static NTSTATUS idmap_autorid_unixids_to_sids(struct idmap_domain *dom,
 			goto failure;
 		}
 	}
-
-	talloc_free(ctx);
 	return NT_STATUS_OK;
 
       failure:
-	talloc_free(ctx);
 	return ret;
-
 }
 
 /**********************************
@@ -272,29 +257,9 @@ static NTSTATUS idmap_autorid_sids_to_unixids(struct idmap_domain *dom,
 					      struct id_map **ids)
 {
 	struct autorid_global_config *global;
-	struct autorid_domain_config *domaincfg;
-	struct dom_sid *domainsid;
-	struct winbindd_tdc_domain *domain;
-	uint32_t rid;
-	TALLOC_CTX *ctx;
 	NTSTATUS ret;
 	int i;
 
-	ctx = talloc_new(dom);
-	domainsid = talloc(ctx, struct dom_sid);
-	if (!ctx || !domainsid) {
-		DEBUG(0, ("Out of memory!\n"));
-		ret = NT_STATUS_NO_MEMORY;
-		goto failure;
-	}
-
-	if ((domaincfg = TALLOC_ZERO_P(ctx,
-				       struct autorid_domain_config)) == NULL) {
-		DEBUG(0, ("Out of memory!\n"));
-		ret = NT_STATUS_NO_MEMORY;
-		goto failure;
-	}
-
 	/* initialize the status to avoid surprise */
 	for (i = 0; ids[i]; i++) {
 		ids[i]->status = ID_UNKNOWN;
@@ -304,28 +269,37 @@ static NTSTATUS idmap_autorid_sids_to_unixids(struct idmap_domain *dom,
 				 struct autorid_global_config);
 
 	for (i = 0; ids[i]; i++) {
-		ZERO_STRUCTP(domainsid);
-		sid_copy(domainsid, ids[i]->sid);
-		if (!sid_split_rid(domainsid, &rid)) {
+		struct winbindd_tdc_domain *domain;
+		struct autorid_domain_config domaincfg;
+		uint32_t rid;
+
+		ZERO_STRUCT(domaincfg);
+
+		sid_copy(&domaincfg.sid, ids[i]->sid);
+		if (!sid_split_rid(&domaincfg.sid, &rid)) {
 			DEBUG(4, ("Could not determine domain SID from %s, "
 				  "ignoring mapping request\n",
 				  sid_string_dbg(ids[i]->sid)));
 			continue;
 		}
 
-		domain = wcache_tdc_fetch_domainbysid(ctx, domainsid);
+		/*
+		 * Check if the domain is around
+		 */
+		domain = wcache_tdc_fetch_domainbysid(talloc_tos(),
+						      &domaincfg.sid);
 		if (domain == NULL) {
 			DEBUG(10, ("Ignoring unknown domain sid %s\n",
-				   sid_string_dbg(domainsid)));
+				   sid_string_dbg(&domaincfg.sid)));
 			continue;
 		}
+		TALLOC_FREE(domain);
 
-		ZERO_STRUCTP(domaincfg);
-		domaincfg->sid = domain->sid;
-		domaincfg->globalcfg = global;
+		domaincfg.globalcfg = global;
 
-		ret = dbwrap_trans_do(autorid_db, idmap_autorid_get_domainrange,
-				      domaincfg);
+		ret = dbwrap_trans_do(autorid_db,
+				      idmap_autorid_get_domainrange,
+				      &domaincfg);
 
 		if (!NT_STATUS_IS_OK(ret)) {
 			DEBUG(3, ("Could not determine range for domain, "
@@ -333,7 +307,7 @@ static NTSTATUS idmap_autorid_sids_to_unixids(struct idmap_domain *dom,
 			goto failure;
 		}
 
-		ret = idmap_autorid_sid_to_id(ctx, global, domaincfg, ids[i]);
+		ret = idmap_autorid_sid_to_id(global, &domaincfg, ids[i]);
 
 		if ((!NT_STATUS_IS_OK(ret)) &&
 		    (!NT_STATUS_EQUAL(ret, NT_STATUS_NONE_MAPPED))) {
@@ -343,12 +317,9 @@ static NTSTATUS idmap_autorid_sids_to_unixids(struct idmap_domain *dom,
 			goto failure;
 		}
 	}
-
-	talloc_free(ctx);
 	return NT_STATUS_OK;
 
       failure:
-	talloc_free(ctx);
 	return ret;
 
 }


-- 
Samba Shared Repository


More information about the samba-cvs mailing list