X-Git-Url: https://arthur.barton.de/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=src%2Fngircd%2Fresolve.c;h=1931bc712e3be470672b92d484c7c9a9c9846f41;hb=c7de505c919c5f550d848f9cafae99532bc1f789;hp=0d6a294e114865b307df0012d7e88cc6adeb2115;hpb=7e14bd3b58522ac34f0af29182248df1577d99c9;p=ngircd.git diff --git a/src/ngircd/resolve.c b/src/ngircd/resolve.c index 0d6a294e..1931bc71 100644 --- a/src/ngircd/resolve.c +++ b/src/ngircd/resolve.c @@ -93,9 +93,7 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short)) pid = Proc_Fork(s, pipefd, cbfunc, RESOLVER_TIMEOUT); if (pid > 0) { /* Main process */ -#ifdef DEBUG Log( LOG_DEBUG, "Resolver for \"%s\" created (PID %d).", Host, pid ); -#endif return true; } else if( pid == 0 ) { /* Sub process */ @@ -108,9 +106,8 @@ Resolve_Name( PROC_STAT *s, const char *Host, void (*cbfunc)(int, short)) return false; } /* Resolve_Name */ - -#if !defined(HAVE_GETADDRINFO) || !defined(HAVE_GETNAMEINFO) -#if !defined(WANT_IPV6) && defined(h_errno) +#if !defined(HAVE_WORKING_GETADDRINFO) || !defined(HAVE_GETNAMEINFO) +#ifdef h_errno static char * Get_Error( int H_Error ) { @@ -141,15 +138,11 @@ Do_IdentQuery(int identsock, array *resolved_addr) if (identsock < 0) return; -#ifdef DEBUG Log_Subprocess(LOG_DEBUG, "Doing IDENT lookup on socket %d ...", identsock); -#endif res = ident_id( identsock, 10 ); -#ifdef DEBUG Log_Subprocess(LOG_DEBUG, "Ok, IDENT lookup on socket %d done: \"%s\"", identsock, res ? res : "(NULL)"); -#endif if (!res) /* no result */ return; if (!array_cats(resolved_addr, res)) @@ -217,8 +210,8 @@ ReverseLookup(const ng_ipaddr_t *IpAddr, char *resbuf, size_t reslen) assert(reslen >= NG_INET_ADDRSTRLEN); ng_ipaddr_tostr_r(IpAddr, tmp_ip_str); - Log_Subprocess(LOG_WARNING, "%s: Can't resolve address \"%s\": %s", - funcname, tmp_ip_str, errmsg); + Log_Subprocess(LOG_WARNING, "Can't resolve address \"%s\": %s [%s].", + tmp_ip_str, errmsg, funcname); strlcpy(resbuf, tmp_ip_str, reslen); return false; } @@ -233,7 +226,11 @@ ReverseLookup(const ng_ipaddr_t *IpAddr, char *resbuf, size_t reslen) * @return true if lookup successful, false if domain name not found */ static bool +#ifdef HAVE_WORKING_GETADDRINFO ForwardLookup(const char *hostname, array *IpAddr, int af) +#else +ForwardLookup(const char *hostname, array *IpAddr, UNUSED int af) +#endif { ng_ipaddr_t addr; @@ -242,9 +239,6 @@ ForwardLookup(const char *hostname, array *IpAddr, int af) struct addrinfo *a, *ai_results; static struct addrinfo hints; -#ifdef AI_ADDRCONFIG /* glibc has this, but not e.g. netbsd 4.0 */ - hints.ai_flags = AI_ADDRCONFIG; -#endif hints.ai_socktype = SOCK_STREAM; hints.ai_protocol = IPPROTO_TCP; hints.ai_family = af; @@ -373,9 +367,7 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd) array_init(&resolved_addr); ng_ipaddr_tostr_r(Addr, tmp_ip_str); -#ifdef DEBUG Log_Subprocess(LOG_DEBUG, "Now resolving %s ...", tmp_ip_str); -#endif if (!ReverseLookup(Addr, hostname, sizeof(hostname))) goto dns_done; @@ -388,9 +380,7 @@ Do_ResolveAddr(const ng_ipaddr_t *Addr, int identsock, int w_fd) Log_Forgery_NoIP(tmp_ip_str, hostname); strlcpy(hostname, tmp_ip_str, sizeof(hostname)); } -#ifdef DEBUG Log_Subprocess(LOG_DEBUG, "Ok, translated %s to \"%s\".", tmp_ip_str, hostname); -#endif dns_done: len = strlen(hostname); hostname[len] = '\n'; @@ -417,10 +407,8 @@ Do_ResolveName( const char *Host, int w_fd ) * to parent. */ array IpAddrs; int af; -#ifdef DEBUG ng_ipaddr_t *addr; size_t len; -#endif Log_Subprocess(LOG_DEBUG, "Now resolving \"%s\" ...", Host); array_init(&IpAddrs); @@ -440,7 +428,6 @@ Do_ResolveName( const char *Host, int w_fd ) close(w_fd); return; } -#ifdef DEBUG len = array_length(&IpAddrs, sizeof(*addr)); assert(len > 0); addr = array_start(&IpAddrs); @@ -449,7 +436,6 @@ Do_ResolveName( const char *Host, int w_fd ) Log_Subprocess(LOG_DEBUG, "translated \"%s\" to %s.", Host, ng_ipaddr_tostr(addr)); } -#endif /* Write result into pipe to parent */ ArrayWrite(w_fd, &IpAddrs);