[SCM] Samba Shared Repository - branch v3-devel updated - release-3-2-0pre2-3961-g74c8575

Simo Sorce idra at samba.org
Wed Sep 3 18:27:05 GMT 2008


The branch, v3-devel has been updated
       via  74c8575b3f3b90ea21ae6aa7ccd95947838af956 (commit)
       via  8e4dca3b9416d9b5e535bda5e4befc073bfc1641 (commit)
       via  e038f1cf9fb305fc1e7a4189208e451d30aaa1f0 (commit)
       via  8594edf666c29fd4ddf1780da842683dd81483b6 (commit)
      from  32cb45c962c822bd79a7d0f666f2f6037060b324 (commit)

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


- Log -----------------------------------------------------------------
commit 74c8575b3f3b90ea21ae6aa7ccd95947838af956
Author: Simo Sorce <idra at samba.org>
Date:   Wed Sep 3 10:44:09 2008 -0400

    The msync manpage reports that msync *must* be called before munmap. Failure to do so may result in lost data. Fix an ifdef check, I really think we meant to check HAVE_MMAP here.

commit 8e4dca3b9416d9b5e535bda5e4befc073bfc1641
Merge: e038f1cf9fb305fc1e7a4189208e451d30aaa1f0 32cb45c962c822bd79a7d0f666f2f6037060b324
Author: Simo Sorce <idra at samba.org>
Date:   Wed Sep 3 11:52:54 2008 -0400

    Merge branch 'v3-devel' of ssh://git.samba.org/data/git/samba into v3-devel

commit e038f1cf9fb305fc1e7a4189208e451d30aaa1f0
Merge: 8594edf666c29fd4ddf1780da842683dd81483b6 566d3b6e76afeca8e862cb36202a5283b86920e4
Author: Simo Sorce <idra at samba.org>
Date:   Tue Aug 26 18:56:49 2008 -0400

    Merge branch 'v3-devel' of ssh://git.samba.org/data/git/samba into v3-devel

commit 8594edf666c29fd4ddf1780da842683dd81483b6
Author: Simo Sorce <idra at samba.org>
Date:   Sun Aug 17 19:54:41 2008 -0400

    Split lookup_name() and create a new functiong called
    lookup_domain_name(). This new function accept separated
    strings for domain and name.

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

Summary of changes:
 source/auth/auth_util.c             |   17 +---
 source/auth/token_util.c            |    7 +-
 source/include/proto.h              |    4 +
 source/lib/tdb/common/io.c          |    8 ++-
 source/lib/tdb/common/transaction.c |    2 +-
 source/passdb/lookup_sid.c          |  171 +++++++++++++++++++----------------
 source/winbindd/winbindd_passdb.c   |   28 +++---
 7 files changed, 125 insertions(+), 112 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source/auth/auth_util.c b/source/auth/auth_util.c
index 9220df0..5b2c304 100644
--- a/source/auth/auth_util.c
+++ b/source/auth/auth_util.c
@@ -1086,7 +1086,6 @@ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info,
 	NTSTATUS status;
 	struct samu *sampass = NULL;
 	gid_t *gids;
-	char *qualified_name = NULL;
 	TALLOC_CTX *mem_ctx = NULL;
 	DOM_SID u_sid;
 	enum lsa_SidType type;
@@ -1152,18 +1151,10 @@ NTSTATUS make_server_info_pw(auth_serversupplied_info **server_info,
 		return NT_STATUS_NO_MEMORY;
 	}
 
