static int collect_map(struct db_record *rec, void *private_data) { struct enum_map_state *state = (struct enum_map_state *)private_data; GROUP_MAP map; GROUP_MAP *tmp; if (!dbrec2map(rec, &map)) { return 0; } /* list only the type or everything if UNKNOWN */ if (state->sid_name_use != SID_NAME_UNKNOWN && state->sid_name_use != map.sid_name_use) { DEBUG(11,("enum_group_mapping: group %s is not of the " "requested type\n", map.nt_name)); return 0; } if ((state->unix_only == ENUM_ONLY_MAPPED) && (map.gid == -1)) { DEBUG(11,("enum_group_mapping: group %s is non mapped\n", map.nt_name)); return 0; } if ((state->domsid != NULL) && (sid_compare_domain(state->domsid, &map.sid) != 0)) { DEBUG(11,("enum_group_mapping: group %s is not in domain\n", sid_string_dbg(&map.sid))); return 0; } if (!(tmp = SMB_REALLOC_ARRAY(state->maps, GROUP_MAP, state->num_maps+1))) { DEBUG(0,("enum_group_mapping: Unable to enlarge group " "map!\n")); return 1; } state->maps = tmp; state->maps[state->num_maps] = map; state->num_maps++; return 0; }
static int find_map(struct db_record *rec, void *private_data) { struct find_map_state *state = (struct find_map_state *)private_data; if (!dbrec2map(rec, state->map)) { DEBUG(10, ("failed to unpack map\n")); return 0; } if (state->name != NULL) { if (strequal(state->name, state->map->nt_name)) { state->found = true; return 1; } } else { if (state->map->gid == state->gid) { state->found = true; return 1; } } return 0; }