nsswitch: allow passing the domain name to wbcPingDC[2]()
authorStefan Metzmacher <metze@samba.org>
Wed, 10 Dec 2014 14:02:18 +0000 (14:02 +0000)
committerStefan Metzmacher <metze@samba.org>
Fri, 19 Dec 2014 12:15:12 +0000 (13:15 +0100)
winbindd already supports this.

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
nsswitch/libwbclient/tests/wbclient.c
nsswitch/libwbclient/wbc_pam.c

index f40ce52dbee5934ef99a81839b980645d286cc53..5bce0aead8853cc93771f8bd338e5cbee9e94d92 100644 (file)
@@ -57,24 +57,60 @@ static bool test_wbc_ping(struct torture_context *tctx)
 
 static bool test_wbc_pingdc(struct torture_context *tctx)
 {
-       torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_NOT_IMPLEMENTED,
+       struct wbcInterfaceDetails *details;
+
+       torture_assert_wbc_equal(tctx, wbcPingDc("random_string", NULL), WBC_ERR_DOMAIN_NOT_FOUND,
                                 "%s", "wbcPingDc failed");
        torture_assert_wbc_ok(tctx, wbcPingDc(NULL, NULL),
                "%s", "wbcPingDc failed");
 
+       torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
+               "%s", "wbcInterfaceDetails failed");
+       torture_assert(tctx, details,
+                      "wbcInterfaceDetails returned NULL pointer");
+       torture_assert(tctx, details->netbios_domain,
+                      "wbcInterfaceDetails returned NULL netbios_domain");
+
+       torture_assert_wbc_ok(tctx, wbcPingDc(details->netbios_domain, NULL),
+               "wbcPingDc(%s) failed", details->netbios_domain);
+
+       torture_assert_wbc_ok(tctx, wbcPingDc("BUILTIN", NULL),
+               "%s", "wbcPingDc(BUILTIN) failed");
+
+       wbcFreeMemory(details);
        return true;
 }
 
 static bool test_wbc_pingdc2(struct torture_context *tctx)
 {
+       struct wbcInterfaceDetails *details;
        char *name = NULL;
 
        torture_assert_wbc_equal(tctx, wbcPingDc2("random_string", NULL, &name),
-                                WBC_ERR_NOT_IMPLEMENTED, "%s",
+                                WBC_ERR_DOMAIN_NOT_FOUND, "%s",
                                 "wbcPingDc2 failed");
        torture_assert_wbc_ok(tctx, wbcPingDc2(NULL, NULL, &name), "%s",
                              "wbcPingDc2 failed");
 
+       wbcFreeMemory(name);
+
+       torture_assert_wbc_ok(tctx, wbcInterfaceDetails(&details),
+               "%s", "wbcInterfaceDetails failed");
+       torture_assert(tctx, details,
+                      "wbcInterfaceDetails returned NULL pointer");
+       torture_assert(tctx, details->netbios_domain,
+                      "wbcInterfaceDetails returned NULL netbios_domain");
+
+       torture_assert_wbc_ok(tctx, wbcPingDc2(details->netbios_domain, NULL, &name),
+               "wbcPingDc2(%s) failed", details->netbios_domain);
+       wbcFreeMemory(name);
+
+       torture_assert_wbc_ok(tctx, wbcPingDc2("BUILTIN", NULL, &name),
+               "%s", "wbcPingDc2(BUILTIN) failed");
+       wbcFreeMemory(name);
+
+       wbcFreeMemory(details);
+
        return true;
 }
 
index 11b59f6f30ce76b7d2acb4c43a77f80e88a76cac..e243538b818d31f66367081a88a77eff74b0e248 100644 (file)
@@ -639,18 +639,14 @@ wbcErr wbcPingDc2(const char *domain, struct wbcAuthErrorInfo **error,
        struct winbindd_response response;
        wbcErr wbc_status = WBC_ERR_UNKNOWN_FAILURE;
 
-       if (domain) {
-               /*
-                * the current protocol doesn't support
-                * specifying a domain
-                */
-               wbc_status = WBC_ERR_NOT_IMPLEMENTED;
-               BAIL_ON_WBC_ERROR(wbc_status);
-       }
-
        ZERO_STRUCT(request);
        ZERO_STRUCT(response);
 
+       if (domain) {
+               strncpy(request.domain_name, domain,
+                       sizeof(request.domain_name)-1);
+       }
+
        /* Send request */
 
        wbc_status = wbcRequestResponse(WINBINDD_PING_DC,