ipa_subdomains.c revision e438fbf102c3d787902504bdae177e84230cbbc9
97018cf5fa25b494adffd7e9b4e87320dae6bf47Christian Maeder IPA Subdomains Module
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder Sumit Bose <sbose@redhat.com>
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder Copyright (C) 2011 Red Hat
679d3f541f7a9ede4079e045f7758873bb901872Till Mossakowski This program is free software; you can redistribute it and/or modify
679d3f541f7a9ede4079e045f7758873bb901872Till Mossakowski it under the terms of the GNU General Public License as published by
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder the Free Software Foundation; either version 3 of the License, or
306763c67bb99228487345b32ab8c5c6cd41f23cChristian Maeder (at your option) any later version.
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder This program is distributed in the hope that it will be useful,
d21dd452cd68abade683103a5c0cfe6d02c5f17bTill Mossakowski but WITHOUT ANY WARRANTY; without even the implied warranty of
d21dd452cd68abade683103a5c0cfe6d02c5f17bTill Mossakowski MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder GNU General Public License for more details.
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder You should have received a copy of the GNU General Public License
c83546084a1344bb2ef752b83d0e082823508db2Christian Maeder along with this program. If not, see <http://www.gnu.org/licenses/>.
2d2826f9db2c17275f91b0104940a60a2f9fd44dChristian Maeder#define SUBDOMAINS_FILTER "objectclass=ipaNTTrustedDomain"
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder#define MASTER_DOMAIN_FILTER "objectclass=ipaNTDomainAttrs"
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder#define RANGE_FILTER "objectclass=ipaIDRange"
ba904a15082557e939db689fcfba0c68c9a4f740Christian Maeder#define IPA_TRUSTED_DOMAIN_SID "ipaNTTrustedDomainSID"
89ab08979dc23d72e9e09c8990a8c44847041d6fChristian Maeder#define IPA_SECONDARY_BASE_RID "ipaSecondaryBaseRID"
43b4c41fbb07705c9df321221ab9cb9832460407Christian Maeder#define IPA_ASSIGNED_ID_VIEW "ipaAssignedIDView"
b9804822fb178b0fc27ce967a6a8cedc42c5bf90Christian Maeder/* do not refresh more often than every 5 seconds for now */
daec53c285f692c56db0cefe16061b46ba602cf0Christian Maeder struct sdap_search_base **master_search_bases;
c83546084a1344bb2ef752b83d0e082823508db2Christian Maeder struct sdap_search_base **ranges_search_bases;
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski struct sdap_search_base **host_search_bases;
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maederstatic void ipa_subdomains_done(struct ipa_subdomains_ctx *sd_ctx,
dc8100ead1e97ea34c9ff3fe4af14d37510bf8aeChristian Maeder return be_req_terminate(req, dp_err, error, errstr);
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maederstruct be_ctx *ipa_get_subdomains_be_ctx(struct be_ctx *be_ctx)
f0e85ee7e4accfc01f46aa0363acc59fcd248e8aTill Mossakowski subdom_ctx = talloc_get_type(be_ctx->bet_info[BET_SUBDOMAINS].pvt_bet_data,
3bcd9d942601d59dd55a6069d8b2d1c33d7ced0eChristian Maeder DEBUG(SSSDBG_TRACE_ALL, "Subdomains are not configured.\n");
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder ad_options = ad_create_default_options(id_ctx, id_ctx->server_mode->realm,
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "Cannot initialize AD options\n");
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder ret = dp_opt_set_string(ad_options->basic, AD_DOMAIN, ad_domain);
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "Cannot set AD domain\n");
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder ret = dp_opt_set_string(ad_options->basic, AD_KRB5_REALM,
99aecbb3a3f935dd4663a45760a703faabdd04fbChristian Maeder DEBUG(SSSDBG_OP_FAILURE, "Cannot set AD realm\n");
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder extra_attrs = dp_opt_get_string(id_ctx->sdap_id_ctx->opts->basic,
dc8100ead1e97ea34c9ff3fe4af14d37510bf8aeChristian Maeder "Setting extra attrs for subdomain [%s] to [%s].\n", ad_domain,
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder ret = dp_opt_set_string(ad_options->id->basic, SDAP_USER_EXTRA_ATTRS,
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder DEBUG(SSSDBG_OP_FAILURE, "dp_opt_get_string failed.\n");
7297175957c5ad3c0498032190b1dee9ec5fb873Christian Maeder ret = sdap_extend_map_with_list(ad_options->id, ad_options->id,
f1d04fe5072b827d9cc490ebdbca78108241a392Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "sdap_extend_map_with_list failed.\n");
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder DEBUG(SSSDBG_TRACE_ALL, "No extra attrs set.\n");
26ed2a19326560786ff94dfc462309d6d5d862a8Heng Jiang gc_service_name = talloc_asprintf(ad_options, "%s%s", "gc_", subdom->name);
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski /* Set KRB5 realm to same as the one of IPA when IPA
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski * is able to attach PAC. For testing, use hardcoded. */
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder ret = ad_failover_init(ad_options, be_ctx, NULL, NULL,
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "Cannot initialize AD failover\n");
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder ad_id_ctx = ad_id_ctx_init(ad_options, be_ctx);
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder ad_id_ctx->sdap_id_ctx->opts = ad_options->id;
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder ad_site_override = dp_opt_get_string(ad_options->basic, AD_SITE);
8db14bfdbfec2f153de435718d748fe5e22fd634Heng Jiang /* use AD plugin */
ff49754b0e0b7ca133a66ce6c0b240c55128cde1Heng Jiang srv_ctx = ad_srv_plugin_ctx_init(be_ctx, be_ctx->be_res,
7297175957c5ad3c0498032190b1dee9ec5fb873Christian Maeder DEBUG(SSSDBG_FATAL_FAILURE, "Out of memory?\n");
26ed2a19326560786ff94dfc462309d6d5d862a8Heng Jiang be_fo_set_srv_lookup_plugin(be_ctx, ad_srv_plugin_send,
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder ret = sdap_domain_subdom_add(ad_id_ctx->sdap_id_ctx,
7297175957c5ad3c0498032190b1dee9ec5fb873Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "Cannot initialize sdap domain\n");
7297175957c5ad3c0498032190b1dee9ec5fb873Christian Maeder sdom = sdap_domain_get(ad_id_ctx->sdap_id_ctx->opts, subdom);
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski /* Set up the ID mapping object */
89ab08979dc23d72e9e09c8990a8c44847041d6fChristian Maeder ret = ipa_ad_ctx_new(be_ctx, id_ctx, subdom, &ad_id_ctx);
c3a264bbb3692f9b44024c6024382e3ed6590688Christian Maeder "Cannot create ad_id_ctx for subdomain %s\n", subdom->name);
21dae7237ac384abdb94a81e00b3f099873ec623Till Mossakowski trust_ctx = talloc(id_ctx->server_mode, struct ipa_ad_server_ctx);
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder DLIST_ADD(id_ctx->server_mode->trusts, trust_ctx);
2d2826f9db2c17275f91b0104940a60a2f9fd44dChristian Maederipa_ad_subdom_refresh(struct be_ctx *be_ctx,
e182d0ec56025d97d74829cac75ee31eec12b093Maciek Makowski if (dp_opt_get_bool(id_ctx->ipa_options->basic,
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder dom && IS_SUBDOMAIN(dom); /* if we get back to a parent, stop */
89ab08979dc23d72e9e09c8990a8c44847041d6fChristian Maeder /* Check if we already have an ID context for this subdomain */
c3a264bbb3692f9b44024c6024382e3ed6590688Christian Maeder DLIST_FOR_EACH(trust_iter, id_ctx->server_mode->trusts) {
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder /* Newly detected trust */
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder ret = ipa_server_trust_add(be_ctx, id_ctx, dom);
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder "Cannot create ad_id_ctx for subdomain %s\n",
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maederipa_subdom_reinit(struct ipa_subdomains_ctx *ctx)
b4b6cffb6746d672e2bb558b72f616f97ac98316Till Mossakowski dp_opt_get_string(ctx->id_ctx->ipa_options->basic,
b4b6cffb6746d672e2bb558b72f616f97ac98316Till Mossakowski DEBUG(SSSDBG_MINOR_FAILURE, "sss_write_krb5_conf_snippet failed.\n");
b4b6cffb6746d672e2bb558b72f616f97ac98316Till Mossakowski /* Just continue */
0e4b70274950d17f45c85d124bc600921e70fd87Christian Maeder ret = sysdb_update_subdomains(ctx->be_ctx->domain);
2d2826f9db2c17275f91b0104940a60a2f9fd44dChristian Maeder DEBUG(SSSDBG_OP_FAILURE, "sysdb_update_subdomains failed.\n");
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder ret = sss_write_domain_mappings(ctx->be_ctx->domain);
948f37fdb71c544ff4c907bc5863702648cf36e4Christian Maeder "sss_krb5_write_mappings failed.\n");
948f37fdb71c544ff4c907bc5863702648cf36e4Christian Maeder /* Just continue */
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maederipa_ad_subdom_remove(struct ipa_subdomains_ctx *ctx,
7f7460e7095628f3437b116ee78d3043d11f8febChristian Maeder if (dp_opt_get_bool(ctx->id_ctx->ipa_options->basic,
2d2826f9db2c17275f91b0104940a60a2f9fd44dChristian Maeder DLIST_FOR_EACH(iter, ctx->id_ctx->server_mode->trusts) {
b645cf3dc1e449038ed291bbd11fcc6e02b2fc7fChristian Maeder DEBUG(SSSDBG_CRIT_FAILURE, "No IPA-AD context for subdomain %s\n",
b03274844ecd270f9e9331f51cc4236a33e2e671Christian Maeder sdom = sdap_domain_get(iter->ad_id_ctx->sdap_id_ctx->opts, subdom);
1b05bdb88b90d3c947351f262d7ae7d68f0a4a6fTill Mossakowski sdap_domain_remove(iter->ad_id_ctx->sdap_id_ctx->opts, subdom);
587fb54160b66128cf17e4c9bca7494a7f2c3c4aChristian Maeder DLIST_REMOVE(ctx->id_ctx->server_mode->trusts, iter);
7bf4436b6f9987b070033a323757b206c898c1beChristian Maeder /* terminate all requests for this subdomain so we can free it */
7bf4436b6f9987b070033a323757b206c898c1beChristian Maeder be_terminate_domain_requests(ctx->be_ctx, subdom->name);
58b671de3fe578346fef9642ffa3c5a0a0edb3cbTill Mossakowskiconst char *get_flat_name_from_subdomain_name(struct be_ctx *be_ctx,
4ea99e115bbade1632815267d5e0dcb9931aac1eChristian Maeder ctx = talloc_get_type(be_ctx->bet_info[BET_SUBDOMAINS].pvt_bet_data,
b9804822fb178b0fc27ce967a6a8cedc42c5bf90Christian Maeder DEBUG(SSSDBG_TRACE_ALL, "Subdomains are not configured.\n");
89ab08979dc23d72e9e09c8990a8c44847041d6fChristian Maeder dom = find_domain_by_name(ctx->be_ctx->domain, name, true);
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maederstatic errno_t ipa_ranges_parse_results(TALLOC_CTX *mem_ctx,
2d2826f9db2c17275f91b0104940a60a2f9fd44dChristian Maeder range_list = talloc_array(mem_ctx, struct range_info *, count + 1);
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "talloc_array failed.\n");
aebf36d7483e5c012eff154d0b76de400d8fe3fcTill Mossakowski for (c = 0; c < count; c++) {
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder r = talloc_zero(range_list, struct range_info);
95c3e5d11dcee331dc3876a9bf0c1d6daa38e2caChristian Maeder DEBUG(SSSDBG_OP_FAILURE, "talloc_zero failed.\n");
e953bea49e7f0e1a43bccf2a66c5e2a2b50848e0Christian Maeder ret = sysdb_attrs_get_string(reply[c], IPA_CN, &value);
b9804822fb178b0fc27ce967a6a8cedc42c5bf90Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
2d2826f9db2c17275f91b0104940a60a2f9fd44dChristian Maeder DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
b9804822fb178b0fc27ce967a6a8cedc42c5bf90Christian Maeder ret = sysdb_attrs_get_string(reply[c], IPA_TRUSTED_DOMAIN_SID, &value);
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder r->trusted_dom_sid = talloc_strdup(r, value);
c092fcac4b8f5c524c22ca579189c4487c13edf7Christian Maeder DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
2d2826f9db2c17275f91b0104940a60a2f9fd44dChristian Maeder DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
d21dd452cd68abade683103a5c0cfe6d02c5f17bTill Mossakowski ret = sysdb_attrs_get_uint32_t(reply[c], IPA_BASE_ID,
goto done;
&r->id_range_size);
goto done;
&r->base_rid);
goto done;
&r->secondary_base_rid);
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
range_list[c] = r;
done:
return ret;
bool *_enumerates)
const char *name;
return ret;
return EOK;
char **_forest)
int ret;
const char *orig_dn;
if (ret) {
goto done;
orig_dn);
goto done;
orig_dn);
goto done;
goto done;
goto done;
goto done;
goto done;
done:
return ret;
bool enumerate)
const char *name;
char *realm;
const char *flat;
const char *id;
int ret;
bool mpg;
return ENOMEM;
goto done;
if (!realm) {
goto done;
if (ret) {
goto done;
if (ret) {
goto done;
goto done;
if (ret) {
goto done;
done:
return ret;
bool *changes)
const char *value;
int ret;
bool enumerate;
for (c = 0; c < count; c++) {
if (handled[c]) {
goto done;
if (c >= count) {
goto done;
goto done;
if (ret) {
handled[c] = true;
if (count == h) {
goto done;
*changes = true;
for (c = 0; c < count; c++) {
if (handled[c]) {
goto done;
if (ret) {
done:
return ret;
struct ipa_subdomains_req_ctx {
char *current_filter;
int search_base_iter;
static errno_t
{ RANGE_FILTER,
int ret;
goto done;
goto done;
goto done;
done:
int ret;
if (ret) {
goto fail;
goto fail;
fail:
static errno_t
return EINVAL;
return EOK;
return ENOMEM;
SDAP_SEARCH_TIMEOUT), false);
return ENOMEM;
return EAGAIN;
return ENOMEM;
return EOK;
return ENOMEM;
return EAGAIN;
int ret;
int sret;
const char *view_name;
goto done;
goto done;
if (reply_count == 0) {
goto done;
goto done;
&view_name);
goto done;
goto done;
SYSDB_DEFAULT_VIEW_NAME) != 0) {
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
goto done;
done:
int ret;
bool refresh_has_changes = false;
goto done;
if (reply_count) {
goto done;
goto done;
goto done;
if (refresh_has_changes) {
goto done;
domain);
goto done;
IPA_HOSTNAME));
goto done;
goto done;
goto done;
done:
int ret;
return ret;
return EAGAIN;
return ret;
return EOK;
goto done;
goto done;
goto done;
goto done;
done:
goto done;
if (reply_count) {
goto done;
goto done;
goto done;
done:
void *pvt)
const char *errstr)
if (!ctx) {
if (ctx) {
bool *configured_explicit)
int ret;
char *tmp_str;
return ENOMEM;
&tmp_str);
goto done;
*configured_explicit = false;
*configured_explicit = true;
done:
return ret;
struct ipa_subdomains_ctx);
if (!ctx) {
void **pvt_data)
int ret;
bool configured_explicit = false;
return ret;
return ENOMEM;
NULL);
return EOK;
char *realm;
char *hostname;
IPA_SERVER_MODE) == false) {
return EOK;
CONFDB_DEFAULT_FULL_NAME_FORMAT_INTERNAL) != 0)) {
return EINVAL;
return EINVAL;
return ENOMEM;
return ret;
return EOK;