ipa_hosts.c revision a3c8390d19593b1e5277d95bfb4ab206d4785150
/*
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"
#include "providers/ipa/ipa_common.h"
struct ipa_host_state {
struct tevent_context *ev;
struct sdap_handle *sh;
struct sdap_options *opts;
const char **attrs;
struct sdap_attr_map *host_map;
struct sdap_attr_map *hostgroup_map;
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;
struct sysdb_attrs **hostgroups;
struct sdap_attr_map_info *ipa_hostgroup_map;
};
static void
static void
static errno_t
struct ipa_host_state *state);
static errno_t
struct ipa_host_state *state);
/**
* hostname == NULL -> look up all hosts / host groups
* hostname != NULL -> look up only given host and groups
* it's member of
* hostgroup_map == NULL -> skip looking up hostgroups
*/
struct tevent_req *
struct tevent_context *ev,
struct sdap_handle *sh,
struct sdap_options *opts,
const char *hostname,
struct sdap_attr_map *host_map,
struct sdap_attr_map *hostgroup_map,
struct sdap_search_base **search_bases)
{
struct ipa_host_state *state;
struct tevent_req *req;
return NULL;
}
state->search_base_iter = 0;
goto immediate;
}
} else {
hostname);
}
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;
}
true);
return EIO;
}
return EAGAIN;
}
static void
{
struct tevent_req *req =
struct ipa_host_state *state =
const char *host_dn;
&state->host_count,
return;
}
if (state->host_count == 0) {
/* No more search bases to try */
}
return;
}
if (state->hostgroup_map) {
return;
}
/* Look up host groups */
return;
}
state->search_base_iter = 0;
return;
return;
}
} else {
return;
}
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;
}
true);
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);
"sdap_get_generic_recv failed: [%d]\n", ret);
return;
}
/* 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;
}
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;
}