diff options
-rw-r--r-- | source4/torture/winbind/struct_based.c | 66 |
1 files changed, 66 insertions, 0 deletions
diff --git a/source4/torture/winbind/struct_based.c b/source4/torture/winbind/struct_based.c index 1006b3c23b..924d98202d 100644 --- a/source4/torture/winbind/struct_based.c +++ b/source4/torture/winbind/struct_based.c @@ -23,6 +23,7 @@ #include "torture/winbind/proto.h" #include "nsswitch/winbind_client.h" #include "libcli/security/security.h" +#include "librpc/gen_ndr/netlogon.h" #include "param/param.h" #include "auth/pam_errors.h" @@ -490,6 +491,70 @@ static bool torture_winbind_struct_getdcname(struct torture_context *torture) return true; } +static bool torture_winbind_struct_dsgetdcname(struct torture_context *torture) +{ + bool ok; + bool strict = torture_setting_bool(torture, "strict mode", false); + struct torture_trust_domain *listd = NULL; + uint32_t i; + uint32_t count = 0; + + torture_comment(torture, "Running WINBINDD_DSGETDCNAME (struct based)\n"); + + ok = get_trusted_domains(torture, &listd); + torture_assert(torture, ok, "failed to get trust list"); + + for (i=0; listd[i].netbios_name; i++) { + struct winbindd_request req; + struct winbindd_response rep; + + ZERO_STRUCT(req); + ZERO_STRUCT(rep); + + if (strlen(listd[i].dns_name) == 0) continue; + + /* + * TODO: remove this and let winbindd give no dns name + * for NT4 domains + */ + if (strcmp(listd[i].dns_name, listd[i].netbios_name) == 0) { + continue; + } + + fstrcpy(req.domain_name, listd[i].dns_name); + + /* TODO: test more flag combinations */ + req.flags = DS_DIRECTORY_SERVICE_REQUIRED; + + ok = true; + DO_STRUCT_REQ_REP_EXT(WINBINDD_DSGETDCNAME, &req, &rep, + NSS_STATUS_SUCCESS, + strict, ok = false, + talloc_asprintf(torture, "DOMAIN '%s'", + req.domain_name)); + if (!ok) continue; + + /* TODO: check rep.data.dc_name; */ + torture_comment(torture, "DOMAIN '%s' => DCNAME '%s'\n", + req.domain_name, rep.data.dc_name); + + count++; + } + + if (count == 0) { + torture_warning(torture, "WINBINDD_DSGETDCNAME" + " was not tested with %d non-AD domains", + i); + } + + if (strict) { + torture_assert(torture, count > 0, + "WiNBINDD_DSGETDCNAME was not tested"); + } + + return true; +} + struct torture_suite *torture_winbind_struct_init(void) { struct torture_suite *suite = torture_suite_create(talloc_autofree_context(), "STRUCT"); @@ -504,6 +569,7 @@ struct torture_suite *torture_winbind_struct_init(void) torture_suite_add_simple_test(suite, "LIST_TRUSTDOM", torture_winbind_struct_list_trustdom); torture_suite_add_simple_test(suite, "DOMAIN_INFO", torture_winbind_struct_domain_info); torture_suite_add_simple_test(suite, "GETDCNAME", torture_winbind_struct_getdcname); + torture_suite_add_simple_test(suite, "DSGETDCNAME", torture_winbind_struct_dsgetdcname); suite->description = talloc_strdup(suite, "WINBIND - struct based protocol tests"); |