796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher Stephen Gallagher <sgallagh@redhat.com>
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher Copyright (C) 2012 Red Hat
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher This program is free software; you can redistribute it and/or modify
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher it under the terms of the GNU General Public License as published by
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher the Free Software Foundation; either version 3 of the License, or
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher (at your option) any later version.
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher This program is distributed in the hope that it will be useful,
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher but WITHOUT ANY WARRANTY; without even the implied warranty of
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher GNU General Public License for more details.
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher You should have received a copy of the GNU General Public License
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher along with this program. If not, see <http://www.gnu.org/licenses/>.
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagherservices_get_retry(struct tevent_req *req);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagherservices_get_connect_done(struct tevent_req *subreq);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagherservices_get_done(struct tevent_req *subreq);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher req = tevent_req_create(mem_ctx, &state, struct sdap_services_get_state);
9aa117a93e315f790a1922d9ac7bd484878b621eJakub Hrozek state->op = sdap_id_op_create(state, state->conn->conn_cache);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_MINOR_FAILURE, "sdap_id_op_create failed\n");
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher attr_name = id_ctx->opts->service_map[SDAP_AT_SERVICE_NAME].name;
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher attr_name = id_ctx->opts->service_map[SDAP_AT_SERVICE_PORT].name;
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher ret = sss_filter_sanitize(state, name, &clean_name);
e4ba22c165be4b0ccd0e1b9fc92f2f1e35f78a82Petr Cech ret = sss_filter_sanitize(state, protocol, &clean_protocol);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher state, "(&(%s=%s)(%s=%s)(objectclass=%s))",
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher id_ctx->opts->service_map[SDAP_AT_SERVICE_PROTOCOL].name,
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher id_ctx->opts->service_map[SDAP_OC_SERVICE].name);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher talloc_asprintf(state, "(&(%s=%s)(objectclass=%s))",
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher id_ctx->opts->service_map[SDAP_OC_SERVICE].name);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Failed to build the base filter\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Preparing to search for services with filter [%s]\n",
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher ret = build_attrs_from_map(state, id_ctx->opts->service_map,
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher tevent_req_data(req, struct sdap_services_get_state);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher subreq = sdap_id_op_connect_send(state->op, state, &ret);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher tevent_req_set_callback(subreq, services_get_connect_done, req);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagherservices_get_connect_done(struct tevent_req *subreq)
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher tevent_req_callback_data(subreq, struct tevent_req);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher tevent_req_data(req, struct sdap_services_get_state);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher ret = sdap_id_op_connect_recv(subreq, &dp_error);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher subreq = sdap_get_services_send(state, state->ev,
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher dp_opt_get_int(state->id_ctx->opts->basic,
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher tevent_req_set_callback(subreq, services_get_done, req);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagherservices_get_done(struct tevent_req *subreq)
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher tevent_req_callback_data(subreq, struct tevent_req);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher tevent_req_data(req, struct sdap_services_get_state);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher ret = sdap_get_services_recv(NULL, subreq, NULL);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher /* Check whether we need to try again with another
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher * failover server.
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher ret = sdap_id_op_done(state->op, ret, &dp_error);
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher if (dp_error == DP_ERR_OK && ret != EOK) {
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher /* Return to the mainloop to retry */
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher /* An error occurred. */
ca344fdecdf127c80ad1074047aeba21e1165313Jakub Hrozek if (ret == ENOENT && state->noexist_delete == true) {
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher /* Ensure that this entry is removed from the sysdb */
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zidek ret = sysdb_svc_delete(state->domain, state->name,
796463906a54e259bd5b582ce84af4297a58eafcStephen Gallagher port = strtouint16(state->name, NULL, 10);
4fcc50e133f90cd4c5931a3ac48c84cb628b16fcMichal Zidek ret = sysdb_svc_delete(state->domain, NULL, port,
ca344fdecdf127c80ad1074047aeba21e1165313Jakub Hrozekservices_get_recv(struct tevent_req *req, int *dp_error_out, int *sdap_ret)