NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
gethostbyname(3) doesn't appear to work under NetBSD-5.2 and NetBSD-6.1.x when hostnames appear only in /etc/hosts
hello. It appears that gethostbyname(3) in NetBSD-5.2 and 6.1.x is
broken if the name you're trying to fetch is listed in /etc/hosts and
nowhere else. The problem appears to be with this change:
RCS file: /cvsroot/src/lib/libc/net/gethnamaddr.c
revision 1.73.18.3
date: 2013-12-23 23:12:44 +0000; author: riz; state: Exp; lines: +10 -7;
commitid: QLuYhA2iZpQzpjix;
Apply patch (requested by bad in ticket #1887):
src/lib/libc/net/getaddrinfo.c r1.106:
this is supposed to be re-entrant, call don't call __hostalias that uses
a static buffer.
src/lib/libc/net/gethnamaddr.c r1.85:
- don't clobber hp in the RES_USE_INET6 case
- increment naddrs in the yp case
- don't use __hostalias(), it is not thread-safe.
This should finish addressing PR lib/46454
----------------------------
Here are some scripts that demonstrate the problem. Note I've only shown
the issue under NetbSD-5.1 and 5.2, but NetBSD-6.1.x exhibits the
NetBSD-5.2 broken behavior.
good script started on Wed Jun 18 23:35:48 2014
stats# uname -a
NetBSD stats 5.1_STABLE NetBSD 5.1_STABLE (X2200) #0: Mon Mar 18 11:05:41 PDT
2013
buhrow%lothlorien.nfbcal.org@localhost:/usr/src/sys/arch/i386/compile/X2200 i386
stats# ident /lib/libc.so.12.164 |grep 'gethnamaddr'
$NetBSD: gethnamaddr.c,v 1.73 2007/01/27 22:27:35 christos Exp $
stats# cat /etc/hosts |tail -1
192.168.3.1 this_host_only_in_etc_hosts.via.net this_host_only_in_etc_hosts
stats# getent hosts this_host_only_in_etc_hosts
192.168.3.1 this_host_only_in_etc_hosts.via.net this_host_only_in_etc_hosts
stats# exit
bad script started on Wed Jun 18 23:38:58 2014
mirkwood#
mirkwood# uname -a
NetBSD mirkwood.nfbcal.org 5.2_STABLE NetBSD 5.2_STABLE (RBL) #0: Mon Mar 24
21:42:05 PDT 2014
buhrow%lothlorien.nfbcal.org@localhost:/usr/src/sys/arch/i386/compile/RBL i386
mirkwood# ident /lib/libc.so.12.164 |grep 'gethnamaddr'
$NetBSD: gethnamaddr.c,v 1.73.18.3 2013/12/23 23:12:44 riz Exp $
mirkwood# cat /etc/hosts |tail -1
192.168.3.1 this_host_only_in_etc_hosts.via.net this_host_only_in_etc_hosts
mirkwood# getent hosts this_host_only_in_etc_hosts
mirkwood# exit
I'm not familiar enough with the libc resolver code to feel confident
enough to make a commitable fix. Has anyone else run into this behavior?
Even better, has anyone found a fix?
-thanks
-brian
Home |
Main Index |
Thread Index |
Old Index