winbindd: Do not ignore domain in the LOOKUPNAME request
authorChristof Schmitt <cs@samba.org>
Wed, 28 Feb 2018 19:05:34 +0000 (12:05 -0700)
committerAndreas Schneider <asn@cryptomilk.org>
Fri, 6 Apr 2018 19:03:31 +0000 (21:03 +0200)
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 <cs@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org>
Autobuild-Date(master): Fri Apr  6 21:03:31 CEST 2018 on sn-devel-144

selftest/knownfail
source3/winbindd/winbindd_lookupname.c

index 6ef61dbcba2f8b593031c1242dcdd9f80b5b8aa5..a2aeed2690dd4f48b03a1688a643741aa9d63456 100644 (file)
 # 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\)
index 1be29fd85c8da0d9422f43314c1ed662ed7443e5..b02269155f1dbf3b7a31bfd167ea7c233f3bb413 100644 (file)
@@ -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;