return true;
}
-static bool get_group_list(struct torture_context *torture, char ***groups)
+static bool get_group_list(struct torture_context *torture, int *num_entries,
+ char ***groups)
{
struct winbindd_request req;
struct winbindd_response rep;
ZERO_STRUCT(rep);
DO_STRUCT_REQ_REP(WINBINDD_LIST_GROUPS, &req, &rep);
-
extra_data = (char *)rep.extra_data.data;
+
+ *num_entries = rep.data.num_entries;
+
+ if (*num_entries == 0) {
+ torture_assert(torture, extra_data == NULL,
+ "extra data is null for >0 reported entries\n");
+ *groups = NULL;
+ return true;
+ }
+
torture_assert(torture, extra_data, "NULL extra data");
for(count = 0;
SAFE_FREE(rep.extra_data.data);
+ torture_assert_int_equal(torture, *num_entries, count,
+ "Wrong number of group entries reported.");
+
*groups = g;
return true;
}
torture_comment(torture, "Running WINBINDD_LIST_GROUPS (struct based)\n");
- ok = get_group_list(torture, &groups);
+ ok = get_group_list(torture, &count, &groups);
torture_assert(torture, ok, "failed to get group list");
- for (count = 0; groups[count]; count++) { }
-
torture_comment(torture, "got %d groups\n", count);
return true;
{
uint32_t count;
- for (count = 0; list[count]; count++) {
+ for (count = 0; list && list[count]; count++) {
if (strequal(name, list[count])) {
return true;
}
bool strict = torture_setting_bool(torture, "strict mode", false);
char **users;
char **groups;
- uint32_t count;
+ uint32_t count, num_groups;
bool ok;
torture_comment(torture, "Running WINBINDD_LOOKUP_NAME_SID (struct based)\n");
torture_assert(torture, ok, "failed to retrieve list of users");
lookup_name_sid_list(torture, users);
- ok = get_group_list(torture, &groups);
+ ok = get_group_list(torture, &num_groups, &groups);
torture_assert(torture, ok, "failed to retrieve list of groups");
- lookup_name_sid_list(torture, groups);
+ if (num_groups > 0) {
+ lookup_name_sid_list(torture, groups);
+ }
ZERO_STRUCT(req);
ZERO_STRUCT(rep);