[SCM] Samba Shared Repository - branch master updated

Günther Deschner gd at samba.org
Tue Apr 9 08:33:02 MDT 2013


The branch, master has been updated
       via  045c446 BUG 9766: Cache name_to_sid/sid_to_name correctly.
       via  b7c0330 BUG 9139: Fix the username map optimization.
      from  243278a doc: Document performance impact of "hide unxx" parameters

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


- Log -----------------------------------------------------------------
commit 045c446b5a3ffc7e56d46ac4aa4acae9d27d9f49
Author: Andreas Schneider <asn at samba.org>
Date:   Thu Apr 4 12:18:25 2013 +0200

    BUG 9766: Cache name_to_sid/sid_to_name correctly.
    
    If there is no domain_name specified we still need to set to for
    caching else we will not find the entry later if we lookup the entry
    with the domain_name.
    
    Reviewed-by: Guenther Deschner <gd at samba.org>
    Reviewed-by: Volker Lendecke <vl at samba.org>
    Signed-off-by: Andreas Schneider <asn at samba.org>
    
    Autobuild-User(master): Günther Deschner <gd at samba.org>
    Autobuild-Date(master): Tue Apr  9 16:32:44 CEST 2013 on sn-devel-104

commit b7c0330b7429ce1b9cda8b1c2446b3a21cbd29db
Author: Andreas Schneider <asn at samba.org>
Date:   Fri Apr 5 14:07:37 2013 +0200

    BUG 9139: Fix the username map optimization.
    
    If we successfully map a user. We call
    
    set_last_from_to(user_in, unixname);
    
    in the while loop reading the map file. After a successfull map we don't
    stop and continue the loop to check all other mappings in the username
    mapfile. But when we hit the end of the file and leave the loop we call:
    
    set_last_from_to(user_in, user_in);
    
    This overwrites the successful mapping, and the next time we call
    map_username() we skip the username and no mapping is done.
    
    Signed-off-by: Andreas Schneider <asn at samba.org>
    Reviewed-by: Günther Deschner <gd at samba.org>

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

Summary of changes:
 source3/auth/user_util.c          |   12 ++++++++----
 source3/winbindd/winbindd_cache.c |   21 +++++++++++++++++++++
 2 files changed, 29 insertions(+), 4 deletions(-)


Changeset truncated at 500 lines:

diff --git a/source3/auth/user_util.c b/source3/auth/user_util.c
index 4842192..082c885 100644
--- a/source3/auth/user_util.c
+++ b/source3/auth/user_util.c
@@ -427,12 +427,16 @@ bool map_username(TALLOC_CTX *ctx, const char *user_in, char **p_user_out)
 	x_fclose(f);
 
 	/*
-	 * Setup the last_from and last_to as an optimization so
+	 * If we didn't successfully map a user in the loop above,
+	 * setup the last_from and last_to as an optimization so
 	 * that we don't scan the file again for the same user.
 	 */
-
-	set_last_from_to(user_in, user_in);
-	store_map_in_gencache(ctx, user_in, user_in);
+	if (!mapped_user) {
+		DEBUG(8, ("The user '%s' has no mapping. "
+			  "Skip it next time.\n", user_in));
+		set_last_from_to(user_in, user_in);
+		store_map_in_gencache(ctx, user_in, user_in);
+	}
 
 	return mapped_user;
 }
diff --git a/source3/winbindd/winbindd_cache.c b/source3/winbindd/winbindd_cache.c
index d7499df..86f15c2 100644
--- a/source3/winbindd/winbindd_cache.c
+++ b/source3/winbindd/winbindd_cache.c
@@ -943,6 +943,15 @@ static void wcache_save_name_to_sid(struct winbindd_domain *domain,
 	centry = centry_start(domain, status);
 	if (!centry)
 		return;
+
+	if (domain_name[0] == '\0') {
+		struct winbindd_domain *mydomain =
+			find_domain_from_sid_noinit(sid);
+		if (mydomain != NULL) {
+			domain_name = mydomain->name;
+		}
+	}
+
 	centry_put_uint32(centry, type);
 	centry_put_sid(centry, sid);
 	fstrcpy(uname, name);
@@ -963,6 +972,14 @@ static void wcache_save_sid_to_name(struct winbindd_domain *domain, NTSTATUS sta
 	if (!centry)
 		return;
 
+	if (domain_name[0] == '\0') {
+		struct winbindd_domain *mydomain =
+			find_domain_from_sid_noinit(sid);
+		if (mydomain != NULL) {
+			domain_name = mydomain->name;
+		}
+	}
+
 	if (NT_STATUS_IS_OK(status)) {
 		centry_put_uint32(centry, type);
 		centry_put_string(centry, domain_name);
@@ -1793,6 +1810,10 @@ NTSTATUS wcache_name_to_sid(struct winbindd_domain *domain,
 		return NT_STATUS_NO_MEMORY;
 	}
 
+	if (domain_name[0] == '\0') {
+		domain_name = domain->name;
+	}
+
 	centry = wcache_fetch(cache, domain, "NS/%s/%s", domain_name, uname);
 	TALLOC_FREE(uname);
 	if (centry == NULL) {


-- 
Samba Shared Repository


More information about the samba-cvs mailing list