torture: fix the ldap.cldap test
authorMichael Adam <obnox@samba.org>
Thu, 17 Dec 2015 12:56:16 +0000 (13:56 +0100)
committerMichael Adam <obnox@samba.org>
Mon, 11 Jan 2016 11:25:26 +0000 (12:25 +0100)
This makes sure a host*NAME* handed in will get properly resolved.
Bug uncovered by the new nss_wrapper code (1.1.2) which fixed
the handling of the AI_NUMERICHOST flag in getaddrinfo.

Signed-off-by: Michael Adam <obnox@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
Reviewed-by: Stefan Metzmacher <metze@samba.org>
source4/torture/ldap/cldap.c

index 6a925cf4546baf983134fad7bd2a668ff595e123..6a9e9e160783850e9005bcdeba3f205d0bf415dc 100644 (file)
@@ -24,6 +24,7 @@
 #include "includes.h"
 #include "libcli/cldap/cldap.h"
 #include "libcli/ldap/ldap_client.h"
+#include "libcli/resolve/resolve.h"
 #include "param/param.h"
 #include "../lib/tsocket/tsocket.h"
 
@@ -87,10 +88,20 @@ static bool test_cldap_generic(struct torture_context *tctx, const char *dest)
        const char *attrs2[] = { "currentTime", "highestCommittedUSN", "netlogon", NULL };
        const char *attrs3[] = { "netlogon", NULL };
        struct tsocket_address *dest_addr;
+       const char *ip;
+       struct nbt_name nbt_name;
        int ret;
 
+       make_nbt_name_server(&nbt_name, dest);
+
+       status = resolve_name_ex(lpcfg_resolve_context(tctx->lp_ctx),
+                                0, 0, &nbt_name, tctx, &ip, tctx->ev);
+       torture_assert_ntstatus_ok(tctx, status,
+                       talloc_asprintf(tctx,"Failed to resolve %s: %s",
+                                       nbt_name.name, nt_errstr(status)));
+
        ret = tsocket_address_inet_from_strings(tctx, "ip",
-                                               dest,
+                                               ip,
                                                lpcfg_cldap_port(tctx->lp_ctx),
                                                &dest_addr);
        CHECK_VAL(ret, 0);