81165faf5d951aca69f410713730c26ff048ec44Sumit Bose IPA Subdomains Module
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose Sumit Bose <sbose@redhat.com>
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose Copyright (C) 2011 Red Hat
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose This program is free software; you can redistribute it and/or modify
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose it under the terms of the GNU General Public License as published by
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose the Free Software Foundation; either version 3 of the License, or
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose (at your option) any later version.
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose This program is distributed in the hope that it will be useful,
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose but WITHOUT ANY WARRANTY; without even the implied warranty of
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose GNU General Public License for more details.
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose You should have received a copy of the GNU General Public License
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose along with this program. If not, see <http://www.gnu.org/licenses/>.
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose#define SUBDOMAINS_FILTER "objectclass=ipaNTTrustedDomain"
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny#define MASTER_DOMAIN_FILTER "objectclass=ipaNTDomainAttrs"
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose#define IPA_TRUSTED_DOMAIN_SID "ipaNTTrustedDomainSID"
39f21d2b61685362642d42bc2f94f829671cd5efSumit Bose#define IPA_ADDITIONAL_SUFFIXES "ipaNTAdditionalSuffixes"
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose#define IPA_SECONDARY_BASE_RID "ipaSecondaryBaseRID"
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce/* do not refresh more often than every 5 seconds for now */
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozekipa_subdom_reinit(struct ipa_subdomains_ctx *ctx)
c3243e3212f91b69ef9990e2cb4c9339bf2f7888Jakub Hrozek "Re-initializing domain %s\n", ctx->be_ctx->domain->name);
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose if (ctx->ipa_id_ctx->ipa_options->auth_ctx != NULL
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose && ctx->ipa_id_ctx->ipa_options->auth_ctx->krb5_auth_ctx != NULL
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose && ctx->ipa_id_ctx->ipa_options->auth_ctx->krb5_auth_ctx->opts != NULL
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose ctx->ipa_id_ctx->ipa_options->auth_ctx->krb5_auth_ctx->opts,
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose DEBUG(SSSDBG_CONF_SETTINGS, "Auth provider data is not available, "
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose "most probably because the auth provider "
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose "is not 'ipa'. Kerberos configuration "
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose "snippet to set the 'canonicalize' option "
ea11ed3ea6291488dd762033246edc4ce3951aebSumit Bose "will not be created.\n");
e6b6b9fa79c67d7d2698bc7e33d2e2f6bb53d483Sumit Bose dp_opt_get_string(ctx->ipa_id_ctx->ipa_options->basic,
4fa184e2c60b377fd71e0115a618bd68dc73627dSumit Bose DEBUG(SSSDBG_MINOR_FAILURE, "sss_write_krb5_conf_snippet failed.\n");
4fa184e2c60b377fd71e0115a618bd68dc73627dSumit Bose /* Just continue */
c3243e3212f91b69ef9990e2cb4c9339bf2f7888Jakub Hrozek ret = sysdb_master_domain_update(ctx->be_ctx->domain);
c3243e3212f91b69ef9990e2cb4c9339bf2f7888Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "sysdb_master_domain_update failed.\n");
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek ret = sysdb_update_subdomains(ctx->be_ctx->domain);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_update_subdomains failed.\n");
06424c5ac5ffb871476208155762bb5b73e0b665Jakub Hrozek ret = sss_write_domain_mappings(ctx->be_ctx->domain);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "sss_krb5_write_mappings failed.\n");
d2a8b08561e6700bdd4feb988becae4e8f5368ddJakub Hrozek /* Just continue */
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bosestatic errno_t ipa_ranges_parse_results(TALLOC_CTX *mem_ctx,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose range_list = talloc_array(mem_ctx, struct range_info *, count + 1);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "talloc_array failed.\n");
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose for (c = 0; c < count; c++) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "talloc_zero failed.\n");
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_string(reply[c], IPA_CN, &value);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_string(reply[c], IPA_TRUSTED_DOMAIN_SID, &value);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_BASE_ID,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_ID_RANGE_SIZE,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_BASE_RID,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_SECONDARY_BASE_RID,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
5e60c73cb91d1659755fb5ea829837db68d46163Sumit Bose ret = sysdb_attrs_get_string(reply[c], IPA_RANGE_TYPE, &value);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
5e60c73cb91d1659755fb5ea829837db68d46163Sumit Bose /* Older IPA servers might not have the range_type attribute, but
5e60c73cb91d1659755fb5ea829837db68d46163Sumit Bose * only support local ranges and trusts with algorithmic mapping. */
096a9678919fae460342469989b97fd47d812823Sumit Bose r->range_type = talloc_strdup(r, IPA_RANGE_LOCAL);
096a9678919fae460342469989b97fd47d812823Sumit Bose r->range_type = talloc_strdup(r, IPA_RANGE_AD_TRUST);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "talloc_strdup failed.\n");
096a9678919fae460342469989b97fd47d812823Sumit Bose ret = get_idmap_data_from_range(r, domain_name, &name1, &sid1, &rid1,
db5f9ab3feb85aa444eab20428ca2b98801b6783Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "get_idmap_data_from_range failed.\n");
096a9678919fae460342469989b97fd47d812823Sumit Bose for (d = 0; d < c; d++) {
096a9678919fae460342469989b97fd47d812823Sumit Bose ret = get_idmap_data_from_range(range_list[d], domain_name, &name2,
db5f9ab3feb85aa444eab20428ca2b98801b6783Jakub Hrozek "get_idmap_data_from_range failed.\n");
096a9678919fae460342469989b97fd47d812823Sumit Bose err = sss_idmap_check_collision_ex(name1, sid1, &range1, rid1,
096a9678919fae460342469989b97fd47d812823Sumit Bose "Collision of ranges [%s] and [%s] detected.\n",
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozekstatic errno_t ipa_subdom_enumerates(struct sss_domain_info *parent,
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozek ret = sysdb_attrs_get_string(attrs, IPA_CN, &name);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozek *_enumerates = subdomain_enumerates(parent, name);
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bosestatic errno_t ipa_subdom_get_forest(TALLOC_CTX *mem_ctx,
89ddc9ed474e9ac2b1e7bccb0a58610babf26cf8Jakub Hrozek dn = ipa_subdom_ldb_dn(mem_ctx, ldb_ctx, attrs);
89ddc9ed474e9ac2b1e7bccb0a58610babf26cf8Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "ipa_subdom_ldb_dn failed.\n");
10bf907b6d463a5cd776a056cb182bc9f8765bf4Jakub Hrozek ret = sysdb_attrs_get_string(attrs, IPA_CN, &name);
10bf907b6d463a5cd776a056cb182bc9f8765bf4Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
10bf907b6d463a5cd776a056cb182bc9f8765bf4Jakub Hrozek DEBUG(SSSDBG_OP_FAILURE, "talloc_strndup failed.\n");
10bf907b6d463a5cd776a056cb182bc9f8765bf4Jakub Hrozek DEBUG(SSSDBG_TRACE_INTERNAL, "The forest name is %s\n", forest);
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose forest = talloc_strndup(mem_ctx, (const char *) val->data, val->length);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "talloc_strndup failed.\n");
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozekstatic errno_t ipa_get_sd_trust_direction(struct sysdb_attrs *sd,
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek return ipa_server_get_trust_direction(sd, ldb_ctx, _direction);
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek /* Clients do not have access to the trust objects's trust direction
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek * and don't generally care
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozekstatic errno_t ipa_subdom_store(struct sss_domain_info *parent,
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose struct ldb_message_element *alternative_domain_suffixes = NULL;
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce ret = sysdb_attrs_get_string(attrs, IPA_CN, &name);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce ret = sysdb_attrs_get_string(attrs, IPA_FLATNAME, &flat);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce ret = sysdb_attrs_get_string(attrs, IPA_TRUSTED_DOMAIN_SID, &id);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
20348a30feb4be619b3b691c24c9be8131507c46Sumit Bose ret = sysdb_attrs_get_el_ext(attrs, IPA_ADDITIONAL_SUFFIXES, false,
fdda4b659fa3be3027df91a2b053835186ec2c59Sumit Bose mpg = sdap_idmap_domain_has_algorithmic_mapping(sdap_idmap_ctx, name, id);
c5711b0279ea85d69fe3c77dfb194360c346e1d7Sumit Bose ret = ipa_subdom_get_forest(tmp_ctx, sysdb_ctx_get_ldb(parent->sysdb),
9b7762729da24a901388ea53da29448f23e0f77bJakub Hrozek ret = ipa_subdom_enumerates(parent, attrs, &enumerate);
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek ret = ipa_get_sd_trust_direction(attrs, id_ctx,
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek "ipa_get_sd_trust_direction failed: %d\n", ret);
2427b40566cf63880f3650b26a2fee91cb28de24Petr Cech "Trust type of [%s]: %s\n", name, ipa_trust_dir2str(direction));
31dd31b00ad759f256282ef0f7054e60672161ceJakub Hrozek ret = sysdb_subdomain_store(parent->sysdb, name, realm, flat,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_subdomain_store failed.\n");
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozekstatic void ipa_subdom_store_step(struct sss_domain_info *parent,
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek ret = ipa_subdom_store(parent, id_ctx, sdap_idmap_ctx, attrs);
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek DEBUG(SSSDBG_MINOR_FAILURE, "Unsupported trust type, skipping\n");
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek } else if (ret) {
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek /* Nothing we can do about the error. */
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek DEBUG(SSSDBG_MINOR_FAILURE, "Failed to parse subdom data, "
05d935cc9d04f03522d0bb44598d22d99b085926Jakub Hrozek "will try to use cached subdomain\n");
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorcestatic errno_t ipa_subdomains_refresh(struct ipa_subdomains_ctx *ctx,
95e94691178297f2b8225a83d43ae388cab04b45Simo Sorce /* check existing subdomains */
877b92e80bde510d5cd9f03dbf01e2bcf73ab072Michal Židek for (dom = get_next_domain(parent, SSS_GND_DESCEND);
4f118e3e6a25762f40a43e6dbefb09f44adbef32Simo Sorce dom && IS_SUBDOMAIN(dom); /* if we get back to a parent, stop */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce for (c = 0; c < count; c++) {
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = sysdb_attrs_get_string(reply[c], IPA_CN, &value);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* ok this subdomain does not exist anymore, let's clean up */
bba1a5fd62cffcae076d1351df5a83fbc4a6ec17Simo Sorce ret = sysdb_subdomain_delete(dom->sysdb, dom->name);
418e6ccd116eced7ccc75aca999a4c37c67289baJakub Hrozek /* Remove the AD ID ctx from the list of LDAP domains */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ipa_ad_subdom_remove(ctx->be_ctx, ctx->ipa_id_ctx, dom);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* ok let's try to update it */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ipa_subdom_store_step(parent, ctx->ipa_id_ctx,
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* all domains were already accounted for and have been updated */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* if we get here it means we have changes to the subdomains list */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce for (c = 0; c < count; c++) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ipa_subdom_store_step(parent, ctx->ipa_id_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_apply_view(struct sss_domain_info *domain,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_ALL, "read_at_init [%s] current view [%s]\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina read_at_init ? "true" : "false", ipa_id_ctx->view_name);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (current != NULL && strcmp(current, view_name) != 0 && read_at_init) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "View name changed, this is not supported "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina "at runtime. Please restart SSSD to get the new view applied.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (current != NULL && strcmp(current, view_name) == 0) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "View name did not change.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "View name changed to [%s].\n", view_name);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* View name changed. If there was a non-default non-local view
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * was used the tree in cache containing the override values is
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * removed. In all cases sysdb_invalidate_overrides() is called to
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * remove the override attribute from the cached user objects.
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * Typically ctx->sd_ctx->id_ctx->view_name == NULL means that the
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * cache was empty but there was a bug in with caused that the
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * view name was not written to the cache at all. In this case the
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * cache must be invalidated if the new view is not the
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * default-view as well. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (current != NULL || !is_default_view(view_name)) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Unable to start transaction "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (!is_default_view(current) && !is_local_view(current)) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* Old view was not the default view, delete view tree */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Unable to delete old view tree "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, " Unable to invalidate overrides "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Unable to commint transaction "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sysdb_update_view_name(sysdb, view_name);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Cannot update view name "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ipa_id_ctx->view_name = talloc_strdup(ipa_id_ctx, view_name);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Cannot copy view name.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* refresh view data of all domains at startup */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sysdb_master_domain_update failed "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sysdb_update_subdomains failed "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Could not cancel transaction\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_ranges_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic struct tevent_req *
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinaipa_subdomains_ranges_send(TALLOC_CTX *mem_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina IPA_BASE_ID, IPA_BASE_RID, IPA_SECONDARY_BASE_RID,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "No search base is set\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = sdap_search_bases_send(state, ev, sd_ctx->sdap_id_ctx->opts, sh,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_ranges_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_ranges_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 ipa_subdomains_ranges_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sdap_search_bases_recv(subreq, state, &reply_count, &reply);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get data from LDAP [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = ipa_ranges_parse_results(state, state->domain->name,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Unable to parse range resulg [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sysdb_update_ranges(state->domain->sysdb, range_list);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Unable to update ranges [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_ranges_recv(struct tevent_req *req)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_master_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic struct tevent_req *
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinaipa_subdomains_master_send(TALLOC_CTX *mem_ctx,
39f21d2b61685362642d42bc2f94f829671cd5efSumit Bose const char *attrs[] = { IPA_CN, IPA_FLATNAME, IPA_SID,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "No search base is set\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina state->domain = domain = sd_ctx->be_ctx->domain;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina state->ipa_options = sd_ctx->ipa_id_ctx->ipa_options;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to update master domain [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (domain->flat_name != NULL && domain->domain_id != NULL
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Master record is up to date.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = sdap_search_bases_return_first_send(state, ev,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_master_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_master_done(struct tevent_req *subreq)
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose struct ldb_message_element *alternative_domain_suffixes = NULL;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina state = tevent_req_data(req, struct ipa_subdomains_master_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sdap_search_bases_return_first_recv(subreq, state,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get data from LDAP [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sysdb_attrs_get_string(reply[0], IPA_FLATNAME, &flat);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sysdb_attrs_get_string(reply[0], IPA_SID, &id);
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose ret = sysdb_attrs_get_el_ext(reply[0], IPA_ADDITIONAL_SUFFIXES, false,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* All search paths are searched and no master domain record was
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * A default IPA installation will not have a master domain record,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * this is only created by ipa-adtrust-install. Nevertheless we should
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * continue to read other data like the idview on IPA clients. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_INTERNAL, "Master domain record not found!\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina realm = dp_opt_get_string(state->ipa_options->basic, IPA_KRB5_REALM);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "No Kerberos realm for IPA?\n");
132b31fd5fb74a7627896cdceaf29c7601ed4795Sumit Bose ret = sysdb_master_domain_add_info(state->domain, realm, flat, id, NULL,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to add master domain info "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_master_recv(struct tevent_req *req)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_slave_search_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_slave_trusts_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic struct tevent_req *
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina const char *attrs[] = { IPA_CN, IPA_FLATNAME, IPA_TRUSTED_DOMAIN_SID,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "No search base is set\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = sdap_search_bases_send(state, ev, sd_ctx->sdap_id_ctx->opts, sh,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_slave_search_done, req);
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bosestatic errno_t ipa_enable_enterprise_principals(struct be_ctx *be_ctx)
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose while (d != NULL) {
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_TRACE_ALL, "checking [%s].\n", d->name);
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose "No UPN suffixes found, "
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose "no need to enable enterprise principals.\n");
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "talloc_new failed.\n");
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose ret = confdb_get_param(be_ctx->cdb, tmp_ctx, be_ctx->conf_path,
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose ipa_def_krb5_opts[KRB5_USE_ENTERPRISE_PRINCIPAL].opt_name,
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "confdb_get_param failed.\n");
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose "Parameter [%s] set in config file and will not be changed.\n",
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose ipa_def_krb5_opts[KRB5_USE_ENTERPRISE_PRINCIPAL].opt_name);
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose auth = dp_target_module(be_ctx->provider, DPT_AUTH);
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "Unable to find auth proivder.\n");
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose krb5_auth_ctx = ipa_init_get_krb5_auth_ctx(dp_get_module_data(auth));
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "Unable to find auth proivder data.\n");
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "dp_opt_set_bool failed.\n");
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_CONF_SETTINGS, "Enterprise principals enabled.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_slave_search_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 ipa_subdomains_slave_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sdap_search_bases_recv(subreq, state, &reply_count, &reply);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get data from LDAP [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = ipa_subdomains_refresh(state->sd_ctx, reply_count, reply,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Failed to refresh subdomains.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Could not reinitialize subdomains\n");
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose ret = ipa_enable_enterprise_principals(state->sd_ctx->be_ctx);
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose DEBUG(SSSDBG_OP_FAILURE, "ipa_enable_enterprise_principals failed. "
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose "Enterprise principals might not work as "
70673115c03c37ddc64c951b53d92df9d3310762Sumit Bose "expected.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (state->sd_ctx->ipa_id_ctx->server_mode == NULL) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = ipa_server_create_trusts_send(state, state->be_ctx->ev,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_slave_trusts_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_slave_trusts_done(struct tevent_req *subreq)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina req = tevent_req_callback_data(subreq, struct tevent_req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to create trusts [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_slave_recv(struct tevent_req *req)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_view_name_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic struct tevent_req *
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinaipa_subdomains_view_name_send(TALLOC_CTX *mem_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina const char *attrs[] = {IPA_CN, OBJECTCLASS, NULL};
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (sd_ctx->ipa_id_ctx->server_mode != NULL) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* Only get view on clients, on servers it is always 'default'. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ipa_options = sd_ctx->ipa_id_ctx->ipa_options;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina maps = talloc_zero_array(state, struct sdap_attr_map_info, 2);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "talloc_zero() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina filter = talloc_asprintf(state, "(&(objectClass=%s)(%s=%s))",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina dp_opt_get_string(ipa_options->basic, IPA_HOSTNAME));
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* We add SDAP_DEREF_FLG_SILENT because old IPA servers don't have
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * the attribute we dereference, causing the deref call to fail. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = sdap_deref_bases_return_first_send(state, ev,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx->sdap_id_ctx->opts, sh, sd_ctx->host_search_bases,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_view_name_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_view_name_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 ipa_subdomains_view_name_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sdap_deref_bases_return_first_recv(subreq, state,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* Depending on the version 389ds return a different error code if the
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * search for the view name failed because our dereference attribute
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * ipaAssignedIDView is not known. Newer version return
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * LDAP_UNAVAILABLE_CRITICAL_EXTENSION(12) which is translated to
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * EOPNOTSUPP and older versions return LDAP_PROTOCOL_ERROR(2) which
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * is returned as EIO. In both cases we have to assume that the server
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina * is not view aware and keep the view name unset. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Unable to get view name, looks " \
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina "like server does not support views.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "Unable to get view name [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "No view found, using default.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sysdb_attrs_get_string(reply[0]->attrs, SYSDB_VIEW_NAME,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sysdb_attrs_get_string failed.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "More than one object returned.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = ipa_apply_view(state->sd_ctx->be_ctx->domain,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to set view [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_view_name_recv(struct tevent_req *req)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_refresh_retry(struct tevent_req *req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_connect_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_ranges_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_master_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_slave_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_view_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic struct tevent_req *
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinaipa_subdomains_refresh_send(TALLOC_CTX *mem_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* asynchronous processing */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_refresh_retry(struct tevent_req *req)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina state = tevent_req_data(req, struct ipa_subdomains_refresh_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = sdap_id_op_connect_send(state->sdap_op, state, &ret);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "sdap_id_op_connect_send() failed "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_refresh_connect_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_connect_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 ipa_subdomains_refresh_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sdap_id_op_connect_recv(subreq, &dp_error);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to connect to LDAP "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_MINOR_FAILURE, "No IPA server is available, "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina "cannot get the subdomain list while offline\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = ipa_subdomains_ranges_send(state, state->ev, state->sd_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_refresh_ranges_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_ranges_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 ipa_subdomains_refresh_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get IPA ranges "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = ipa_subdomains_master_send(state, state->ev, state->sd_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_refresh_master_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_master_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 ipa_subdomains_refresh_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get master domain "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = ipa_subdomains_slave_send(state, state->ev, state->sd_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_refresh_slave_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_slave_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 ipa_subdomains_refresh_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get subdomains "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = ipa_subdomains_view_name_send(state, state->ev, state->sd_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_refresh_view_done, req);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_refresh_view_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 ipa_subdomains_refresh_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = sdap_id_op_done(state->sdap_op, ret, &dp_error);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to get view name "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Unable to refresh subdomains [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Subdomains refreshed.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_refresh_recv(struct tevent_req *req)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic void ipa_subdomains_handler_done(struct tevent_req *subreq);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic struct tevent_req *
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinaipa_subdomains_handler_send(TALLOC_CTX *mem_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "tevent_req_create() failed\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina if (sd_ctx->last_refreshed > time(NULL) - IPA_SUBDOMAIN_REFRESH_LIMIT) {
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_TRACE_FUNC, "Subdomains were recently refreshed, "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina "nothing to do\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina subreq = ipa_subdomains_refresh_send(state, params->ev, sd_ctx);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina tevent_req_set_callback(subreq, ipa_subdomains_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 ipa_subdomains_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 ipa_subdomains_handler_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to refresh subdomains [%d]: %s\n",
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* TODO For backward compatibility we always return EOK to DP now. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina dp_reply_std_set(&state->reply, DP_ERR_DECIDE, ret, NULL);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic errno_t ipa_subdomains_handler_recv(TALLOC_CTX *mem_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina state = tevent_req_data(req, struct ipa_subdomains_handler_state);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinastatic struct tevent_req *
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx = talloc_get_type(pvt, struct ipa_subdomains_ctx);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina return ipa_subdomains_refresh_send(mem_ctx, ev, sd_ctx);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinaipa_subdomains_ptask_recv(struct tevent_req *req)
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březinaerrno_t ipa_subdomains_init(TALLOC_CTX *mem_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx = talloc_zero(mem_ctx, struct ipa_subdomains_ctx);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "talloc_zero failed.\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx->sdap_id_ctx = ipa_id_ctx->sdap_id_ctx;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx->search_bases = ipa_options->subdomains_search_bases;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx->master_search_bases = ipa_options->master_domain_search_bases;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx->ranges_search_bases = ipa_options->ranges_search_bases;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina sd_ctx->host_search_bases = ipa_options->host_search_bases;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina dp_set_method(dp_methods, DPM_DOMAINS_HANDLER,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ipa_subdomains_handler_send, ipa_subdomains_handler_recv, sd_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina struct ipa_subdomains_ctx, struct dp_subdomains_data, struct dp_reply_std);
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina period = be_ctx->domain->subdomain_refresh_interval;
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ret = be_ptask_create(sd_ctx, be_ctx, period, 0, 0, 0, period,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina ipa_subdomains_ptask_send, ipa_subdomains_ptask_recv, sd_ctx,
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "Unable to setup ptask "
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* Ignore, responders will trigger refresh from time to time. */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_MINOR_FAILURE, "Could not reinitialize subdomains. "
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Users from trusted domains might not be resolved correctly\n");
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina /* Ignore this error and try to discover the subdomains later */
dea636af4d1902a081ee891f1b19ee2f8729d759Pavel Březina DEBUG(SSSDBG_CRIT_FAILURE, "ipa_ad_subdom_init() failed.\n");