From 9acc670541031414d0cb5df39d18866c4c96b37c Mon Sep 17 00:00:00 2001 From: Bo Yang Date: Thu, 23 Jul 2009 10:23:21 +0800 Subject: s3: To correctly handle upn lookupname failed, cannot find domain when attempt to change password. This addresses bug #6560. Signed-off-by: Bo Yang --- nsswitch/pam_winbind.c | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'nsswitch') diff --git a/nsswitch/pam_winbind.c b/nsswitch/pam_winbind.c index e90f1b75ad6..4a44248e8ea 100644 --- a/nsswitch/pam_winbind.c +++ b/nsswitch/pam_winbind.c @@ -2284,6 +2284,7 @@ static char* winbind_upn_to_username(struct pwb_context *ctx, enum wbcSidType type; char *domain; char *name; + char *p; /* This cannot work when the winbind separator = @ */ @@ -2292,9 +2293,19 @@ static char* winbind_upn_to_username(struct pwb_context *ctx, return NULL; } + name = talloc_strdup(ctx, upn); + if (!name) { + return NULL; + } + + if ((p = strchr(name, '@')) != NULL) { + *p = 0; + domain = p + 1; + } + /* Convert the UPN to a SID */ - wbc_status = wbcLookupName("", upn, &sid, &type); + wbc_status = wbcLookupName(domain, name, &sid, &type); if (!WBC_ERROR_IS_OK(wbc_status)) { return NULL; } -- cgit