ipa_hosts.c revision ad07ed37b6b51ef134d4524edaf2259e19ac984f
/*
SSSD
Authors:
Jan Zeleny <jzeleny@redhat.com>
Copyright (C) 2012 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include "providers/ldap/sdap_async.h"
#include "providers/ipa/ipa_hosts.h"
/* FIXME: this is temporary, use proper map instead */
#include "providers/ipa/ipa_hbac_private.h"
struct ipa_host_state {
struct tevent_context *ev;
struct sdap_handle *sh;
struct sdap_options *opts;
const char **attrs;
struct sdap_search_base **search_bases;
int search_base_iter;
char *cur_filter;
char *host_filter;
const char *hostname;
/* Return values */
struct sysdb_attrs **hosts;
bool fetch_hostgroups;
struct sysdb_attrs **hostgroups;
struct sdap_attr_map_info *hostgroup_map;
};
#define HOSTGROUP_MAP_ATTRS_COUNT 5
static struct sdap_attr_map hostgroup_map[] = {
};
static void
static void
static errno_t
struct ipa_host_state *state);
static errno_t
struct ipa_host_state *state);
struct tevent_req *
struct tevent_context *ev,
struct sdap_handle *sh,
struct sdap_options *opts,
const char *hostname,
const char **attrs,
bool fetch_hostgroups,
struct sdap_search_base **search_bases)
{
struct ipa_host_state *state;
struct tevent_req *req;
return NULL;
}
state->search_base_iter = 0;
IPA_HOST);
} else {
}
goto immediate;
}
}
goto immediate;
}
return req;
} else {
}
return req;
}
struct ipa_host_state *state)
{
struct sdap_search_base *base;
struct tevent_req *subreq;
return EOK;
}
return ENOMEM;
}
return EIO;
}
return EAGAIN;
}
static void
{
struct tevent_req *req =
struct ipa_host_state *state =
const char *host_dn;
int i;
&state->host_count,
return;
}
if (state->host_count == 0) {
/* No more search bases to try */
}
return;
}
return;
}
/* Complete the map */
for (i = 0; i < HOSTGROUP_MAP_ATTRS_COUNT; i++) {
/* These are allocated on the state, so the next time they'll
* have to be allocated again
*/
hostgroup_map[i].def_name);
return;
}
}
if (state->fetch_hostgroups) {
/* Look up host groups */
return;
}
state->search_base_iter = 0;
return;
return;
}
} else {
return;
}
return;
}
return;
}
}
} else {
/* Nothing else to do, just complete the req */
}
}
struct ipa_host_state *state)
{
struct sdap_search_base *base;
struct tevent_req *subreq;
return EOK;
}
return ENOMEM;
}
return EIO;
}
return EAGAIN;
}
static void
{
struct tevent_req *req =
struct ipa_host_state *state =
struct sysdb_attrs **hostgroups;
struct sdap_deref_attrs **deref_result;
const char *hostgroup_name;
const char *hostgroup_dn;
int i, j;
&hostgroups);
/* Merge the two arrays */
if (hostgroup_count > 0) {
struct sysdb_attrs *,
return;
}
i = 0;
state->hostgroup_count++;
i++;
}
}
/* Now look in the next base */
}
/* Only continue if no error occurred
* and no req was created */
return;
}
} else {
&deref_result);
if (state->hostgroup_count == 0) {
} else {
goto done;
}
j = 0;
for (i = 0; i < state->hostgroup_count; i++) {
NULL)) {
continue;
}
IPA_CN, &hostgroup_name);
deref_result[i]->attrs);
j++;
}
state->hostgroup_count = j;
}
}
done:
} else {
}
}
struct sysdb_attrs ***hosts,
struct sysdb_attrs ***hostgroups)
{
size_t c;
struct ipa_host_state *state =
for (c = 0; c < state->host_count; c++) {
/* Guarantee the memory heirarchy of the list */
}
return EOK;
}