ipa_sudo.c revision 4ddd5591c50e27dffa55f03fbce0dcc85cd50a8b
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen Pavel Březina <pbrezina@redhat.com>
bdd36cfdba3ff66d25570a9ff568d69e1eb543cfTimo Sirainen Copyright (C) 2015 Red Hat
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen This program is free software; you can redistribute it and/or modify
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen it under the terms of the GNU General Public License as published by
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen the Free Software Foundation; either version 3 of the License, or
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen (at your option) any later version.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen This program is distributed in the hope that it will be useful,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen but WITHOUT ANY WARRANTY; without even the implied warranty of
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen GNU General Public License for more details.
4fda77c9e9fc68feb292c4dacae1fac49dd08165Timo Sirainen You should have received a copy of the GNU General Public License
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen along with this program. If not, see <http://www.gnu.org/licenses/>.
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenstatic void ipa_sudo_handler(struct be_req *breq);
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenipa_sudo_choose_schema(struct dp_option *ipa_opts,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "talloc_new() failed\n");
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen ret = domain_to_basedn(tmp_ctx, dp_opt_get_string(ipa_opts,
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Unable to obtain basedn\n");
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen ipa_search_base = talloc_asprintf(tmp_ctx, "cn=sudo,%s", basedn);
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen search_base = dp_opt_get_string(sdap_opts, SDAP_SUDO_SEARCH_BASE);
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen ret = dp_opt_set_string(sdap_opts, SDAP_SUDO_SEARCH_BASE,
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen DEBUG(SSSDBG_TRACE_FUNC, "Option %s set to %s\n",
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen sdap_opts[SDAP_SUDO_SEARCH_BASE].opt_name, ipa_search_base);
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen /* Use IPA schema only if search base is cn=sudo,$dc. */
8b16d3b00f051401c97568697ccdbba48663759aTimo Sirainen if (strcmp(ipa_search_base, search_base) == 0) {
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainenipa_sudo_init_ipa_schema(struct be_ctx *be_ctx,
4fda77c9e9fc68feb292c4dacae1fac49dd08165Timo Sirainen sudo_ctx = talloc_zero(be_ctx, struct ipa_sudo_ctx);
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen sudo_ctx->sdap_opts = id_ctx->sdap_id_ctx->opts;
4fda77c9e9fc68feb292c4dacae1fac49dd08165Timo Sirainen ret = sdap_get_map(sudo_ctx, be_ctx->cdb, be_ctx->conf_path,
4fda77c9e9fc68feb292c4dacae1fac49dd08165Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Unable to parse attribute map "
8c2b4a45f17a5cb13bb01058ca37798cf48d91baTimo Sirainen ret = sdap_get_map(sudo_ctx, be_ctx->cdb, be_ctx->conf_path,
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Unable to parse attribute map "
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen ret = sdap_get_map(sudo_ctx, be_ctx->cdb, be_ctx->conf_path,
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Unable to parse attribute map "
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen ret = sdap_parse_search_base(sudo_ctx, sudo_ctx->sdap_opts->basic,
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen DEBUG(SSSDBG_OP_FAILURE, "Could not parse sudo search base\n");
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen DEBUG(SSSDBG_TRACE_INTERNAL, "Initializing IPA sudo back end\n");
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen ret = ipa_sudo_choose_schema(id_ctx->ipa_options->basic,
e2a88d59c0d47d63ce1ad5b1fd95e487124a3fd4Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Unable to choose sudo schema [%d]: %s\n",
e4194f4703eeec32b432371ae30fc8f25ab720d8Timo Sirainen DEBUG(SSSDBG_TRACE_FUNC, "Using IPA schema for sudo\n");
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen ret = ipa_sudo_init_ipa_schema(be_ctx, id_ctx, ops, pvt_data);
cf9d67e4a9bfee31cf3be05244555d51a3d1b9feTimo Sirainen DEBUG(SSSDBG_TRACE_FUNC, "Using LDAP schema for sudo\n");
2670cd577aa57eb9f915a4f4220ae48c9b4fc5fbTimo Sirainen ret = sdap_sudo_init(be_ctx, id_ctx->sdap_id_ctx, ops, pvt_data);
3c296d819c54e21ce05c3d2eeeedc79be42ac593Timo Sirainen DEBUG(SSSDBG_CRIT_FAILURE, "Unable to initialize sudo provider"
cf9d67e4a9bfee31cf3be05244555d51a3d1b9feTimo Sirainen sdap_handler_done(be_req, DP_ERR_FATAL, ERR_INTERNAL, "Not implemented yet.");