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

Simo Sorce idra at samba.org
Sun Jul 13 01:43:42 GMT 2008


The branch, v3-3-test has been updated
       via  4436272dd4d6cdd223b1dc3d217a97cbe3bc887b (commit)
       via  657a2f20dd4d422d45d7e054f463641cdff16816 (commit)
       via  2adea093c5709e128bdde1e37c6a897db7cbc3b1 (commit)
       via  e113b7c13f2457676fdec9e52f09046286e25b60 (commit)
      from  1dfb9242d1b6000d4b75327adf1a0a0882f3ea6c (commit)

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


- Log -----------------------------------------------------------------
commit 4436272dd4d6cdd223b1dc3d217a97cbe3bc887b
Author: Simo Sorce <idra at samba.org>
Date:   Sat Jul 12 21:28:18 2008 -0400

    Fix regression introduced with 4086ef15b395f1a536fb669af2103a33ecc14de4
    We must not return an error here just because we are offline.
    We must instead fix the mappings to the best of our knowledge
    (ie mark as mapped, expired ones, and as unmapped, unknown ones)

commit 657a2f20dd4d422d45d7e054f463641cdff16816
Author: Simo Sorce <idra at samba.org>
Date:   Sat Jul 12 21:23:16 2008 -0400

    Remove one nested level by reversing if condition

commit 2adea093c5709e128bdde1e37c6a897db7cbc3b1
Author: Simo Sorce <idra at samba.org>
Date:   Sat Jul 12 21:13:44 2008 -0400

    Add back mem leak fixes

commit e113b7c13f2457676fdec9e52f09046286e25b60
Author: Simo Sorce <idra at samba.org>
Date:   Sat Jul 12 21:13:05 2008 -0400

    Make again idmap_init static

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

Summary of changes:
 source/include/proto.h  |    1 -
 source/winbindd/idmap.c |  146 +++++++++++++++++++++++------------------------
 2 files changed, 72 insertions(+), 75 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/include/proto.h b/source/include/proto.h
index 2a5d21d..9958c91 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -10484,7 +10484,6 @@ NTSTATUS smb_register_idmap_alloc(int version, const char *name,
 				  struct idmap_alloc_methods *methods);
 NTSTATUS idmap_close(void);
 NTSTATUS idmap_init_cache(void);
-NTSTATUS idmap_init(void);
 NTSTATUS idmap_allocate_uid(struct unixid *id);
 NTSTATUS idmap_allocate_gid(struct unixid *id);
 NTSTATUS idmap_set_uid_hwm(struct unixid *id);
