cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek LDAP handler for autofs
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek Copyright (C) 2012 Red Hat
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek This program is free software; you can redistribute it and/or modify
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek it under the terms of the GNU General Public License as published by
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek the Free Software Foundation; either version 3 of the License, or
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek (at your option) any later version.
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek This program is distributed in the hope that it will be useful,
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek GNU General Public License for more details.
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek You should have received a copy of the GNU General Public License
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozeksdap_autofs_get_map_retry(struct tevent_req *req);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozeksdap_autofs_get_map_connect_done(struct tevent_req *subreq);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozeksdap_autofs_get_map_done(struct tevent_req *req);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozekstatic struct tevent_req *
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek req = tevent_req_create(mem_ctx, &state, struct autofs_get_map_state);
dcb44c39dda9699cdd6488fd116a51ced0687de3Jakub Hrozek state->op = sdap_id_op_create(state, state->ctx->conn->conn_cache);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create failed\n");
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozeksdap_autofs_get_map_retry(struct tevent_req *req)
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek tevent_req_data(req, struct autofs_get_map_state);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek subreq = sdap_id_op_connect_send(state->op, state, &ret);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek tevent_req_set_callback(subreq, sdap_autofs_get_map_connect_done, req);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozeksdap_autofs_get_map_connect_done(struct tevent_req *subreq)
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek struct tevent_req *req = tevent_req_callback_data(subreq,
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek tevent_req_data(req, struct autofs_get_map_state);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek ret = sdap_id_op_connect_recv(subreq, &dp_error);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek subreq = sdap_autofs_setautomntent_send(state, state->ev,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "sdap_autofs_setautomntent_send failed\n");
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek tevent_req_set_callback(subreq, sdap_autofs_get_map_done, req);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozeksdap_autofs_get_map_done(struct tevent_req *subreq)
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek struct tevent_req *req = tevent_req_callback_data(subreq,
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek tevent_req_data(req, struct autofs_get_map_state);
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek ret = sdap_id_op_done(state->op, ret, &dp_error);
e7d1cd14ce1a427007b1a7e9789dcb7e9619f84fJakub Hrozek ret = sysdb_delete_autofsmap(state->ctx->be->domain, state->map_name);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Cannot delete autofs map %s [%d]: %s\n",
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozeksdap_autofs_get_map_recv(struct tevent_req *req, int *dp_error_out)
cc84fd46f356c4a36a721ab135a33ec77c93e34dJakub Hrozek tevent_req_data(req, struct autofs_get_map_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void sdap_autofs_handler_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina req = tevent_req_create(mem_ctx, &state, struct sdap_autofs_handler_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_FUNC_DATA, "Requested refresh for: %s\n", data->mapname);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina master_map = dp_opt_get_string(id_ctx->opts->basic,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_FUNC_DATA, "Refresh of automount master map triggered: "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sysdb_invalidate_autofs_maps(id_ctx->be->domain);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_MINOR_FAILURE, "Could not invalidate autofs maps, "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina "backend might return stale entries\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = sdap_autofs_get_map_send(mem_ctx, params->ev,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to send request for %s.\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, sdap_autofs_handler_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina dp_reply_std_set(&state->reply, DP_ERR_DECIDE, ret, NULL);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* TODO For backward compatibility we always return EOK to DP now. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void sdap_autofs_handler_done(struct tevent_req *subreq)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina state = tevent_req_data(req, struct sdap_autofs_handler_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sdap_autofs_get_map_recv(subreq, &dp_error);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* TODO For backward compatibility we always return EOK to DP now. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina dp_reply_std_set(&state->reply, dp_error, ret, NULL);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina struct sdap_autofs_handler_state *state = NULL;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina state = tevent_req_data(req, struct sdap_autofs_handler_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_INTERNAL, "Initializing autofs LDAP back end\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = ldap_get_autofs_options(id_ctx, be_ctx->cdb, be_ctx->conf_path,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sdap_autofs_handler_send, sdap_autofs_handler_recv, id_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina struct sdap_id_ctx, struct dp_autofs_data, struct dp_reply_std);