diff options
| author | Chris Lumens <clumens@redhat.com> | 2008-02-05 10:06:07 -0500 |
|---|---|---|
| committer | Chris Lumens <clumens@redhat.com> | 2008-02-05 21:58:38 -0500 |
| commit | eca30cc3ced2bef4164e577cc5b5865f70899c8a (patch) | |
| tree | 14f2afc16a83149690b82fc71af867b6a0961528 /loader2 | |
| parent | ff1c377b3798f0bbb6730fd179a8d4ea6711c23f (diff) | |
| download | anaconda-eca30cc3ced2bef4164e577cc5b5865f70899c8a.tar.gz anaconda-eca30cc3ced2bef4164e577cc5b5865f70899c8a.tar.xz anaconda-eca30cc3ced2bef4164e577cc5b5865f70899c8a.zip | |
Remove our own DNS functions, since glibc's are available now.
Diffstat (limited to 'loader2')
| -rw-r--r-- | loader2/ftp.c | 23 | ||||
| -rw-r--r-- | loader2/net.c | 11 | ||||
| -rw-r--r-- | loader2/urls.c | 23 |
3 files changed, 29 insertions, 28 deletions
diff --git a/loader2/ftp.c b/loader2/ftp.c index 242a1ac34..940b8df21 100644 --- a/loader2/ftp.c +++ b/loader2/ftp.c @@ -26,7 +26,6 @@ #define HAVE_ALLOCA_H 1 #define HAVE_NETINET_IN_SYSTM_H 1 #define HAVE_SYS_SOCKET_H 1 -#define USE_ALT_DNS 1 #if HAVE_ALLOCA_H # include <alloca.h> @@ -70,10 +69,6 @@ extern int h_errno; # define IPPORT_FTP 21 #endif -#if defined(USE_ALT_DNS) && USE_ALT_DNS -#include "../isys/dns.h" -#endif - #include "ftp.h" #include "log.h" #include "net.h" @@ -217,6 +212,7 @@ int ftpCommand(int sock, char * command, ...) { static int getHostAddress(const char * host, void * address, int family) { char *hostname, *port; + struct hostent *hostent; splitHostname((char *) host, &hostname, &port); @@ -228,11 +224,12 @@ static int getHostAddress(const char * host, void * address, int family) { return FTPERR_BAD_HOST_ADDR; } } else { - if (mygethostbyname(hostname, (struct in_addr *)address, AF_INET)) { + if ((hostent = gethostbyname(hostname)) != NULL) { + memcpy((struct in_addr *) address, hostent->h_addr_list[0], hostent->h_length); + return 0; + } else { errno = h_errno; return FTPERR_BAD_HOSTNAME; - } else { - return 0; } } } else if (family == AF_INET6) { @@ -242,9 +239,13 @@ static int getHostAddress(const char * host, void * address, int family) { } else return FTPERR_BAD_HOST_ADDR; } else { - /* FIXME: implement me */ - logMessage(ERROR, "we don't have reverse DNS for IPv6 yet"); - return FTPERR_BAD_HOSTNAME; + if ((hostent = gethostbyname(hostname)) != NULL) { + memcpy((struct in_addr6 *) address, hostent->h_addr_list[0], hostent->h_length); + return 0; + } else { + errno = h_errno; + return FTPERR_BAD_HOSTNAME; + } } } else { return FTPERR_UNSUPPORTED_FAMILY; diff --git a/loader2/net.c b/loader2/net.c index 0be97f6ac..2bb2c85ac 100644 --- a/loader2/net.c +++ b/loader2/net.c @@ -20,6 +20,7 @@ * Author(s): David Cantrell <dcantrell@redhat.com> */ +#include <netdb.h> #include <sys/types.h> #include <sys/ioctl.h> #include <sys/socket.h> @@ -35,7 +36,6 @@ #include <strings.h> #include <unistd.h> -#include "../isys/dns.h" #include "../isys/isys.h" #include "../isys/net.h" #include "../isys/wireless.h" @@ -1539,6 +1539,7 @@ int findHostAndDomain(struct networkDeviceConfig * dev) { char * name, * chptr; char ret[48]; ip_addr_t *tip; + struct hostent *host; if (!FL_TESTING(flags)) { writeResolvConf(dev); @@ -1558,16 +1559,18 @@ int findHostAndDomain(struct networkDeviceConfig * dev) { tip = &(dev->dev.ip); inet_ntop(tip->sa_family, IP_ADDR(tip), ret, IP_STRLEN(tip)); - name = mygethostbyaddr(ret, tip->sa_family); + host = gethostbyaddr(ret, IP_STRLEN(tip), tip->sa_family); if (!FL_CMDLINE(flags)) newtPopWindow(); - if (!name) { - logMessage(WARNING, "reverse name lookup failed"); + if (!host) { + logMessage(WARNING, "reverse name lookup of %s failed", ret); return 1; } + name = strdup(host->h_name); + logMessage(INFO, "reverse name lookup worked"); dev->dev.hostname = strdup(name); diff --git a/loader2/urls.c b/loader2/urls.c index 3a47fa787..f7301333e 100644 --- a/loader2/urls.c +++ b/loader2/urls.c @@ -34,8 +34,6 @@ #include <unistd.h> #include <netdb.h> -#include "../isys/dns.h" - #include "ftp.h" #include "lang.h" #include "loader.h" @@ -172,6 +170,7 @@ int urlinstStartTransfer(struct iurlinfo * ui, char * filename, struct in_addr addr; struct in6_addr addr6; char *hostname, *portstr; + struct hostent *host; if (!strcmp(ui->prefix, "/")) finalPrefix = ""; @@ -201,14 +200,13 @@ int urlinstStartTransfer(struct iurlinfo * ui, char * filename, else if (inet_pton(AF_INET6, hostname, &addr6) >= 1) family = AF_INET6; else { - if (mygethostbyname(hostname, &addr, AF_INET) == 0) { - family = AF_INET; - } else if (mygethostbyname(hostname, &addr6, AF_INET6) == 0) { - family = AF_INET6; - } else { - logMessage(ERROR, "cannot determine address family of %s", - hostname); + if ((host = gethostbyname(hostname)) == NULL) { + logMessage(ERROR, "cannot determine address family of %s: %s", + hostname, hstrerror(h_errno)); + return -1; } + else + family = host->h_addrtype; } if (ui->protocol == URL_METHOD_FTP) { @@ -258,6 +256,7 @@ char * addrToIp(char * hostname) { struct in_addr ad; struct in6_addr ad6; char *ret; + struct hostent *host; if ((ret = malloc(48)) == NULL) return hostname; @@ -266,10 +265,8 @@ char * addrToIp(char * hostname) { return ret; else if (inet_ntop(AF_INET6, &ad6, ret, INET6_ADDRSTRLEN) != NULL) return ret; - else if (mygethostbyname(hostname, &ad, AF_INET) == 0) - return hostname; - else if (mygethostbyname(hostname, &ad6, AF_INET6) == 0) - return hostname; + else if ((host = gethostbyname(hostname)) != NULL) + return host->h_name; else return NULL; } |
