d98fdd80331e93cd698281341360a3ce3e30afbePavel Březina Pavel Březina <pbrezina@redhat.com>
88275cccddf39892e01682b39b02292eb74729bdPavel Březina Copyright (C) 2013 Red Hat
88275cccddf39892e01682b39b02292eb74729bdPavel Březina This program is free software; you can redistribute it and/or modify
88275cccddf39892e01682b39b02292eb74729bdPavel Březina it under the terms of the GNU General Public License as published by
88275cccddf39892e01682b39b02292eb74729bdPavel Březina the Free Software Foundation; either version 3 of the License, or
88275cccddf39892e01682b39b02292eb74729bdPavel Březina (at your option) any later version.
88275cccddf39892e01682b39b02292eb74729bdPavel Březina This program is distributed in the hope that it will be useful,
88275cccddf39892e01682b39b02292eb74729bdPavel Březina but WITHOUT ANY WARRANTY; without even the implied warranty of
88275cccddf39892e01682b39b02292eb74729bdPavel Březina MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
88275cccddf39892e01682b39b02292eb74729bdPavel Březina GNU General Public License for more details.
88275cccddf39892e01682b39b02292eb74729bdPavel Březina You should have received a copy of the GNU General Public License
88275cccddf39892e01682b39b02292eb74729bdPavel Březina along with this program. If not, see <http://www.gnu.org/licenses/>.
88275cccddf39892e01682b39b02292eb74729bdPavel Březina ctx = talloc_zero(mem_ctx, struct ipa_srv_plugin_ctx);
88275cccddf39892e01682b39b02292eb74729bdPavel Březina ctx->ipa_domain = talloc_strdup(ctx, ipa_domain);
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březinastatic void ipa_srv_plugin_done(struct tevent_req *subreq);
88275cccddf39892e01682b39b02292eb74729bdPavel Březina/* If IPA server supports sites, we will use
88275cccddf39892e01682b39b02292eb74729bdPavel Březina * _locations.hostname.discovery_domain for primary servers and
88275cccddf39892e01682b39b02292eb74729bdPavel Březina * discovery_domain for backup servers. If the server does not support sites or
88275cccddf39892e01682b39b02292eb74729bdPavel Březina * client's SRV record is not found, we will use the latter for primary
88275cccddf39892e01682b39b02292eb74729bdPavel Březina * servers, setting backup servers to NULL */
88275cccddf39892e01682b39b02292eb74729bdPavel Březinastruct tevent_req *ipa_srv_plugin_send(TALLOC_CTX *mem_ctx,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
88275cccddf39892e01682b39b02292eb74729bdPavel Březina ctx = talloc_get_type(pvt, struct ipa_srv_plugin_ctx);
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březina backup_domain = talloc_strdup(state, discovery_domain);
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březina backup_domain = talloc_strdup(state, ctx->ipa_domain);
88275cccddf39892e01682b39b02292eb74729bdPavel Březina /* not FQDN, append domain name */
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březina primary_domain = talloc_asprintf(state, IPA_DNS_LOCATION ".%s.%s",
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březina primary_domain = talloc_asprintf(state, IPA_DNS_LOCATION ".%s",
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "About to discover primary and "
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "backup servers\n");
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březina subreq = fo_discover_servers_send(state, ev, ctx->resolv_ctx, service,
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březina tevent_req_set_callback(subreq, ipa_srv_plugin_done, req);
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březinastatic void ipa_srv_plugin_done(struct tevent_req *subreq)
88275cccddf39892e01682b39b02292eb74729bdPavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
88275cccddf39892e01682b39b02292eb74729bdPavel Březina state = tevent_req_data(req, struct ipa_srv_plugin_state);
9894b0fabc1720bd083538c2d818fcd88409cad7Pavel Březina ret = fo_discover_servers_recv(state, subreq, &state->dns_domain,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "Got %zu primary and %zu backup servers\n",
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov state->num_primary_servers, state->num_backup_servers);
88275cccddf39892e01682b39b02292eb74729bdPavel Březinaerrno_t ipa_srv_plugin_recv(TALLOC_CTX *mem_ctx,
88275cccddf39892e01682b39b02292eb74729bdPavel Březina state = tevent_req_data(req, struct ipa_srv_plugin_state);
88275cccddf39892e01682b39b02292eb74729bdPavel Březina *_primary_servers = talloc_steal(mem_ctx, state->primary_servers);
88275cccddf39892e01682b39b02292eb74729bdPavel Březina *_num_primary_servers = state->num_primary_servers;
88275cccddf39892e01682b39b02292eb74729bdPavel Březina *_backup_servers = talloc_steal(mem_ctx, state->backup_servers);
88275cccddf39892e01682b39b02292eb74729bdPavel Březina *_num_backup_servers = state->num_backup_servers;