]> git.ipfire.org Git - thirdparty/samba.git/commitdiff
s3/libsmb: check the negative-conn-cache in resolve_ads()
authorRalph Boehme <slow@samba.org>
Thu, 3 Jul 2025 16:42:04 +0000 (18:42 +0200)
committerJule Anger <janger@samba.org>
Wed, 6 Aug 2025 08:08:10 +0000 (08:08 +0000)
This way we throw away blacklisted servers right away when learning about them
from the DNS SRV query.

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

Signed-off-by: Ralph Boehme <slow@samba.org>
Reviewed-by: Guenther Deschner <gd@samba.org>
Autobuild-User(master): Günther Deschner <gd@samba.org>
Autobuild-Date(master): Wed Jul 30 10:10:21 UTC 2025 on atb-devel-224

(cherry picked from commit c1ee6fe9a489a8923d607e14d26768935a398849)

source3/libsmb/namequery.c

index 9a47f034d385418563efbd5cd02dbd209a8092bf..779386be39ddd04ff9d900d6e0c946c14be387e3 100644 (file)
@@ -2576,6 +2576,14 @@ static NTSTATUS resolve_ads(TALLOC_CTX *ctx,
        for(i = 0; i < numdcs; i++) {
                /* Copy all the IP addresses from the SRV response */
                size_t j;
+
+               status = check_negative_conn_cache(name, dcs[i].hostname);
+               if (!NT_STATUS_IS_OK(status)) {
+                       DBG_DEBUG("Skipping blacklisted server [%s] "
+                                 "for domain [%s]", dcs[i].hostname, name);
+                       continue;
+               }
+
                for (j = 0; j < dcs[i].num_ips; j++) {
                        char addr[INET6_ADDRSTRLEN];
 
@@ -2584,12 +2592,19 @@ static NTSTATUS resolve_ads(TALLOC_CTX *ctx,
                                continue;
                        }
 
+                       print_sockaddr(addr,
+                                      sizeof(addr),
+                                      &srv_addrs[num_srv_addrs]);
+
                        DBG_DEBUG("SRV lookup %s got IP[%zu] %s\n",
-                               name,
-                               j,
-                               print_sockaddr(addr,
-                                       sizeof(addr),
-                                       &srv_addrs[num_srv_addrs]));
+                                 name, j, addr);
+
+                       status = check_negative_conn_cache(name, addr);
+                       if (!NT_STATUS_IS_OK(status)) {
+                               DBG_DEBUG("Skipping blacklisted server [%s] "
+                                          "for domain [%s]", addr, name);
+                               continue;
+                       }
 
                        num_srv_addrs++;
                }