winbind: Use domain name from lsa query for sid_to_name cache entry
authorChristof Schmitt <cs@samba.org>
Mon, 11 Mar 2019 23:14:02 +0000 (16:14 -0700)
committerChristof Schmitt <cs@samba.org>
Thu, 18 Apr 2019 17:21:18 +0000 (17:21 +0000)
When winbindd is asked to map a name like realm.com\name to a SID ,that
is sucessfully resolved through the lsa lookup name call. The same call
also returns the short domain name (netbios name of the domain). Use
that short domain name for the sid_to_name cache entry, so that
subsequent sid_to_name queries return the expected netbiosname\name
result and not realm.com\name.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=13831

Signed-off-by: Christof Schmitt <cs@samba.org>
Reviewed-by: Volker Lendecke <vl@samba.org>
selftest/knownfail
source3/winbindd/winbindd_cache.c

index 29cce4b..c588f2f 100644 (file)
 ^samba.tests.ntlmdisabled.python\(ktest\).python2.ntlmdisabled.NtlmDisabledTests.test_samr_change_password\(ktest\)
 ^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).python3.ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
 ^samba.tests.ntlmdisabled.python\(ad_dc_no_ntlm\).python2.ntlmdisabled.NtlmDisabledTests.test_ntlm_connection\(ad_dc_no_ntlm\)
-^samba3.wbinfo_name_lookup.Verify DOMAIN/USER output\(ad_member\)
index 92a5e1d..abdfd11 100644 (file)
@@ -1794,6 +1794,7 @@ NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
 {
        NTSTATUS status;
        bool old_status;
+       const char *dom_name;
 
        old_status = domain->online;
 
@@ -1820,7 +1821,7 @@ NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
 
        winbindd_domain_init_backend(domain);
        status = domain->backend->name_to_sid(domain, mem_ctx, domain_name,
-                                             name, flags, NULL, sid, type);
+                                             name, flags, &dom_name, sid, type);
 
        if (NT_STATUS_EQUAL(status, NT_STATUS_IO_TIMEOUT) ||
                NT_STATUS_EQUAL(status, NT_STATUS_DOMAIN_CONTROLLER_NOT_FOUND)) {
@@ -1855,7 +1856,7 @@ NTSTATUS wb_cache_name_to_sid(struct winbindd_domain *domain,
                        }
                        (void)strlower_m(discard_const_p(char, name));
                        wcache_save_sid_to_name(domain, status, sid,
-                                               domain_name, name, save_type);
+                                               dom_name, name, save_type);
                }
        }