diff options
author | Matthias Andree <matthias.andree@gmx.de> | 2017-04-22 23:20:24 +0200 |
---|---|---|
committer | Matthias Andree <matthias.andree@gmx.de> | 2017-04-22 23:22:32 +0200 |
commit | 6ae9c025819d4cc8e7e23308e4834af4ec695945 (patch) | |
tree | 8407bc5f2e696d3c8104ac3d8e96851d7b88432a | |
parent | c36be3453b906381c9580fa0ef8c6b652fcb6cfe (diff) | |
download | fetchmail-6ae9c025819d4cc8e7e23308e4834af4ec695945.tar.gz fetchmail-6ae9c025819d4cc8e7e23308e4834af4ec695945.tar.bz2 fetchmail-6ae9c025819d4cc8e7e23308e4834af4ec695945.zip |
Remove last traces of gethostbyname().
-rw-r--r-- | Makefile.am | 2 | ||||
-rw-r--r-- | checkalias.c | 7 | ||||
-rw-r--r-- | configure.ac | 5 | ||||
-rw-r--r-- | env.c | 2 | ||||
-rw-r--r-- | libesmtp/gethostbyname.c | 228 | ||||
-rw-r--r-- | libesmtp/gethostbyname.h | 103 | ||||
-rw-r--r-- | m4-local/gethostbyname_r.m4 | 71 |
7 files changed, 3 insertions, 415 deletions
diff --git a/Makefile.am b/Makefile.am index ded5dd32..af9dfeaa 100644 --- a/Makefile.am +++ b/Makefile.am @@ -33,10 +33,10 @@ noinst_LIBRARIES= libfm.a libfm_a_SOURCES= xmalloc.c base64.c rfc822.c report.c rfc2047e.c \ servport.c ntlm.h smbbyteorder.h smbdes.h smbmd4.h \ smbencrypt.h smbdes.c smbencrypt.c smbmd4.c smbutil.c \ - libesmtp/gethostbyname.h libesmtp/gethostbyname.c \ smbtypes.h fm_getaddrinfo.c starttls.c rfc822valid.c \ xmalloc.h sdump.h sdump.c x509_name_match.c \ fm_strl.h md5c.c + if NTLM_ENABLE libfm_a_SOURCES += ntlmsubr.c endif diff --git a/checkalias.c b/checkalias.c index 1e1d1633..eb92ff00 100644 --- a/checkalias.c +++ b/checkalias.c @@ -53,8 +53,6 @@ static int is_ip_alias(const char *name1,const char *name2) /* * Given two hostnames as arguments, returns TRUE if they * have at least one IP address in common. - * No check is done on errors returned by gethostbyname, - * the calling function does them. */ { int rc = FALSE; @@ -151,9 +149,6 @@ int is_host_alias(const char *name, struct query *ctl, struct addrinfo **res) return(FALSE); #else /* - * The only code that calls the BIND library is here and in the - * start-of-run probe with gethostbyname(3) under ETRN/Kerberos. - * * We know DNS service was up at the beginning of the run. * If it's down, our nameserver has crashed. We don't want to try * delivering the current message or anything else from the @@ -216,8 +211,6 @@ int is_host_alias(const char *name, struct query *ctl, struct addrinfo **res) } /* - * We're only here if DNS was OK but the gethostbyname() failed - * with a HOST_NOT_FOUND or NO_ADDRESS error. * Search for a name match on MX records pointing to the server. */ h_errno = 0; diff --git a/configure.ac b/configure.ac index 31e90ee0..8393176b 100644 --- a/configure.ac +++ b/configure.ac @@ -839,14 +839,11 @@ then AC_CHECK_LIB(socks5, SOCKSconnect,, AC_MSG_ERROR([could not find libsocks5 which is needed for built-in SOCKS5 support])) AC_DEFINE(HAVE_SOCKS) - CFLAGS="$CFLAGS -Dconnect=SOCKSconnect -Dgetsockname=SOCKSgetsockname -Dbind=SOCKSbind -Daccept=SOCKSaccept -Dlisten=SOCKSlisten -Dselect=SOCKSselect -Drecvfrom=SOCKSrecvfrom -Dsendto=SOCKSsendto -Drecv=SOCKSrecv -Dsend=SOCKSsend -Dread=SOCKSread -Dwrite=SOCKSwrite -Drresvport=SOCKSrresvport -Dshutdown=SOCKSshutdown -Dlisten=SOCKSlisten -Dclose=SOCKSclose -Ddup=SOCKSdup -Ddup2=SOCKSdup2 -Dgethostbyname=SOCKSgethostbyname" + CFLAGS="$CFLAGS -Dconnect=SOCKSconnect -Dgetsockname=SOCKSgetsockname -Dbind=SOCKSbind -Daccept=SOCKSaccept -Dlisten=SOCKSlisten -Dselect=SOCKSselect -Drecvfrom=SOCKSrecvfrom -Dsendto=SOCKSsendto -Drecv=SOCKSrecv -Dsend=SOCKSsend -Dread=SOCKSread -Dwrite=SOCKSwrite -Drresvport=SOCKSrresvport -Dshutdown=SOCKSshutdown -Dlisten=SOCKSlisten -Dclose=SOCKSclose -Ddup=SOCKSdup -Ddup2=SOCKSdup2" AC_CHECK_FUNC(SOCKSfclose, [CFLAGS="$CFLAGS -Dfclose=SOCKSfclose"]) LDFLAGS="$ac_savedLDFLAGS" fi]) -dnl for libesmtp/ modules: -ACX_WHICH_GETHOSTBYNAME_R - ### use option --with-hesiod=DIR to point at a HESIOD directory AC_ma_SEARCH_PACKAGE(hesiod, hesiod_getmailhost, /usr/athena /usr /usr/local,hesiod, hesiod.h) @@ -169,7 +169,7 @@ char *host_fqdn(int required) if (e) { /* exit with error message */ fprintf(stderr, - GT_("gethostbyname failed for %s\n"), tmpbuf); + GT_("getaddrinfo failed for %s\n"), tmpbuf); fprintf(stderr, "%s", gai_strerror(e)); fprintf(stderr, GT_("Cannot find my own host in hosts database to qualify it!\n")); if (required) diff --git a/libesmtp/gethostbyname.c b/libesmtp/gethostbyname.c deleted file mode 100644 index cd74ec0a..00000000 --- a/libesmtp/gethostbyname.c +++ /dev/null @@ -1,228 +0,0 @@ -/* - * This file is a ghastly hack because nobody can agree on - * gethostbyname_r()'s prototype. - * - * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - -#define _SVID_SOURCE 1 /* Need this to get gethostbyname_r() */ - -#include <assert.h> - -#include <stdlib.h> -#include <string.h> -#include <netdb.h> -#include <errno.h> - -#include "gethostbyname.h" - -#if HAVE_GETIPNODEBYNAME - -void -free_ghbnctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - if (ctx->hostent != NULL) - freehostent (ctx->hostent); -} - -struct hostent * -gethostbyname_ctx (const char *host, struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - memset (ctx, 0, sizeof (struct ghbnctx)); - ctx->hostent = getipnodebyname (host, AF_UNSPEC, AI_ADDRCONFIG, &ctx->h_err); - return ctx->hostent; -} - -int -h_error_ctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - return ctx->h_err; -} - -#elif HAVE_GETHOSTBYNAME_R == 6 - -void -free_ghbnctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - if (ctx->hostbuf != NULL) - free (ctx->hostbuf); -} - -struct hostent * -gethostbyname_ctx (const char *host, struct ghbnctx *ctx) -{ - struct hostent *hp; - char *tmp; - int err; - - assert (ctx != NULL); - - memset (ctx, 0, sizeof (struct ghbnctx)); - ctx->hostbuf_len = 2048; - if ((ctx->hostbuf = (char *)malloc (ctx->hostbuf_len)) == NULL) - { - errno = ENOMEM; - return NULL; - } - while ((err = gethostbyname_r (host, - &ctx->hostent, ctx->hostbuf, ctx->hostbuf_len, - &hp, &ctx->h_err)) == ERANGE) - { - ctx->hostbuf_len += 1024; - if ((tmp = (char *)realloc (ctx->hostbuf, ctx->hostbuf_len)) == NULL) - { - errno = ENOMEM; - return NULL; - } - ctx->hostbuf = tmp; - } - if (err != 0) - { - errno = err; - return NULL; - } - return hp; -} - -int -h_error_ctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - return ctx->h_err; -} - -#elif HAVE_GETHOSTBYNAME_R == 5 - -void -free_ghbnctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - if (ctx->hostbuf != NULL) - free (ctx->hostbuf); -} - -struct hostent * -gethostbyname_ctx (const char *host, struct ghbnctx *ctx) -{ - struct hostent *hp; - char *tmp; - - assert (ctx != NULL); - - memset (ctx, 0, sizeof (struct ghbnctx)); - ctx->hostbuf_len = 2048; - if ((ctx->hostbuf = malloc (ctx->hostbuf_len)) == NULL) - { - errno = ENOMEM; - return NULL; - } - while ((hp = gethostbyname_r (host, &ctx->hostent, - ctx->hostbuf, ctx->hostbuf_len, - &ctx->h_err)) == NULL && errno == ERANGE) - { - ctx->hostbuf_len += 1024; - if ((tmp = realloc (ctx->hostbuf, ctx->hostbuf_len)) == NULL) - { - errno = ENOMEM; - return NULL; - } - ctx->hostbuf = tmp; - } - return hp; -} - -int -h_error_ctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - return ctx->h_err; -} - -#elif HAVE_GETHOSTBYNAME_R == 3 - -void -free_ghbnctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - /* FIXME: does this need to do anything? */ -} - -struct hostent * -gethostbyname_ctx (const char *host, struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - if (!gethostbyname_r (host, &ctx->hostent, &ctx->hostent_data)) - { - ctx->h_err = h_errno; /* FIXME: is this correct? */ - return NULL; - } - return &ctx->hostent; -} - -int -h_error_ctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - return ctx->h_err; -} - -#else - -void -free_ghbnctx (struct ghbnctx *ctx ) -{ - assert (ctx != NULL); -} - -struct hostent * -gethostbyname_ctx (const char *host, struct ghbnctx *ctx) -{ - struct hostent *hp; - - hp = gethostbyname (host); - if (hp == NULL) - ctx->h_err = h_errno; - return hp; -} - -int -h_error_ctx (struct ghbnctx *ctx) -{ - assert (ctx != NULL); - - return ctx->h_err; -} - -#endif diff --git a/libesmtp/gethostbyname.h b/libesmtp/gethostbyname.h deleted file mode 100644 index 2b963997..00000000 --- a/libesmtp/gethostbyname.h +++ /dev/null @@ -1,103 +0,0 @@ -/* - * This file is a ghastly hack because nobody can agree on - * gethostbyname_r()'s prototype. - * - * Copyright (C) 2001,2002 Brian Stafford <brian@stafford.uklinux.net> - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * This library 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 - * Lesser General Public License for more details. - * - * You should have received a copy of the GNU Lesser General Public - * License along with this library; if not, write to the Free Software - * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ - -/************************************************************************* - Usage: - - #include <errno.h> - #include "gethostbyname.h" - - f () - { - struct ghbnctx ctx; - - errno = 0; - hp = gethostbyname_ctx (host, &ctx); - if (hp == NULL) - { - if (errno != 0) - handle_value_of_errno (errno); - else - handle_value_of_h_errno (h_error_ctx (&ctx)); - } - else - { - ... - } - free_ghbnctx (&ctx); - } - *************************************************************************/ - -#ifndef _gethostbyname_h -#define _gethostbyname_h - -#if HAVE_GETIPNODEBYNAME - -struct ghbnctx - { - int h_err; - struct hostent *hostent; - }; - -#elif HAVE_GETHOSTBYNAME_R == 6 - -struct ghbnctx - { - int h_err; - struct hostent hostent; - char *hostbuf; - size_t hostbuf_len; - }; - -#elif HAVE_GETHOSTBYNAME_R == 5 - -struct ghbnctx - { - int h_err; - struct hostent hostent; - char *hostbuf; - int hostbuf_len; - }; - -#elif HAVE_GETHOSTBYNAME_R == 3 - -struct ghbnctx - { - int h_err; - struct hostent_data hostent_data; - struct hostent hostent; - }; - -#else - -struct ghbnctx - { - int h_err; - }; - -#endif - -struct hostent *gethostbyname_ctx (const char *host, struct ghbnctx *ctx); -int h_error_ctx (struct ghbnctx *ctx); -void free_ghbnctx (struct ghbnctx *ctx); - -#endif - diff --git a/m4-local/gethostbyname_r.m4 b/m4-local/gethostbyname_r.m4 deleted file mode 100644 index 84f99c83..00000000 --- a/m4-local/gethostbyname_r.m4 +++ /dev/null @@ -1,71 +0,0 @@ -dnl @synopsis ACX_WHICH_GETHOSTBYNAME_R -dnl -dnl Provides a test to determine the correct way to call gethostbyname_r -dnl -dnl defines HAVE_GETHOSTBYNAME_R to the number of arguments required -dnl -dnl e.g. 6 arguments (linux) -dnl e.g. 5 arguments (solaris) -dnl e.g. 3 arguments (osf/1) -dnl -dnl @version $Id: acinclude.m4,v 1.6 2001/10/17 07:19:14 brian Exp $ -dnl @author Brian Stafford <brian@stafford.uklinux.net> -dnl -dnl based on version by Caolan McNamara <caolan@skynet.ie> -dnl based on David Arnold's autoconf suggestion in the threads faq -dnl with fixes and updates by Matthias Andree -dnl -AC_DEFUN([ACX_WHICH_GETHOSTBYNAME_R], -[AC_CACHE_CHECK(number of arguments to gethostbyname_r, - acx_cv_which_gethostbyname_r, [ - AC_TRY_LINK([ -# include <netdb.h> - ], [ - - char *name; - struct hostent *he; - struct hostent_data data; - (void) gethostbyname_r(name, he, &data); - - ],acx_cv_which_gethostbyname_r=3, - [ -dnl acx_cv_which_gethostbyname_r=0 - AC_TRY_LINK([ -#include <stdlib.h> -# include <netdb.h> - ], [ - char *name; - struct hostent *he, *res; - char *buffer = NULL; - int buflen = 2048; - int h_errnop; - (void) gethostbyname_r(name, he, buffer, buflen, &res, &h_errnop) - ],acx_cv_which_gethostbyname_r=6, - - [ -dnl acx_cv_which_gethostbyname_r=0 - AC_TRY_LINK([ -#include <stdlib.h> -# include <netdb.h> - ], [ - char *name; - struct hostent *he; - char *buffer = NULL; - int buflen = 2048; - int h_errnop; - (void) gethostbyname_r(name, he, buffer, buflen, &h_errnop) - ],acx_cv_which_gethostbyname_r=5,acx_cv_which_gethostbyname_r=0) - - ] - - ) - ] - ) - ]) - -if test $acx_cv_which_gethostbyname_r -gt 0 ; then - AC_DEFINE_UNQUOTED([HAVE_GETHOSTBYNAME_R], $acx_cv_which_gethostbyname_r, - [Number of parameters to gethostbyname_r or 0 if not available]) -fi - -]) |