summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2014-12-10 14:02:18 +0000
committerStefan Metzmacher <metze@samba.org>2014-12-19 13:15:12 +0100
commitf80f585d959b03a41434e48ffa31cac842a76ade (patch)
tree7dc167500960abbba5bd7c8082104cd7de08af74
parenta44e8a3249f644accc0c115ba0d2e305e3b69f10 (diff)
downloadsamba-f80f585d959b03a41434e48ffa31cac842a76ade.tar.gz
nsswitch: allow passing the domain name to wbcPingDC[2]()
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>
-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 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,