ipa_hosts.c revision ad07ed37b6b51ef134d4524edaf2259e19ac984f
842ae4bd224140319ae7feec1872b93dfd491143fielding Jan Zeleny <jzeleny@redhat.com>
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb Copyright (C) 2012 Red Hat
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb This program is free software; you can redistribute it and/or modify
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd it under the terms of the GNU General Public License as published by
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd the Free Software Foundation; either version 3 of the License, or
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd (at your option) any later version.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd This program is distributed in the hope that it will be useful,
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb but WITHOUT ANY WARRANTY; without even the implied warranty of
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb GNU General Public License for more details.
9d129b55f5a43abf43865c6b0eb6dd19bc22aba8ianh You should have received a copy of the GNU General Public License
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb along with this program. If not, see <http://www.gnu.org/licenses/>.
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb/* FIXME: this is temporary, use proper map instead */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char **attrs;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb const char *hostname;
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb /* Return values */
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantz {"memberof", IPA_MEMBEROF, SYSDB_ORIG_MEMBEROF, NULL},
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantzipa_hostgroup_info_done(struct tevent_req *subreq);
4f9c22c4f27571d54197be9674e1fc0d528192aestriker const char *hostname,
18b5268e013574026b2503b1641baf3299045f45sf const char **attrs,
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd req = tevent_req_create(mem_ctx, &state, struct ipa_host_state);
731344ed8f3677d1661c261ca5fcdd2ee3dbc74ccoar state->host_filter = talloc_asprintf(state, "(objectClass=%s)",
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe state->host_filter = talloc_asprintf(state, "(&(objectClass=%s)(%s=%s))",
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe DEBUG(SSSDBG_CRIT_FAILURE, ("No host search base configured?\n"));
d4abb06ac220bb280ae996b6d21bbd257db51bb1jerenkrantzstatic errno_t ipa_host_info_next(struct tevent_req *req,
4f9c22c4f27571d54197be9674e1fc0d528192aestriker base = state->search_bases[state->search_base_iter];
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe state->cur_filter = sdap_get_id_specific_filter(state, state->host_filter,
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf subreq = sdap_get_generic_send(state, state->ev, state->opts,
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe DEBUG(SSSDBG_CRIT_FAILURE, ("Error requesting host info\n"));
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe tevent_req_set_callback(subreq, ipa_host_info_done, req);
efd83d1dd1a25688a3093c5a542ae16bacef62ddsf const char *host_dn;
fa06de8a28a737e8fbaad76d7f3ff67aaa5e4a09wrowe /* No more search bases to try */
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes ret = replace_attribute_name(IPA_MEMBEROF, SYSDB_ORIG_MEMBEROF,
18b5268e013574026b2503b1641baf3299045f45sf DEBUG(SSSDBG_CRIT_FAILURE, ("Could not replace attribute names\n"));
18b5268e013574026b2503b1641baf3299045f45sf /* Complete the map */
18b5268e013574026b2503b1641baf3299045f45sf for (i = 0; i < HOSTGROUP_MAP_ATTRS_COUNT; i++) {
d9cc5de428947d5c7221d7d42ceefea649bcab48sf /* These are allocated on the state, so the next time they'll
18b5268e013574026b2503b1641baf3299045f45sf * have to be allocated again
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq /* Look up host groups */
1a7a4f8c6a312cb237e428c77da0792eb165dc7aniq state->host_filter = talloc_asprintf(state, "(objectClass=%s)",
18b5268e013574026b2503b1641baf3299045f45sf DEBUG(SSSDBG_CRIT_FAILURE, ("No host search base configured?\n"));
18b5268e013574026b2503b1641baf3299045f45sf state->hostgroup_map = talloc_zero(state, struct sdap_attr_map_info);
18b5268e013574026b2503b1641baf3299045f45sf state->hostgroup_map->num_attrs = HOSTGROUP_MAP_ATTRS_COUNT;
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes ret = sysdb_attrs_get_string(state->hosts[0], SYSDB_ORIG_DN, &host_dn);
69bbd0a9d1892949e1d4e454c10e8ad24b37c759sf subreq = sdap_deref_search_send(state, state->ev, state->opts, state->sh,
0d26b42fc1735e110c6dc83b114c56257b20070bbnicholes DEBUG(SSSDBG_CRIT_FAILURE, ("Error requesting host info\n"));
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowe tevent_req_set_callback(subreq, ipa_hostgroup_info_done, req);
4f9c22c4f27571d54197be9674e1fc0d528192aestriker /* Nothing else to do, just complete the req */
83a8dc5a596a8a1b9d14f063268287d123b9ed7ewrowestatic errno_t ipa_hostgroup_info_next(struct tevent_req *req,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe state->cur_filter = sdap_get_id_specific_filter(state, state->host_filter,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe subreq = sdap_get_generic_send(state, state->ev, state->opts, state->sh,
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe DEBUG(SSSDBG_CRIT_FAILURE, ("Error requesting hostgroup info\n"));
4f9c22c4f27571d54197be9674e1fc0d528192aestriker tevent_req_set_callback(subreq, ipa_hostgroup_info_done, req);
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd /* Merge the two arrays */
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd hostgroups_total = hostgroup_count + state->hostgroup_count;
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd state->hostgroups = talloc_realloc(state, state->hostgroups,
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd /* Now look in the next base */
a72211e92bab814bfa28ee086ca9b2a1a6095c92chrisd /* Only continue if no error occurred
cc9582e53aead2a044077c4a92f3dfc3605590b3wrowe * and no req was created */
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb DEBUG(SSSDBG_FUNC_DATA, ("No host groups were dereferenced\n"));
b38846b15c8891c6dec44dcc4f96ca40721bf663rbb state->hostgroups = talloc_zero_array(state, struct sysdb_attrs *,
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantz DEBUG(SSSDBG_FUNC_DATA, ("Dereferenced host group: %s\n",
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe DEBUG(SSSDBG_OP_FAILURE, ("Error [%d][%s]\n", ret, strerror(ret)));
7c301a1818939f85da8f3629cc3e9b5588610ef0jerenkrantzerrno_t ipa_host_info_recv(struct tevent_req *req,
290ecc1ddceca1ed49bc1a5338921264b5c3e07cwrowe /* Guarantee the memory heirarchy of the list */