From f80f585d959b03a41434e48ffa31cac842a76ade Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Wed, 10 Dec 2014 14:02:18 +0000 Subject: [PATCH] nsswitch: allow passing the domain name to wbcPingDC[2]() winbindd already supports this. Signed-off-by: Stefan Metzmacher Reviewed-by: Jeremy Allison Reviewed-by: Andrew Bartlett --- nsswitch/libwbclient/tests/wbclient.c | 40 +++++++++++++++++++++++++++++++++-- nsswitch/libwbclient/wbc_pam.c | 14 +++++------- 2 files changed, 43 insertions(+), 11 deletions(-) diff --git a/nsswitch/libwbclient/tests/wbclient.c b/nsswitch/libwbclient/tests/wbclient.c index f40ce52dbee..5bce0aead88 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 11b59f6f30c..e243538b818 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, -- 2.11.4.GIT