[SCM] Samba Shared Repository - branch v4-0-test updated

Karolin Seeger kseeger at samba.org
Fri Apr 12 03:45:05 MDT 2013


The branch, v4-0-test has been updated
       via  86dbc31 BUG 9766: Cache name_to_sid/sid_to_name correctly.
       via  09758ce BUG 9139: Fix the username map optimization.
      from  4bebda4 [PATCH] getpass: Don't fail if stdin is not a tty

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


- Log -----------------------------------------------------------------
commit 86dbc3121f2e028604272309a4b1c41d51122aeb
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
    
    Autobuild-User(v4-0-test): Karolin Seeger <kseeger at samba.org>
    Autobuild-Date(v4-0-test): Fri Apr 12 11:44:46 CEST 2013 on sn-devel-104

commit 09758ceaa8fa82146a71fcc1afee57d41a460d7c
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 6ae46db..8b2e6a9 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);
@@ -1789,6 +1806,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