summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--nsswitch/libwbclient/tests/wbclient.c40
-rw-r--r--nsswitch/libwbclient/wbc_pam.c14
2 files changed, 43 insertions, 11 deletions
diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c
index f40ce52dbe..5bce0aead8 100644
--- a/nsswitch/libwbclient/tests/wbclient.c
+++ b/nsswitch/libwbclient/tests/wbclient.c
@@ -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;
}
diff --git a/nsswitch/libwbclient/wbc_pam.c b/nsswitch/libwbclient/wbc_pam.c
index 11b59f6f30..e243538b81 100644
--- a/nsswitch/libwbclient/wbc_pam.c
+++ b/nsswitch/libwbclient/wbc_pam.c
@@ -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,