-	qualified_name = talloc_asprintf(mem_ctx, "%s\\%s",
-					unix_users_domain_name(),
-					unix_username );
-	if (!qualified_name) {
-		TALLOC_FREE(result);
-		TALLOC_FREE(mem_ctx);
-		return NT_STATUS_NO_MEMORY;
-	}
-
-	if (!lookup_name(mem_ctx, qualified_name, LOOKUP_NAME_ALL,
-						NULL, NULL,
-						&u_sid, &type)) {
+	if (!lookup_domain_name(mem_ctx,
+				unix_users_domain_name(), unix_username,
+				LOOKUP_NAME_ALL,
+				NULL, NULL, &u_sid, &type)) {
 		TALLOC_FREE(result);
 		TALLOC_FREE(mem_ctx);
 		return NT_STATUS_NO_SUCH_USER;
diff --git a/source/auth/token_util.c b/source/auth/token_util.c
index d6cd2ea..2b55af7 100644
--- a/source/auth/token_util.c
+++ b/source/auth/token_util.c
@@ -291,7 +291,6 @@ NTSTATUS create_builtin_administrators(const DOM_SID *dom_sid)
 {
 	NTSTATUS status;
 	DOM_SID dom_admins, root_sid;
-	fstring root_name;
 	enum lsa_SidType type;
 	TALLOC_CTX *ctx;
 	bool ret;
@@ -317,9 +316,9 @@ NTSTATUS create_builtin_administrators(const DOM_SID *dom_sid)
 	if ( (ctx = talloc_init("create_builtin_administrators")) == NULL ) {
 		return NT_STATUS_NO_MEMORY;
 	}
-	fstr_sprintf( root_name, "%s\\root", get_global_sam_name() );
-	ret = lookup_name(ctx, root_name, LOOKUP_NAME_DOMAIN, NULL, NULL,
-			  &root_sid, &type);
+	ret = lookup_domain_name(ctx, get_global_sam_name(), "root",
+				 LOOKUP_NAME_DOMAIN,
+				 NULL, NULL, &root_sid, &type);
 	TALLOC_FREE( ctx );
 
 	if ( ret ) {
diff --git a/source/include/proto.h b/source/include/proto.h
index 291afac..a81375c 100644
--- a/source/include/proto.h
+++ b/source/include/proto.h
@@ -6199,6 +6199,10 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 		 const char *full_name, int flags,
 		 const char **ret_domain, const char **ret_name,
 		 DOM_SID *ret_sid, enum lsa_SidType *ret_type);
+bool lookup_domain_name(TALLOC_CTX *mem_ctx,
+		 const char *domain, const char *name, int flags,
+		 const char **ret_domain, const char **ret_name,
+		 DOM_SID *ret_sid, enum lsa_SidType *ret_type);
 bool lookup_name_smbconf(TALLOC_CTX *mem_ctx,
 		 const char *full_name, int flags,
 		 const char **ret_domain, const char **ret_name,
diff --git a/source/lib/tdb/common/io.c b/source/lib/tdb/common/io.c
index 172ab69..4ec18de 100644
--- a/source/lib/tdb/common/io.c
+++ b/source/lib/tdb/common/io.c
@@ -189,7 +189,13 @@ int tdb_munmap(struct tdb_context *tdb)
 
 #ifdef HAVE_MMAP
 	if (tdb->map_ptr) {
-		int ret = munmap(tdb->map_ptr, tdb->map_size);
+		int ret;
+
+		ret = msync(tdb->map_ptr, tdb->map_size, MS_SYNC);
+		if (ret != 0)
+			return ret;
+
+		ret = munmap(tdb->map_ptr, tdb->map_size);
 		if (ret != 0)
 			return ret;
 	}
diff --git a/source/lib/tdb/common/transaction.c b/source/lib/tdb/common/transaction.c
index 4e2127b..7acda64 100644
--- a/source/lib/tdb/common/transaction.c
+++ b/source/lib/tdb/common/transaction.c
@@ -563,7 +563,7 @@ static int transaction_sync(struct tdb_context *tdb, tdb_off_t offset, tdb_len_t
 		TDB_LOG((tdb, TDB_DEBUG_FATAL, "tdb_transaction: fsync failed\n"));
 		return -1;
 	}
-#ifdef MS_SYNC
+#ifdef HAVE_MMAP
 	if (tdb->map_ptr) {
 		tdb_off_t moffset = offset & ~(tdb->page_size-1);
 		if (msync(moffset + (char *)tdb->map_ptr, 
diff --git a/source/passdb/lookup_sid.c b/source/passdb/lookup_sid.c
index 3861c8e..9813101 100644
--- a/source/passdb/lookup_sid.c
+++ b/source/passdb/lookup_sid.c
@@ -29,44 +29,72 @@
  to do guesswork.
 *****************************************************************/  
 
+#define LN_CHECK_TALLOC(var, memctx) do { \
+	if (var == NULL) { \
+		DEBUG(0, ("talloc failed\n")); \
+		TALLOC_FREE(memctx); \
+		return false; \
+	} \
+} while(0)
+
 bool lookup_name(TALLOC_CTX *mem_ctx,
 		 const char *full_name, int flags,
 		 const char **ret_domain, const char **ret_name,
 		 DOM_SID *ret_sid, enum lsa_SidType *ret_type)
 {
+	char *domain, *name;
+	bool res;
 	char *p;
-	const char *tmp;
-	const char *domain = NULL;
-	const char *name = NULL;
-	uint32 rid;
-	DOM_SID sid;
-	enum lsa_SidType type;
-	TALLOC_CTX *tmp_ctx = talloc_new(mem_ctx);
-
-	if (tmp_ctx == NULL) {
-		DEBUG(0, ("talloc_new failed\n"));
-		return false;
-	}
 
 	p = strchr_m(full_name, '\\');
 
 	if (p != NULL) {
-		domain = talloc_strndup(tmp_ctx, full_name,
+		domain = talloc_strndup(mem_ctx, full_name,
 					PTR_DIFF(p, full_name));
-		name = talloc_strdup(tmp_ctx, p+1);
+		name = talloc_strdup(mem_ctx, p+1);
 	} else {
-		domain = talloc_strdup(tmp_ctx, "");
-		name = talloc_strdup(tmp_ctx, full_name);
+		domain = NULL;
+		name = talloc_strdup(mem_ctx, full_name);
 	}
 
-	if ((domain == NULL) || (name == NULL)) {
+	if (((p != NULL) && (domain == NULL)) || (name == NULL)) {
 		DEBUG(0, ("talloc failed\n"));
-		TALLOC_FREE(tmp_ctx);
 		return false;
 	}
 
-	DEBUG(10,("lookup_name: %s => %s (domain), %s (name)\n",
-		full_name, domain, name));
+	DEBUG(10,("lookup_domain_name: %s => %s (domain), %s (name)\n",
+		  full_name, domain, name));
+
+	res = lookup_domain_name(mem_ctx, domain, name, flags,
+				 ret_domain, ret_name, ret_sid, ret_type);
+
+	talloc_free(domain);
+	talloc_free(name);
+
+	return res;
+}
+
+bool lookup_domain_name(TALLOC_CTX *mem_ctx,
+		 const char *domain, const char *name, int flags,
+		 const char **ret_domain, const char **ret_name,
+		 DOM_SID *ret_sid, enum lsa_SidType *ret_type)
+{
+	const char *tmp;
+	const char *domain_new = NULL;
+	uint32 rid;
+	DOM_SID sid;
+	enum lsa_SidType type;
+	TALLOC_CTX *tmp_ctx;
+
+	tmp_ctx = talloc_new(mem_ctx);
+	if (tmp_ctx == NULL) {
+		DEBUG(0, ("talloc_new failed\n"));
+		return false;
+	}
+
+	if (!domain) domain = talloc_strdup(tmp_ctx, "");
+	LN_CHECK_TALLOC(domain, tmp_ctx);
+
 	DEBUG(10, ("lookup_name: flags = 0x0%x\n", flags));
 
 	if ((flags & LOOKUP_NAME_DOMAIN) &&
@@ -98,7 +126,7 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 	}
 
 	/* Try the explicit winbind lookup first, don't let it guess the
-	 * domain yet at this point yet. This comes later. */
+	 * domain at this point yet. This comes later. */
 
 	if ((domain[0] != '\0') &&
 	    (flags & ~(LOOKUP_NAME_DOMAIN|LOOKUP_NAME_ISOLATED)) &&
@@ -137,9 +165,10 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 	/* 1. well-known names */
 
 	if ((flags & LOOKUP_NAME_WKN) &&
-	    lookup_wellknown_name(tmp_ctx, name, &sid, &domain))
+	    lookup_wellknown_name(tmp_ctx, name, &sid, &domain_new))
 	{
 		type = SID_NAME_WKN_GRP;
+		LN_CHECK_TALLOC(domain_new, tmp_ctx);
 		goto ok;
 	}
 
@@ -199,12 +228,13 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 		goto ok;
 	}
 
-	/* 6. Builtin aliases */	
+	/* 6. Builtin aliases */
 
 	if ((flags & LOOKUP_NAME_BUILTIN) &&
 	    lookup_builtin_name(name, &rid))
 	{
-		domain = talloc_strdup(tmp_ctx, builtin_domain_name());
+		domain_new = talloc_strdup(tmp_ctx, builtin_domain_name());
+		LN_CHECK_TALLOC(domain_new, tmp_ctx);
 		sid_copy(&sid, &global_sid_Builtin);
 		sid_append_rid(&sid, rid);
 		type = SID_NAME_ALIAS;
@@ -219,7 +249,8 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 	if ((flags & LOOKUP_NAME_DOMAIN) &&
 	    lookup_global_sam_name(name, flags, &rid, &type))
 	{
-		domain = talloc_strdup(tmp_ctx, get_global_sam_name());
+		domain_new = talloc_strdup(tmp_ctx, get_global_sam_name());
+		LN_CHECK_TALLOC(domain_new, tmp_ctx);
 		sid_copy(&sid, get_global_sam_sid());
 		sid_append_rid(&sid, rid);
 		goto ok;
@@ -237,7 +268,8 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 
 	if (!IS_DC &&
 	    (winbind_lookup_name(lp_workgroup(), name, &sid, &type))) {
-		domain = talloc_strdup(tmp_ctx, lp_workgroup());
+		domain_new = talloc_strdup(tmp_ctx, lp_workgroup());
+		LN_CHECK_TALLOC(domain_new, tmp_ctx);
 		goto ok;
 	}
 
@@ -250,7 +282,7 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 		DOM_SID dom_sid;
 		uint32 tmp_rid;
 		enum lsa_SidType domain_type;
-		
+
 		if (type == SID_NAME_DOMAIN) {
 			/* Swap name and type */
 			tmp = name; name = domain; domain = tmp;
@@ -272,6 +304,7 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 			TALLOC_FREE(tmp_ctx);
 			return false;
 		}
+		LN_CHECK_TALLOC(domain_new, tmp_ctx);
 		goto ok;
 	}
 
@@ -281,13 +314,15 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
                Unmapped users and unmapped groups */
 
 	if (!(flags & LOOKUP_NAME_EXPLICIT) && lookup_unix_user_name(name, &sid)) {
-		domain = talloc_strdup(tmp_ctx, unix_users_domain_name());
+		domain_new = talloc_strdup(tmp_ctx, unix_users_domain_name());
+		LN_CHECK_TALLOC(domain_new, tmp_ctx);
 		type = SID_NAME_USER;
 		goto ok;
 	}
 
 	if (!(flags & LOOKUP_NAME_EXPLICIT) && lookup_unix_group_name(name, &sid)) {
-		domain = talloc_strdup(tmp_ctx, unix_groups_domain_name());
+		domain_new = talloc_strdup(tmp_ctx, unix_groups_domain_name());
+		LN_CHECK_TALLOC(domain_new, tmp_ctx);
 		type = SID_NAME_DOM_GRP;
 		goto ok;
 	}
@@ -300,12 +335,6 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 	return false;
 
  ok:
-	if ((domain == NULL) || (name == NULL)) {
-		DEBUG(0, ("talloc failed\n"));
-		TALLOC_FREE(tmp_ctx);
-		return false;
-	}
-
 	/*
 	 * Hand over the results to the talloc context we've been given.
 	 */
@@ -319,11 +348,14 @@ bool lookup_name(TALLOC_CTX *mem_ctx,
 
 	if (ret_domain != NULL) {
 		char *tmp_dom;
-		if (!(tmp_dom = talloc_strdup(mem_ctx, domain))) {
-			DEBUG(0, ("talloc failed\n"));
-			TALLOC_FREE(tmp_ctx);
-			return false;
+
+		if (domain_new) {
+			tmp_dom = talloc_steal(mem_ctx, (char *)domain_new);
+		} else {
+			tmp_dom = talloc_strdup(mem_ctx, domain);
 		}
+		LN_CHECK_TALLOC(tmp_dom, tmp_ctx);
+
 		strupper_m(tmp_dom);
 		*ret_domain = tmp_dom;
 	}
@@ -351,59 +383,42 @@ bool lookup_name_smbconf(TALLOC_CTX *mem_ctx,
 		 const char **ret_domain, const char **ret_name,
 		 DOM_SID *ret_sid, enum lsa_SidType *ret_type)
 {
-	char *qualified_name;
-	const char *p;
-
-	/* NB. No winbindd_separator here as lookup_name needs \\' */
-	if ((p = strchr_m(full_name, *lp_winbind_separator())) != NULL) {
-
-		/* The name is already qualified with a domain. */
-
-		if (*lp_winbind_separator() != '\\') {
-			char *tmp;
+	char *p;
 
-			/* lookup_name() needs '\\' as a separator */
+	p = strchr_m(full_name, *lp_winbind_separator());
+	if (p != NULL) {
+		char *name;
+		bool res;
 
-			tmp = talloc_strdup(mem_ctx, full_name);
-			if (!tmp) {
-				return false;
-			}
-			tmp[p - full_name] = '\\';
-			full_name = tmp;
+		name = talloc_strdup(mem_ctx, full_name);
+		if (!name) {
+			DEBUG(0, ("Out of memory!\n"));
+			return false;
 		}
+		name[PTR_DIFF(p, full_name)] = '\\';
 
-		return lookup_name(mem_ctx, full_name, flags,
-				ret_domain, ret_name,
-				ret_sid, ret_type);
+		res = lookup_name(mem_ctx, name, flags,
+				  ret_domain, ret_name,
+				  ret_sid, ret_type);
+		talloc_free(name);
+		return res;
 	}
 
 	/* Try with our own SAM name. */
-	qualified_name = talloc_asprintf(mem_ctx, "%s\\%s",
-				get_global_sam_name(),
-				full_name );
-	if (!qualified_name) {
-		return false;
-	}
-
-	if (lookup_name(mem_ctx, qualified_name, flags,
-				ret_domain, ret_name,
-				ret_sid, ret_type)) {
+	if (lookup_domain_name(mem_ctx,
+				get_global_sam_name(), full_name, flags,
+				ret_domain, ret_name, ret_sid, ret_type)) {
 		return true;
 	}
-	
+
 	/* Finally try with "Unix Users" or "Unix Group" */
-	qualified_name = talloc_asprintf(mem_ctx, "%s\\%s",
+	return lookup_domain_name(mem_ctx,
 				flags & LOOKUP_NAME_GROUP ?
 					unix_groups_domain_name() :
 					unix_users_domain_name(),
-				full_name );
-	if (!qualified_name) {
-		return false;
-	}
+				full_name, flags,
+				ret_domain, ret_name, ret_sid, ret_type);
 
-	return lookup_name(mem_ctx, qualified_name, flags,
-				ret_domain, ret_name,
-				ret_sid, ret_type);
 }
 
 static bool wb_lookup_rids(TALLOC_CTX *mem_ctx,
diff --git a/source/winbindd/winbindd_passdb.c b/source/winbindd/winbindd_passdb.c
index 5677c01..fbe4a27 100644
--- a/source/winbindd/winbindd_passdb.c
+++ b/source/winbindd/winbindd_passdb.c
@@ -94,8 +94,8 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
 			    DOM_SID *sid,
 			    enum lsa_SidType *type)
 {
-	const char *fullname;
 	uint32 flags = LOOKUP_NAME_ALL;
+	bool res;
 
 	switch ( original_cmd ) {
 	case WINBINDD_LOOKUPNAME:
@@ -107,28 +107,26 @@ static NTSTATUS name_to_sid(struct winbindd_domain *domain,
 		DEBUG(10,("winbindd_passdb: limiting name_to_sid() to explicit mappings\n"));
 		break;
 	}
-	
-	if (domain_name && domain_name[0] && strchr_m(name, '\\') == NULL) {
-		fullname = talloc_asprintf(mem_ctx, "%s\\%s",
-				domain_name, name);
-		if (fullname == NULL) {
-			return NT_STATUS_NO_MEMORY;
-		}
+
+	DEBUG(10, ("looking up name [%s\\%s] (domain\\name) \n",
+		   domain_name?domain_name:"(NULL)", name));
+
+	if (strchr_m(name, '\\')) {
+		res = lookup_name(mem_ctx, name, flags, NULL, NULL, sid, type);
 	} else {
-		fullname = name;
+		res = lookup_domain_name(mem_ctx, domain_name, name, flags,
+					 NULL, NULL, sid, type);
 	}
 
-	DEBUG(10, ("Finding fullname %s\n", fullname));
-
-	if ( !lookup_name( mem_ctx, fullname, flags, NULL, NULL, sid, type ) ) {
+	if (!res) {
 		return NT_STATUS_NONE_MAPPED;
 	}
 
-	DEBUG(10, ("name_to_sid for %s returned %s (%s)\n",
-		fullname,
+	DEBUG(10, ("name_to_sid for [%s\\%s] returned %s (%s)\n",
+		domain_name?domain_name:"(NULL)", name,
 		sid_string_dbg(sid),
 		sid_type_lookup((uint32)*type)));
-		
+
 	return NT_STATUS_OK;
 }
 


-- 
Samba Shared Repository


More information about the samba-cvs mailing list