ipa_subdomains.c revision 7197ce636c2b92152f5f6180bef6bda3752d148d
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"
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose#define IPA_SECONDARY_BASE_RID "ipaSecondaryBaseRID"
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce/* do not refresh more often than every 5 seconds for now */
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce/* refresh automatically every 4 hours */
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek/* the directory domain - realm mappings are written to */
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek#define IPA_SUBDOMAIN_MAPPING_DIR PUBCONF_PATH"/krb5.include.d"
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny const char *filter;
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce /* subdomain map cache */
81165faf5d951aca69f410713730c26ff048ec44Sumit Bosestatic void ipa_subdomains_reply(struct be_req *be_req, int dp_err, int result)
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bosestatic errno_t ipa_ranges_parse_results(TALLOC_CTX *mem_ctx,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose const char *value;
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose range_list = talloc_array(mem_ctx, struct range_info *, count + 1);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("talloc_array failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose for (c = 0; c < count; c++) {
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose range_list[c] = talloc_zero(range_list, struct range_info);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("talloc_zero failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_string(reply[c], IPA_CN, &value);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose range_list[c]->name = talloc_strdup(range_list[c], value);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_string(reply[c], IPA_TRUSTED_DOMAIN_SID, &value);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose range_list[c]->trusted_dom_sid = talloc_strdup(range_list[c],
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("talloc_strdup failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_BASE_ID,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_ID_RANGE_SIZE,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_BASE_RID,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sysdb_attrs_get_uint32_t(reply[c], IPA_SECONDARY_BASE_RID,
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
204cfc89a076fd32bf34f2abb3f809304aaa88abSimo Sorcestatic char *name_to_realm(TALLOC_CTX *memctx, const char *name)
204cfc89a076fd32bf34f2abb3f809304aaa88abSimo Sorce for (p = realm; *p; p++) {
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorcestatic errno_t ipa_subdom_parse(TALLOC_CTX *memctx,
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose const char *value;
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = sysdb_attrs_get_string(attrs, IPA_CN, &value);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("subdomain name mismatch!\n"));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* Add Realm as upper(domain name), this is generally always correct
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce * with AD domains */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce subdom->realm = name_to_realm(memctx, subdom->name);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = sysdb_attrs_get_string(attrs, IPA_FLATNAME, &value);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* in theory this may change, it should never happen, so we will log a
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce * warning if it does, but we will allow it for now */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ("Flat name for subdomain changed!\n"));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce subdom->flat_name = talloc_strdup(memctx, value);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = sysdb_attrs_get_string(attrs, IPA_TRUSTED_DOMAIN_SID, &value);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* in theory this may change, it should never happen, so we will log a
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce * warning if it does, but we will allow it for now */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ("ID for subdomain changed!\n"));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozekipa_subdomains_write_mappings(struct sss_domain_info *domain,
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek mapping_file = talloc_asprintf(tmp_ctx, "%s/domain_realm_%s",
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek tmp_file = talloc_asprintf(tmp_ctx, "%sXXXXXX", mapping_file);
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek DEBUG(SSSDBG_OP_FAILURE, ("creating the temp file [%s] for domain-realm "
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek DEBUG(SSSDBG_OP_FAILURE, ("fdopen failed [%d]: %s\n",
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ("fclose failed [%d][%s].\n", ret, strerror(ret)));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek /* Nothing to do here, just report the failure */
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek DEBUG(SSSDBG_OP_FAILURE, ("fprintf failed\n"));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek for (i = 0; i < num_subdoms; i++) {
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek DEBUG(SSSDBG_CRIT_FAILURE, ("fprintf failed\n"));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ("fclose failed [%d][%s].\n", ret, strerror(ret)));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ("rename failed [%d][%s].\n", ret, strerror(ret)));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ("fchmod failed [%d][%s].\n", ret, strerror(ret)));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ("fclose failed [%d][%s].\n", err, strerror(err)));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek /* Nothing to do here, just report the failure */
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ("Could not remove file [%s]: [%d]: %s",
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorcestatic errno_t ipa_subdomains_refresh(struct ipa_subdomains_ctx *ctx,
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce const char *value;
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* check existing subdoms in cache */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce for (c = 0; c < count; c++) {
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = sysdb_attrs_get_string(reply[c], IPA_CN, &value);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("sysdb_attrs_get_string failed.\n"));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* ok this subdomain does not exist anymore, let's clean up */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce /* ok let's try to update it */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = ipa_subdom_parse(ctx->subdoms, reply[c], &ctx->subdoms[i]);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Failed to parse subdom data\n"));
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 /* add space for unhandled domains */
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce for (c = 0; c < count; c++) {
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce memset(&ctx->subdoms[i], 0, sizeof(struct sysdb_subdom));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = ipa_subdom_parse(ctx->subdoms, reply[c], &ctx->subdoms[i]);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Failed to parse subdom data\n"));
81165faf5d951aca69f410713730c26ff048ec44Sumit Bosestatic void ipa_subdomains_get_conn_done(struct tevent_req *req);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zelenyipa_subdomains_handler_get(struct ipa_subdomains_req_ctx *ctx,
81165faf5d951aca69f410713730c26ff048ec44Sumit Bosestatic void ipa_subdomains_handler_done(struct tevent_req *req);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zelenystatic void ipa_subdomains_handler_master_done(struct tevent_req *req);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bosestatic void ipa_subdomains_handler_ranges_done(struct tevent_req *req);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zelenystatic struct ipa_subdomains_req_params subdomain_requests[] = {
5ea449b18d2597f2581627de80bcaf2bc70b0fd3Simo Sorce { IPA_CN, IPA_FLATNAME, IPA_TRUSTED_DOMAIN_SID, NULL }
5ea449b18d2597f2581627de80bcaf2bc70b0fd3Simo Sorce IPA_BASE_ID, IPA_BASE_RID, IPA_SECONDARY_BASE_RID,
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce/* NOTE: be_req can be NULL, this is used by the online callback to refresh
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce * subdomains without any request coming from a frontend */
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorcestatic void ipa_subdomains_retrieve(struct ipa_subdomains_ctx *ctx, struct be_req *be_req)
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce req_ctx = talloc(be_req, struct ipa_subdomains_req_ctx);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sdap_id_op_create failed.\n"));
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce req = sdap_id_op_connect_send(req_ctx->sdap_op, req_ctx, &ret);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sdap_id_op_connect_send failed: %d(%s).\n",
4c20fe34346919cf676c3e1b54b7701069e2aac6Simo Sorce tevent_req_set_callback(req, ipa_subdomains_get_conn_done, req_ctx);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bosestatic void ipa_subdomains_get_conn_done(struct tevent_req *req)
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce ctx = tevent_req_callback_data(req, struct ipa_subdomains_req_ctx);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ("No IPA server is available, cannot get the "
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose "subdomain list while offline\n"));
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose/* FIXME: return saved results ?? */
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ("Failed to connect to IPA server: [%d](%s)\n",
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = ipa_subdomains_handler_get(ctx, IPA_SUBDOMAINS_SLAVE);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zelenyipa_subdomains_handler_get(struct ipa_subdomains_req_ctx *ctx,
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce ctx->current_filter = sdap_get_id_specific_filter(ctx, params->filter,
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce req = sdap_get_generic_send(ctx, ctx->sd_ctx->be_ctx->ev,
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose dp_opt_get_int(ctx->sd_ctx->sdap_id_ctx->opts->basic,
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sdap_get_generic_send failed.\n"));
81165faf5d951aca69f410713730c26ff048ec44Sumit Bosestatic void ipa_subdomains_handler_done(struct tevent_req *req)
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce ctx = tevent_req_callback_data(req, struct ipa_subdomains_req_ctx);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ret = sdap_get_generic_recv(req, ctx, &reply_count, &reply);
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sdap_get_generic_send request failed.\n"));
81165faf5d951aca69f410713730c26ff048ec44Sumit Bose ctx->reply = talloc_realloc(ctx, ctx->reply, struct sysdb_attrs *,
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = ipa_subdomains_handler_get(ctx, IPA_SUBDOMAINS_SLAVE);
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = ipa_subdomains_refresh(ctx->sd_ctx, ctx->reply_count, ctx->reply,
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("Failed to refresh subdomains.\n"));
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce ret = sysdb_update_subdomains(sysdb, ctx->sd_ctx->num_subdoms,
efea50efda58be66638e5d38c8e57fdf9992f204Simo Sorce DEBUG(SSSDBG_OP_FAILURE, ("sysdb_update_subdomains failed.\n"));
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ret = ipa_subdomains_write_mappings(sysdb_ctx_get_domain(sysdb),
7197ce636c2b92152f5f6180bef6bda3752d148dJakub Hrozek ("ipa_subdomains_write_mappings failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ctx->search_bases = ctx->sd_ctx->ranges_search_bases;
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = ipa_subdomains_handler_get(ctx, IPA_SUBDOMAINS_RANGES);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("No search base for ranges available.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bosestatic void ipa_subdomains_handler_ranges_done(struct tevent_req *req)
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce ctx = tevent_req_callback_data(req, struct ipa_subdomains_req_ctx);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = sdap_get_generic_recv(req, ctx, &reply_count, &reply);
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sdap_get_generic_send request failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose ret = ipa_ranges_parse_results(ctx, reply_count, reply, &range_list);
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce ("ipa_ranges_parse_results request failed.\n"));
386a66b1aa18a176e6a06fa126556c9590c373b6Sumit Bose DEBUG(SSSDBG_OP_FAILURE, ("sysdb_update_ranges failed.\n"));
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = sysdb_master_domain_get_info(ctx, sysdb, &domain_info);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ctx->search_bases = ctx->sd_ctx->master_search_bases;
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = ipa_subdomains_handler_get(ctx, IPA_SUBDOMAINS_MASTER);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zelenystatic void ipa_subdomains_handler_master_done(struct tevent_req *req)
21f19d573047e70ee8ec0119ec00c1ed1af9ec04Simo Sorce ctx = tevent_req_callback_data(req, struct ipa_subdomains_req_ctx);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = sdap_get_generic_recv(req, ctx, &reply_count, &reply);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny DEBUG(SSSDBG_OP_FAILURE, ("sdap_get_generic_send request failed.\n"));
b58460076fe843c11d736ae244c1ac979a6473a4Simo Sorce domain_info = talloc_zero(ctx, struct sysdb_subdom);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = sysdb_attrs_get_string(reply[0], IPA_FLATNAME, &tmp_str);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny domain_info->flat_name = talloc_strdup(domain_info, tmp_str);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = sysdb_attrs_get_string(reply[0], IPA_SID, &tmp_str);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny domain_info->id = talloc_strdup(domain_info, tmp_str);
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce ret = sysdb_master_domain_add_info(ctx->sd_ctx->be_ctx->sysdb, domain_info);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny ret = ipa_subdomains_handler_get(ctx, IPA_SUBDOMAINS_MASTER);
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny /* Right now we know there has been an error
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny * and we don't have the master domain record
84c611c1b7c04cc7735ab54d4e5f48284b79e6fbJan Zeleny DEBUG(SSSDBG_CRIT_FAILURE, ("Master domain record not found!\n"));
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorcestatic void ipa_subdom_timer_refresh(struct tevent_context *ev,
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce ctx = talloc_get_type(pvt, struct ipa_subdomains_ctx);
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce DEBUG(SSSDBG_CRIT_FAILURE, ("Bad private pointer\n"));
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce tv = tevent_timeval_current_ofs(IPA_SUBDOMAIN_REFRESH_PERIOD, 0);
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce ctx->timer_event = tevent_add_timer(ctx->be_ctx->ev, ctx, tv,
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce DEBUG(SSSDBG_MINOR_FAILURE, ("Failed to add subdom timer event\n"));
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce ctx = talloc_get_type(pvt, struct ipa_subdomains_ctx);
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorcevoid ipa_subdomains_handler(struct be_req *be_req)
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce ctx = talloc_get_type(be_req->be_ctx->bet_info[BET_SUBDOMAINS].pvt_bet_data,
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce ipa_subdomains_reply(be_req, DP_ERR_FATAL, EINVAL);
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce if (ctx->last_refreshed > time(NULL) - IPA_SUBDOMAIN_REFRESH_LIMIT) {
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce ctx = talloc_zero(id_ctx, struct ipa_subdomains_ctx);
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce DEBUG(SSSDBG_CRIT_FAILURE, ("talloc_zero failed.\n"));
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce ctx->search_bases = id_ctx->ipa_options->subdomains_search_bases;
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce ctx->master_search_bases = id_ctx->ipa_options->master_domain_search_bases;
87ed72b47859e673b636c85f35b85f1546c7ed3dSimo Sorce ctx->ranges_search_bases = id_ctx->ipa_options->ranges_search_bases;
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce ret = be_add_online_cb(ctx, be_ctx, ipa_subdom_online_cb, ctx, NULL);
6a81cb8c3424dbe9f764af3738299cbbe5874a15Simo Sorce DEBUG(SSSDBG_MINOR_FAILURE, ("Failed to add subdom online callback"));
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce ret = be_add_offline_cb(ctx, be_ctx, ipa_subdom_offline_cb, ctx, NULL);
3b533d57a737e2de1b3e85b073b14d3bfb49dafcSimo Sorce DEBUG(SSSDBG_MINOR_FAILURE, ("Failed to add subdom offline callback"));