return true;
}
-struct torture_domain_sequence {
- const char *netbios_name;
- uint32_t seq;
-};
-
-static bool get_sequence_numbers(struct torture_context *torture,
- struct torture_domain_sequence **seqs)
-{
- struct winbindd_request req;
- struct winbindd_response rep;
- const char *extra_data;
- char line[256];
- uint32_t count = 0;
- struct torture_domain_sequence *s = NULL;
-
- ZERO_STRUCT(req);
- ZERO_STRUCT(rep);
-
- DO_STRUCT_REQ_REP(WINBINDD_SHOW_SEQUENCE, &req, &rep);
-
- extra_data = (char *)rep.extra_data.data;
- torture_assert(torture, extra_data, "NULL sequence list");
-
- while (next_token(&extra_data, line, "\n", sizeof(line))) {
- char *p, *lp;
- uint32_t seq;
-
- s = talloc_realloc(torture, s, struct torture_domain_sequence,
- count + 2);
- ZERO_STRUCT(s[count+1]);
-
- lp = line;
- p = strchr(lp, ' ');
- torture_assert(torture, p, "invalid line format");
- *p = 0;
- s[count].netbios_name = talloc_strdup(s, lp);
-
- lp = p+1;
- torture_assert(torture, strncmp(lp, ": ", 2) == 0,
- "invalid line format");
- lp += 2;
- if (strcmp(lp, "DISCONNECTED") == 0) {
- seq = (uint32_t)-1;
- } else {
- seq = (uint32_t)strtol(lp, &p, 10);
- torture_assert(torture, (*p == '\0'),
- "invalid line format");
- torture_assert(torture, (seq != (uint32_t)-1),
- "sequence number -1 encountered");
- }
- s[count].seq = seq;
-
- count++;
- }
- SAFE_FREE(rep.extra_data.data);
-
- torture_assert(torture, count >= 2, "The list of domain sequence "
- "numbers should contain 2 entries");
-
- *seqs = s;
- return true;
-}
-
-static bool torture_winbind_struct_show_sequence(struct torture_context *torture)
-{
- bool ok;
- uint32_t i;
- struct torture_trust_domain *domlist = NULL;
- struct torture_domain_sequence *s = NULL;
-
- torture_comment(torture, "Running WINBINDD_SHOW_SEQUENCE (struct based)\n");
-
- ok = get_sequence_numbers(torture, &s);
- torture_assert(torture, ok, "failed to get list of sequence numbers");
-
- ok = get_trusted_domains(torture, &domlist);
- torture_assert(torture, ok, "failed to get trust list");
-
- for (i=0; domlist[i].netbios_name; i++) {
- struct winbindd_request req;
- struct winbindd_response rep;
- uint32_t seq;
-
- torture_assert(torture, s[i].netbios_name,
- "more domains received in second run");
- torture_assert_str_equal(torture, domlist[i].netbios_name,
- s[i].netbios_name,
- "inconsistent order of domain lists");
-
- ZERO_STRUCT(req);
- ZERO_STRUCT(rep);
- fstrcpy(req.domain_name, domlist[i].netbios_name);
-
- ok = true;
- DO_STRUCT_REQ_REP_EXT(WINBINDD_SHOW_SEQUENCE, &req, &rep,
- NSS_STATUS_SUCCESS,
- false, ok = false,
- "WINBINDD_SHOW_SEQUENCE");
- if (ok == false) {
- torture_warning(torture,
- "WINBINDD_SHOW_SEQUENCE on "
- "domain %s failed\n",
- req.domain_name);
-
- /*
- * Only fail for the first two domain that we
- * check specially below, otherwise we fail on
- * trusts generated by the LSA torture test
- * that do not really exist.
- */
- if (i > 1) {
- /*
- * Do not confirm the sequence numbers
- * below
- */
- return true;
- }
-
- torture_comment(torture,
- "Full trust list for "
- "WINBINDD_SHOW_SEQUENCE "
- "test was:\n");
- for (i=0; domlist[i].netbios_name; i++) {
- torture_comment(torture,
- "%s\n",
- domlist[i].netbios_name);
- }
-
- return false;
- }
-
- seq = rep.data.sequence_number;
-
- if (i == 0) {
- torture_assert(torture, (seq != (uint32_t)-1),
- "BUILTIN domain disconnected");
- } else if (i == 1) {
- torture_assert(torture, (seq != (uint32_t)-1),
- "local domain disconnected");
- }
-
-
- if (seq == (uint32_t)-1) {
- torture_comment(torture, " * %s : DISCONNECTED\n",
- req.domain_name);
- } else {
- torture_comment(torture, " * %s : %d\n",
- req.domain_name, seq);
- }
- torture_assert(torture, (seq >= s[i].seq),
- "illegal sequence number encountered");
- }
-
- return true;
-}
-
static bool torture_winbind_struct_setpwent(struct torture_context *torture)
{
struct winbindd_request req;
torture_suite_add_simple_test(suite, "dsgetdcname", torture_winbind_struct_dsgetdcname);
torture_suite_add_simple_test(suite, "list_users", torture_winbind_struct_list_users);
torture_suite_add_simple_test(suite, "list_groups", torture_winbind_struct_list_groups);
- torture_suite_add_simple_test(suite, "show_sequence", torture_winbind_struct_show_sequence);
torture_suite_add_simple_test(suite, "setpwent", torture_winbind_struct_setpwent);
torture_suite_add_simple_test(suite, "getpwent", torture_winbind_struct_getpwent);
torture_suite_add_simple_test(suite, "endpwent", torture_winbind_struct_endpwent);