9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek sdap_dyndns.c: LDAP specific dynamic DNS update
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek Jakub Hrozek <jhrozek@redhat.com>
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek Copyright (C) 2013 Red Hat
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek This program is free software; you can redistribute it and/or modify
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek it under the terms of the GNU General Public License as published by
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek the Free Software Foundation; either version 3 of the License, or
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek (at your option) any later version.
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek This program is distributed in the hope that it will be useful,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek but WITHOUT ANY WARRANTY; without even the implied warranty of
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek GNU General Public License for more details.
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek You should have received a copy of the GNU General Public License
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek along with this program. If not, see <http://www.gnu.org/licenses/>.
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozekstatic struct tevent_req *
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek const char *iface);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozeksdap_dyndns_get_addrs_recv(struct tevent_req *req,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozekstatic void sdap_dyndns_update_addrs_done(struct tevent_req *subreq);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozekstatic void sdap_dyndns_dns_addrs_done(struct tevent_req *subreq);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozekstatic errno_t sdap_dyndns_addrs_diff(struct sdap_dyndns_update_state *state,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozekstatic errno_t sdap_dyndns_update_step(struct tevent_req *req);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozekstatic errno_t sdap_dyndns_update_ptr_step(struct tevent_req *req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozekstatic void sdap_dyndns_update_done(struct tevent_req *subreq);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozekstatic void sdap_dyndns_update_ptr_done(struct tevent_req *subreq);
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichlsdap_dyndns_next_ptr_record(struct sdap_dyndns_update_state *state,
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichlsdap_get_address_to_delete(struct sss_iface_addr *address_it,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek req = tevent_req_create(mem_ctx, &state, struct sdap_dyndns_update_state);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek state->update_ptr = dp_opt_get_bool(opts, DP_OPT_DYNDNS_UPDATE_PTR);
7c3cc1ee2914bc7b38a992c1af254fc76af5a1adPavel Reichl /* fallback servername is overriden by user option */
8145ab51b05aa86b2f1a21b49383f55e50b0a2e3Jakub Hrozek conf_servername = dp_opt_get_string(opts, DP_OPT_DYNDNS_SERVER);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Unless one family is restricted, just replace all
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek * address families during the update
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* If the interface isn't specified, we ONLY want to have the address
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek * that's connected to the LDAP server stored, so we need to check
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek * (and later remove) both address families.
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek state->remove_af = (DYNDNS_REMOVE_A | DYNDNS_REMOVE_AAAA);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek subreq = sdap_dyndns_get_addrs_send(state, state->ev, sdap_ctx, ifname);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_connect_send failed: [%d](%s)\n",
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek tevent_req_set_callback(subreq, sdap_dyndns_update_addrs_done, req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozeksdap_dyndns_update_addrs_done(struct tevent_req *subreq)
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek req = tevent_req_callback_data(subreq, struct tevent_req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_update_state);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ret = sdap_dyndns_get_addrs_recv(subreq, state, &state->addresses);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Can't get addresses for DNS update\n");
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek /* Check if we need the update at all. In case we are updating the PTR
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek * records as well, we need to know the old addresses to be able to
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek * reliably delete the PTR records */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek subreq = nsupdate_get_addrs_send(state, state->ev,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Can't initiate address check\n");
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek tevent_req_set_callback(subreq, sdap_dyndns_dns_addrs_done, req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Perform update */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Execution will resume in sdap_dyndns_update_done */
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozeksdap_dyndns_dns_addrs_done(struct tevent_req *subreq)
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek req = tevent_req_callback_data(subreq, struct tevent_req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_update_state);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek ret = nsupdate_get_addrs_recv(subreq, state, &state->dns_addrlist, NULL);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Could not receive list of current addresses [%d]: %s\n",
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek ret = sdap_dyndns_addrs_diff(state, &do_update);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Could not check the diff between DNS "
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "and current addresses [%d]: %s\n", ret, strerror(ret));
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek if (do_update == false) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "No DNS update needed, addresses did not change\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Detected IP addresses change, will perform an update\n");
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek /* Either we needed the addresses for updating PTR records only or
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek * the addresses have changed (or both) */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Could not start the update [%d]: %s\n",
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozeksdap_dyndns_addrs_diff(struct sdap_dyndns_update_state *state, bool *_do_update)
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek char **str_dnslist = NULL, **str_local_list = NULL;
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Converting DNS IP addresses to strings failed: [%d]: %s\n",
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Converting local IP addresses to strings failed: [%d]: %s\n",
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Compare the lists */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ret = diff_string_lists(state, str_dnslist, str_local_list,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "diff_string_lists failed: [%d]: %s\n", ret, sss_strerror(ret));
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek for (i=0; dns_only[i]; i++) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Address in DNS only: %s\n", dns_only[i]);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek for (i=0; local_only[i]; i++) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Address on localhost only: %s\n", local_only[i]);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_update_state);
12a1c64105ff56b39e197264fec2d9aba6b84185Pavel Reichl ret = be_nsupdate_create_fwd_msg(state, realm, servername,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Can't get addresses for DNS update\n");
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Fork a child process to perform the DNS update */
e15a9f81eb33066937710d7dee6976a3646d119cJakub Hrozek subreq = be_nsupdate_send(state, state->ev, state->auth_type,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek tevent_req_set_callback(subreq, sdap_dyndns_update_done, req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozeksdap_dyndns_update_done(struct tevent_req *subreq)
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek req = tevent_req_callback_data(subreq, struct tevent_req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_update_state);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* If the update didn't succeed, we can retry using the server name */
12a1c64105ff56b39e197264fec2d9aba6b84185Pavel Reichl "nsupdate failed, retrying.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_TRACE_FUNC, "No PTR update requested, done\n");
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl /* init iterator for addresses to be deleted */
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl state->ptr_addr_iter = sdap_get_address_to_delete(state->dns_addrlist,
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl /* init iterator for addresses to be added */
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek /* Execution will resume in sdap_dyndns_update_ptr_done */
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichlstatic bool remove_addr(int address_family, uint8_t remove_af)
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl DEBUG(SSSDBG_CRIT_FAILURE, "Unknown address family\n");
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichlsdap_get_address_to_delete(struct sss_iface_addr *address_it,
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl address = sss_iface_addr_get_address(address_it);
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl /* skip addresses that are not to be deleted */
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl if (remove_addr(address->ss_family, remove_af)) {
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl address_it = sss_iface_addr_get_next(address_it);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozeksdap_dyndns_update_ptr_step(struct tevent_req *req)
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_update_state);
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl address = sss_iface_addr_get_address(state->ptr_addr_iter);
12a1c64105ff56b39e197264fec2d9aba6b84185Pavel Reichl ret = be_nsupdate_create_ptr_msg(state, realm, servername, state->hostname,
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Can't get addresses for DNS update\n");
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek /* Fork a child process to perform the DNS update */
e15a9f81eb33066937710d7dee6976a3646d119cJakub Hrozek subreq = be_nsupdate_send(state, state->ev, state->auth_type,
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek tevent_req_set_callback(subreq, sdap_dyndns_update_ptr_done, req);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozeksdap_dyndns_update_ptr_done(struct tevent_req *subreq)
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek req = tevent_req_callback_data(subreq, struct tevent_req);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_update_state);
38ebc764eeb7693e0c4f0894d6687e54fbba871bJakub Hrozek /* If the update didn't succeed, we can retry using the server name */
12a1c64105ff56b39e197264fec2d9aba6b84185Pavel Reichl DEBUG(SSSDBG_MINOR_FAILURE, "nsupdate failed, retrying\n");
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichlsdap_dyndns_next_ptr_record(struct sdap_dyndns_update_state *state,
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl /* iterate to next address to delete */
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl state->ptr_addr_iter = sdap_get_address_to_delete(
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl sss_iface_addr_get_next(state->ptr_addr_iter), state->remove_af);
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl /* init iterator for addresses to be added */
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl /* iterate to next address to add */
eeac17ebbe38f16deaa8599231cccfc97aaac85cPavel Reichl state->ptr_addr_iter = sss_iface_addr_get_next(state->ptr_addr_iter);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek/* A request to get addresses to update with */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozekstatic void sdap_dyndns_get_addrs_done(struct tevent_req *subreq);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozekstatic errno_t sdap_dyndns_add_ldap_conn(struct sdap_dyndns_get_addrs_state *state,
038b9ba28a618e3e553803da632116a040b94034Pavel Reichlstatic errno_t get_ifaces_addrs(TALLOC_CTX *mem_ctx,
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl ret = split_on_separator(tmp_ctx, iface, ',', true, true, &list_of_intfs,
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl "Parsing names of interfaces failed - %d:[%s].\n",
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl for (i = 0; i < num_of_intfs; i++) {
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl ret = sss_iface_addr_list_get(tmp_ctx, list_of_intfs[i], &intf_addrs);
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl /* If there is already an existing list, head of this existing
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl * list will be considered as parent talloc context for the
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl sss_iface_addr_concatenate(&result_addrs, intf_addrs);
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl /* non-critical failure */
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl "Cannot get interface %s or there are no addresses "
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl "Cannot get list of addresses from interface %s - %d:[%s]\n",
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl *_result = talloc_steal(mem_ctx, result_addrs);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozekstatic struct tevent_req *
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl ret = get_ifaces_addrs(state, iface, &state->addresses);
038b9ba28a618e3e553803da632116a040b94034Pavel Reichl "get_ifaces_addrs() failed: %d:[%s]\n",
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* We're done. Just fake an async request completion */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Detect DYNDNS address from LDAP connection */
dcb44c39dda9699cdd6488fd116a51ced0687de3Jakub Hrozek state->sdap_op = sdap_id_op_create(state, sdap_ctx->conn->conn_cache);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create failed\n");
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek subreq = sdap_id_op_connect_send(state->sdap_op, state, &ret);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_connect_send failed: [%d](%s)\n",
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek tevent_req_set_callback(subreq, sdap_dyndns_get_addrs_done, req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* EAGAIN - resolution in progress */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozeksdap_dyndns_get_addrs_done(struct tevent_req *subreq)
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek req = tevent_req_callback_data(subreq, struct tevent_req);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_get_addrs_state);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ret = sdap_id_op_connect_recv(subreq, &dp_error);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_MINOR_FAILURE, "No LDAP server is available, "
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "dynamic DNS update is skipped in offline mode.\n");
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Failed to connect to LDAP server: [%d](%s)\n",
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ret = sdap_dyndns_add_ldap_conn(state, sdap_id_op_handle(state->sdap_op));
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "Can't get addresses from LDAP connection\n");
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Got the address! Done! */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozeksdap_dyndns_add_ldap_conn(struct sdap_dyndns_get_addrs_state *state,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek /* Get the file descriptor for the primary LDAP connection */
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek ret = getsockname(fd, (struct sockaddr *) &ss, &ss_len);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_CRIT_FAILURE, "Failed to get socket name\n");
b0a8ed519554f8896e35812e0759862c33f157fePavel Reichl if (ss.ss_family != AF_INET && ss.ss_family != AF_INET6) {
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Connection to LDAP is neither IPv4 nor IPv6\n");
b0a8ed519554f8896e35812e0759862c33f157fePavel Reichl ret = sss_get_dualstack_addresses(state, (struct sockaddr *) &ss,
b0a8ed519554f8896e35812e0759862c33f157fePavel Reichl "sss_get_dualstack_addresses failed: %d:[%s]\n",
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozeksdap_dyndns_get_addrs_recv(struct tevent_req *req,
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek state = tevent_req_data(req, struct sdap_dyndns_get_addrs_state);
9cb46bc62f22e0104f1b41a423b014c281ef5fc2Jakub Hrozek *_addresses = talloc_steal(mem_ctx, state->addresses);
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozekstatic void sdap_dyndns_timer_conn_done(struct tevent_req *req);
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozeksdap_dyndns_timer_conn_send(TALLOC_CTX *mem_ctx,
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek req = tevent_req_create(mem_ctx, &state, struct sdap_dyndns_timer_state);
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek /* In order to prevent the connection triggering an
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek * online callback which would in turn trigger a concurrent DNS
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek /* Make sure to have a valid LDAP connection */
dcb44c39dda9699cdd6488fd116a51ced0687de3Jakub Hrozek state->sdap_op = sdap_id_op_create(state, state->sdap_ctx->conn->conn_cache);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_create failed\n");
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek subreq = sdap_id_op_connect_send(state->sdap_op, state, &ret);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_OP_FAILURE, "sdap_id_op_connect_send failed: [%d](%s)\n",
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek tevent_req_set_callback(subreq, sdap_dyndns_timer_conn_done, req);
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozeksdap_dyndns_timer_conn_done(struct tevent_req *subreq)
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek struct tevent_req *req = tevent_req_callback_data(subreq,
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek struct sdap_dyndns_timer_state *state = tevent_req_data(req,
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek ret = sdap_id_op_connect_recv(subreq, &dp_error);
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov DEBUG(SSSDBG_MINOR_FAILURE, "No server is available, "
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "dynamic DNS update is skipped in offline mode.\n");
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek /* Another timer will be scheduled when provider goes online */
a3c8390d19593b1e5277d95bfb4ab206d4785150Nikolai Kondrashov "Failed to connect to LDAP server: [%d](%s)\n",
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek /* Just schedule another dyndns retry */
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek be_nsupdate_timer_schedule(state->ev, state->dyndns_ctx);
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek /* All OK, schedule another refresh and let the user call its
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek * provider-specific update
33df734b39538eeb870b118b7feea76f90bb004bJakub Hrozek be_nsupdate_timer_schedule(state->ev, state->dyndns_ctx);