/*
Authors:
Pavel Březina <pbrezina@redhat.com>
Copyright (C) 2012 Red Hat
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <errno.h>
#include <tevent.h>
#include <talloc.h>
#include <ifaddrs.h>
#include <unistd.h>
#include <limits.h>
#include <string.h>
#include "providers/ldap/sdap_id_op.h"
#include "providers/ldap/sdap_sudo.h"
#include "resolv/async_resolv.h"
struct sdap_sudo_get_hostinfo_state {
char **hostnames;
char **ip_addr;
};
struct sdap_sudo_get_hostnames_state {
char **hostnames;
};
struct tevent_req *req,
char ***hostnames);
struct sdap_options *opts,
{
/* create request */
struct sdap_sudo_get_hostinfo_state);
return NULL;
}
/* load info from configuration */
if (conf_hostnames != NULL) {
goto done;
} else {
"Hostnames set to: %s\n", conf_hostnames);
}
}
if (conf_ip_addr != NULL) {
"Unable to parse IP addresses [%d]: %s\n",
goto done;
} else {
}
}
/* if IP addresses are not specified, configure it automatically */
"Unable to detect IP addresses [%d]: %s\n",
}
}
/* if hostnames are not specified, configure it automatically */
goto done;
}
}
done:
} else {
}
}
return req;
}
{
int ret;
return;
}
}
struct tevent_req *req,
{
return EOK;
}
char ***_ip_addr_list)
{
unsigned int netmask = 0;
int addr_count = 0;
int ret;
int i;
return ENOMEM;
}
errno = 0;
if (ret == -1) {
goto done;
}
/* Some interfaces don't have an ifa_addr */
netmask = 0;
case AF_INET:
|SSS_NO_BROADCAST)) {
continue;
}
/* get network mask length */
while (ip4_netmask) {
netmask++;
ip4_netmask <<= 1;
}
/* get network address */
break;
case AF_INET6:
continue;
}
/* get network mask length */
for (i = 0; i < 4; i++) {
while (ip6_netmask) {
netmask++;
ip6_netmask <<= 1;
}
}
/* get network address */
for (i = 0; i < 4; i++) {
}
break;
default:
/* skip other families */
continue;
}
/* ip address */
errno = 0;
goto done;
}
/* network */
errno = 0;
goto done;
}
addr_count += 2;
addr_count + 1);
if (ip_addr_list == NULL) {
goto done;
}
goto done;
}
goto done;
}
"Found IP address: %s in network %s/%d\n",
}
if (ip_addr_list) {
}
done:
return ret;
}
/*
* SUDO allows only one hostname that is returned from gethostname()
* (and set to "localhost" if the returned value is empty)
* and then - if allowed - resolves its fqdn using gethostbyname() or
* getaddrinfo() if available.
*/
{
int ret;
struct sdap_sudo_get_hostnames_state);
return NULL;
}
/* hostname, fqdn and NULL */
goto done;
}
/* get hostname */
errno = 0;
goto done;
}
goto done;
}
/* already a fqdn, determine hostname and finish */
*dot = '\0';
goto done;
}
goto done;
} else {
}
/* get fqdn */
goto done;
}
done:
} else {
}
}
return req;
}
{
int resolv_status;
int ret;
&rhostent);
/* Empty result, just quit */
goto done;
"Could not resolve fqdn for this machine, error [%d]: %s, "
return;
}
/* EOK */
goto done;
}
goto done;
}
done:
} else {
}
}
struct tevent_req *req,
char ***hostnames)
{
return EOK;
}