diff --git a/source/winbindd/idmap.c b/source/winbindd/idmap.c
index 8b16f27..95ff923 100644
--- a/source/winbindd/idmap.c
+++ b/source/winbindd/idmap.c
@@ -149,11 +149,13 @@ NTSTATUS smb_register_idmap(int version, const char *name,
 	entry = talloc(idmap_ctx, struct idmap_backend);
 	if ( ! entry) {
 		DEBUG(0,("Out of memory!\n"));
+		TALLOC_FREE(entry);
 		return NT_STATUS_NO_MEMORY;
 	}
 	entry->name = talloc_strdup(idmap_ctx, name);
 	if ( ! entry->name) {
 		DEBUG(0,("Out of memory!\n"));
+		TALLOC_FREE(entry);
 		return NT_STATUS_NO_MEMORY;
 	}
 	entry->methods = methods;
@@ -277,7 +279,7 @@ NTSTATUS idmap_init_cache(void)
 /****************************************************************************
  ****************************************************************************/
 
-NTSTATUS idmap_init(void)
+static NTSTATUS idmap_init(void)
 {
 	NTSTATUS ret;
 	static NTSTATUS idmap_init_status = NT_STATUS_UNSUCCESSFUL;
@@ -1322,55 +1324,53 @@ NTSTATUS idmap_unixids_to_sids(struct id_map **ids)
 
 		ret = idmap_cache_map_id(idmap_cache, ids[i]);
 
-		if ( ! NT_STATUS_IS_OK(ret)) {
+		if (NT_STATUS_IS_OK(ret)) continue;
 
+		if ( ! bids) {
+			/* alloc space for ids to be resolved by
+			 * backends (realloc ten by ten) */
+			bids = TALLOC_ARRAY(ctx, struct id_map *, 10);
 			if ( ! bids) {
-				/* alloc space for ids to be resolved by
-				 * backends (realloc ten by ten) */
-				bids = TALLOC_ARRAY(ctx, struct id_map *, 10);
-				if ( ! bids) {
-					DEBUG(1, ("Out of memory!\n"));
-					talloc_free(ctx);
-					return NT_STATUS_NO_MEMORY;
-				}
-				bn = 10;
+				DEBUG(1, ("Out of memory!\n"));
+				talloc_free(ctx);
+				return NT_STATUS_NO_MEMORY;
 			}
+			bn = 10;
+		}
 
-			/* add this id to the ones to be retrieved
-			 * from the backends */
-			bids[bi] = ids[i];
-			bi++;
-
-			/* check if we need to allocate new space
-			 *  on the rids array */
-			if (bi == bn) {
-				bn += 10;
-				bids = talloc_realloc(ctx, bids,
-						      struct id_map *, bn);
-				if ( ! bids) {
-					DEBUG(1, ("Out of memory!\n"));
-					talloc_free(ctx);
-					return NT_STATUS_NO_MEMORY;
-				}
-			}
+		/* add this id to the ones to be retrieved
+		 * from the backends */
+		bids[bi] = ids[i];
+		bi++;
 
-			/* make sure the last element is NULL */
-			bids[bi] = NULL;
+		/* check if we need to allocate new space
+		 *  on the rids array */
+		if (bi == bn) {
+			bn += 10;
+			bids = talloc_realloc(ctx, bids, struct id_map *, bn);
+			if ( ! bids) {
+				DEBUG(1, ("Out of memory!\n"));
+				talloc_free(ctx);
+				return NT_STATUS_NO_MEMORY;
+			}
 		}
+
+		/* make sure the last element is NULL */
+		bids[bi] = NULL;
 	}
 
 	/* let's see if there is any id mapping to be retrieved
 	 * from the backends */
-	if (bi) {
+	if (bids) {
+		bool online;
+
 		/* Only do query if we are online */
-		if ( IS_DOMAIN_OFFLINE(our_domain) ) {
-			ret = NT_STATUS_FILE_IS_OFFLINE;
-			goto done;
+		online = !IS_DOMAIN_OFFLINE(our_domain);
+		if (online) {
+			ret = idmap_backends_unixids_to_sids(bids);
+			IDMAP_CHECK_RET(ret);
 		}
 
-		ret = idmap_backends_unixids_to_sids(bids);
-		IDMAP_CHECK_RET(ret);
-
 		/* update the cache */
 		for (i = 0; i < bi; i++) {
 			if (bids[i]->status == ID_MAPPED) {
@@ -1388,7 +1388,7 @@ NTSTATUS idmap_unixids_to_sids(struct id_map **ids)
 				 * unmapped and hope next time things will
 				 * settle down. */
 				bids[i]->status = ID_UNMAPPED;
-			} else { /* unmapped */
+			} else if (online) { /* unmapped */
 				ret = idmap_cache_set_negative_id(idmap_cache,
 								  bids[i]);
 			}
@@ -1440,55 +1440,53 @@ NTSTATUS idmap_sids_to_unixids(struct id_map **ids)
 
 		ret = idmap_cache_map_sid(idmap_cache, ids[i]);
 
-		if ( ! NT_STATUS_IS_OK(ret)) {
+		if (NT_STATUS_IS_OK(ret)) continue;
 
+		if ( ! bids) {
+			/* alloc space for ids to be resolved
+			   by backends (realloc ten by ten) */
+			bids = TALLOC_ARRAY(ctx, struct id_map *, 10);
 			if ( ! bids) {
-				/* alloc space for ids to be resolved
-				   by backends (realloc ten by ten) */
-				bids = TALLOC_ARRAY(ctx, struct id_map *, 10);
-				if ( ! bids) {
-					DEBUG(1, ("Out of memory!\n"));
-					talloc_free(ctx);
-					return NT_STATUS_NO_MEMORY;
-				}
-				bn = 10;
+				DEBUG(1, ("Out of memory!\n"));
+				talloc_free(ctx);
+				return NT_STATUS_NO_MEMORY;
 			}
+			bn = 10;
+		}
 
-			/* add this id to the ones to be retrieved
-			 * from the backends */
-			bids[bi] = ids[i];
-			bi++;
-
-			/* check if we need to allocate new space
-			 * on the ids array */
-			if (bi == bn) {
-				bn += 10;
-				bids = talloc_realloc(ctx, bids,
-						      struct id_map *, bn);
-				if ( ! bids) {
-					DEBUG(1, ("Out of memory!\n"));
-					talloc_free(ctx);
-					return NT_STATUS_NO_MEMORY;
-				}
-			}
+		/* add this id to the ones to be retrieved
+		 * from the backends */
+		bids[bi] = ids[i];
+		bi++;
 
-			/* make sure the last element is NULL */
-			bids[bi] = NULL;
+		/* check if we need to allocate new space
+		 * on the ids array */
+		if (bi == bn) {
+			bn += 10;
+			bids = talloc_realloc(ctx, bids, struct id_map *, bn);
+			if ( ! bids) {
+				DEBUG(1, ("Out of memory!\n"));
+				talloc_free(ctx);
+				return NT_STATUS_NO_MEMORY;
+			}
 		}
+
+		/* make sure the last element is NULL */
+		bids[bi] = NULL;
 	}
 
 	/* let's see if there is any id mapping to be retrieved
 	 * from the backends */
 	if (bids) {
+		bool online;
+
 		/* Only do query if we are online */
-		if ( IS_DOMAIN_OFFLINE(our_domain) ) {
-			ret = NT_STATUS_FILE_IS_OFFLINE;
-			goto done;
+		online = !IS_DOMAIN_OFFLINE(our_domain);
+		if (online) {
+			ret = idmap_backends_sids_to_unixids(bids);
+			IDMAP_CHECK_RET(ret);
 		}
 
-		ret = idmap_backends_sids_to_unixids(bids);
-		IDMAP_CHECK_RET(ret);
-
 		/* update the cache */
 		for (i = 0; bids[i]; i++) {
 			if (bids[i]->status == ID_MAPPED) {
@@ -1506,7 +1504,7 @@ NTSTATUS idmap_sids_to_unixids(struct id_map **ids)
 				 * unmapped and hope next time things will
 				 * settle down. */
 				bids[i]->status = ID_UNMAPPED;
-			} else { /* unmapped */
+			} else if (online) { /* unmapped */
 				ret = idmap_cache_set_negative_sid(idmap_cache,
 								   bids[i]);
 			}


-- 
Samba Shared Repository


More information about the samba-cvs mailing list