sdap_async_sudo_hostinfo.c revision 468f1c8d4763a65f24ab8d7523a5291ef6320db7
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd Pavel Březina <pbrezina@redhat.com>
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd Copyright (C) 2012 Red Hat
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd This program is free software; you can redistribute it and/or modify
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein it under the terms of the GNU General Public License as published by
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd the Free Software Foundation; either version 3 of the License, or
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd (at your option) any later version.
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd This program is distributed in the hope that it will be useful,
ce9621257ef9e54c1bbe5ad8a5f445a1f211c2dcnd but WITHOUT ANY WARRANTY; without even the implied warranty of
b0fb330a8581c8bfab5e523084f9f39264a52b12gstein MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
f4c310fd2555c6faca1f980f00b161eadb089023gstein GNU General Public License for more details.
cccd31fa4a72fe23cc3249c06db181b274a55a69gstein You should have received a copy of the GNU General Public License
f4c310fd2555c6faca1f980f00b161eadb089023gstein along with this program. If not, see <http://www.gnu.org/licenses/>.
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantzstatic int sdap_sudo_get_ip_addresses(TALLOC_CTX *mem_ctx, char ***_ip_addr);
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstruct tevent_req * sdap_sudo_get_hostinfo_send(TALLOC_CTX *mem_ctx,
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz struct sdap_sudo_get_hostinfo_state *state = NULL;
f69b31136266022effeb1272d153c92a09de072djerenkrantz /* create request */
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz req = tevent_req_create(mem_ctx, &state, struct sdap_sudo_get_hostinfo_state);
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz DEBUG(SSSDBG_FATAL_FAILURE, ("tevent_req_create() failed\n"));
2e7ef6efb7164346000607d5b5c2d2d392d1a5eajwoolley /* load info from configuration */
2e7ef6efb7164346000607d5b5c2d2d392d1a5eajwoolley conf_hostnames = dp_opt_get_string(opts->basic, SDAP_SUDO_HOSTNAMES);
2e7ef6efb7164346000607d5b5c2d2d392d1a5eajwoolley conf_ip_addr = dp_opt_get_string(opts->basic, SDAP_SUDO_IP);
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz ret = split_on_separator(state, conf_hostnames, ' ', true,
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz ("Unable to parse hostnames [%d]: %s\n", ret, strerror(ret)));
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz DEBUG(SSSDBG_CONF_SETTINGS, ("Hostnames set to: %s\n", conf_hostnames));
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz ret = split_on_separator(state, conf_ip_addr, ' ', true,
f69b31136266022effeb1272d153c92a09de072djerenkrantz ("Unable to parse IP addresses [%d]: %s\n", ret, strerror(ret)));
f69b31136266022effeb1272d153c92a09de072djerenkrantz DEBUG(SSSDBG_CONF_SETTINGS, ("IP addresses set to: %s\n", conf_ip_addr));
f4c310fd2555c6faca1f980f00b161eadb089023gstein /* if IP addresses are not specified, configure it automatically */
a4804918bbbb650c03f1954aa09a8e957589b1ccjerenkrantz ret = sdap_sudo_get_ip_addresses(state, &state->ip_addr);
c364a517c4f0db3d0a33c662c02f2d567a33e135martin state = tevent_req_data(req, struct sdap_sudo_get_hostinfo_state);
f4c310fd2555c6faca1f980f00b161eadb089023gstein *hostnames = talloc_steal(mem_ctx, state->hostnames);
f4c310fd2555c6faca1f980f00b161eadb089023gsteinstatic int sdap_sudo_get_ip_addresses(TALLOC_CTX *mem_ctx, char ***_ip_addr_list)
unsigned int netmask = 0;
int addr_count = 0;
int ret;
return ENOMEM;
errno = 0;
goto done;
netmask = 0;
case AF_INET:
while (ip4_netmask) {
netmask++;
case AF_INET6:
while (ip6_netmask) {
netmask++;
errno = 0;
goto done;
errno = 0;
goto done;
goto done;
goto done;
goto done;
done:
return ret;