From: Christof Schmitt Date: Wed, 28 Feb 2018 19:05:34 +0000 (-0700) Subject: winbindd: Do not ignore domain in the LOOKUPNAME request X-Git-Tag: ldb-1.4.0~678 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=1775ac8aa4dc00b9a0845ade238254ebb8b32429;p=thirdparty%2Fsamba.git winbindd: Do not ignore domain in the LOOKUPNAME request A LOOKUPNAME request with a domain and a name containing a winbind separator character would return the result for the joined domain, instead of the specified domain. BUG: https://bugzilla.samba.org/show_bug.cgi?id=13312 Signed-off-by: Christof Schmitt Reviewed-by: Andreas Schneider Autobuild-User(master): Andreas Schneider Autobuild-Date(master): Fri Apr 6 21:03:31 CEST 2018 on sn-devel-144 --- diff --git a/selftest/knownfail b/selftest/knownfail index 6ef61dbcba2..a2aeed2690d 100644 --- a/selftest/knownfail +++ b/selftest/knownfail @@ -343,5 +343,3 @@ # Disabling NTLM means you can't use samr to change the password ^samba.tests.ntlmdisabled.python\(ktest\).ntlmdisabled.NtlmDisabledTests.test_samr_change_password\(ktest\) ^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\) -samba3.wbinfo_name_lookup.name-to-sid.double-separator\(ad_member\) -samba3.wbinfo_name_lookup.name-to-sid.double-separator-invalid-domain\(ad_member\) diff --git a/source3/winbindd/winbindd_lookupname.c b/source3/winbindd/winbindd_lookupname.c index 1be29fd85c8..b02269155f1 100644 --- a/source3/winbindd/winbindd_lookupname.c +++ b/source3/winbindd/winbindd_lookupname.c @@ -35,7 +35,8 @@ struct tevent_req *winbindd_lookupname_send(TALLOC_CTX *mem_ctx, { struct tevent_req *req, *subreq; struct winbindd_lookupname_state *state; - char *domname, *name, *p; + const char *domname = NULL, *name = NULL; + char *p = NULL; req = tevent_req_create(mem_ctx, &state, struct winbindd_lookupname_state); @@ -49,17 +50,25 @@ struct tevent_req *winbindd_lookupname_send(TALLOC_CTX *mem_ctx, sizeof(request->data.name.dom_name)-1]='\0'; request->data.name.name[sizeof(request->data.name.name)-1]='\0'; - /* cope with the name being a fully qualified name */ - p = strstr(request->data.name.name, lp_winbind_separator()); - if (p) { - *p = 0; - domname = request->data.name.name; - name = p+1; - } else if ((p = strchr(request->data.name.name, '@')) != NULL) { - /* upn */ - domname = p + 1; - *p = 0; - name = request->data.name.name; + if (strlen(request->data.name.dom_name) == 0) { + /* cope with the name being a fully qualified name */ + p = strstr(request->data.name.name, lp_winbind_separator()); + if (p != NULL) { + *p = '\0'; + domname = request->data.name.name; + name = p + 1; + } else { + p = strchr(request->data.name.name, '@'); + if (p != NULL) { + /* upn */ + domname = p + 1; + *p = '\0'; + name = request->data.name.name; + } else { + domname = ""; + name = request->data.name.name; + } + } } else { domname = request->data.name.dom_name; name = request->data.name.name;