Gentoo Websites Logo
Go to: Gentoo Home Documentation Forums Lists Bugs Planet Store Wiki Get Gentoo!
Bug 41597 - gethostbyname does not work
Summary: gethostbyname does not work
Status: RESOLVED DUPLICATE of bug 41608
Alias: None
Product: Gentoo Linux
Classification: Unclassified
Component: [OLD] Core system (show other bugs)
Hardware: All Linux
: High major (vote)
Assignee: Please assign to toolchain
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2004-02-14 16:09 UTC by José Romildo Malaquias
Modified: 2005-07-17 13:06 UTC (History)
1 user (show)

See Also:
Package list:
Runtime testing required: ---


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description José Romildo Malaquias 2004-02-14 16:09:59 UTC
I have noticed that the noip-updater package has stopped working for some time to me, but I have not stopped too look into the problem, as it was not important to me until now. The log registers the following:

Feb 14 21:01:15 gentoo noip2[6855]: Can't gethostbyname for dynupdate.no-ip.com

I checked the hostx works. Then I tested the gethostbyname function with the simple program:

$ cat gh.c
#include <stdio.h>
#include <netdb.h>
 
int main(void)
{
   struct hostent * h;
 
   h = gethostbyname("gentoo.org");
 
   herror("ERROR FOUND: ");
 
   printf("name     = %s\n", h->h_name);
   printf("addrtype = %i\n", h->h_addrtype);
   printf("length   = %i\n", h->h_length);
   printf("addr     = %s\n", h->h_addr_list[0]);
 
   return 0;
}

$ ./gh
ERROR FOUND: : Unknown host
name     = gentoo.org
addrtype = 2
length   = 4
addr     = 
Comment 1 José Romildo Malaquias 2004-02-14 16:09:59 UTC
I have noticed that the noip-updater package has stopped working for some time to me, but I have not stopped too look into the problem, as it was not important to me until now. The log registers the following:

Feb 14 21:01:15 gentoo noip2[6855]: Can't gethostbyname for dynupdate.no-ip.com

I checked the hostx works. Then I tested the gethostbyname function with the simple program:

$ cat gh.c
#include <stdio.h>
#include <netdb.h>
 
int main(void)
{
   struct hostent * h;
 
   h = gethostbyname("gentoo.org");
 
   herror("ERROR FOUND: ");
 
   printf("name     = %s\n", h->h_name);
   printf("addrtype = %i\n", h->h_addrtype);
   printf("length   = %i\n", h->h_length);
   printf("addr     = %s\n", h->h_addr_list[0]);
 
   return 0;
}

$ ./gh
ERROR FOUND: : Unknown host
name     = gentoo.org
addrtype = 2
length   = 4
addr     = ÌJcd

$ hostx gentoo.org
gentoo.org              A       204.74.99.100

So it seems that glibc is buggy!


Reproducible: Always
Steps to Reproduce:
1.
2.
3.




# emerge --info
Portage 2.0.50-r1 (default-x86-1.4, gcc-3.3.2, glibc-2.3.3_pre20040207-r0,
2.6.3-rc2-gentoo)
=================================================================
System uname: 2.6.3-rc2-gentoo i686 AMD Athlon(tm) XP 2000+
Gentoo Base System version 1.4.3.13
Autoconf: sys-devel/autoconf-2.59
Automake: sys-devel/automake-1.8.2
ACCEPT_KEYWORDS="x86 ~x86"
AUTOCLEAN="yes"
CFLAGS="-O2 -march=athlon-xp -funroll-loops -fprefetch-loop-arrays -pipe"
CHOST="i686-pc-linux-gnu"
COMPILER="gcc3"
CONFIG_PROTECT="/etc /usr/X11R6/lib/X11/xkb /usr/kde/2/share/config
/usr/kde/3.2/share/config /usr/kde/3/share/config /usr/share/config
/usr/share/texmf/dvipdfm/config/ /usr/share/texmf/dvips/config/
/usr/share/texmf/tex/generic/config/ /usr/share/texmf/tex/platex/config/
/usr/share/texmf/xdvi/ /var/qmail/control"
CONFIG_PROTECT_MASK="/etc/gconf /etc/env.d"
CXXFLAGS="-O2 -march=athlon-xp -funroll-loops -fprefetch-loop-arrays -pipe"
DISTDIR="/usr/portage/distfiles"
FEATURES="autoaddcvs buildpkg ccache sandbox"
GENTOO_MIRRORS="http://www.ibiblio.org/pub/Linux/distributions/gentoo"
MAKEOPTS="-j2"
PKGDIR="/usr/portage/packages"
PORTAGE_TMPDIR="/var/tmp"
PORTDIR="/usr/portage"
PORTDIR_OVERLAY="/usr/local/portage"
SYNC="rsync://rsync.namerica.gentoo.org/gentoo-portage"
USE="3dnow X aalib acl acpi alsa apm arts artswrappersuid avi berkdb bonobo cdr
crypt cups dvd encode esd fbcon foomaticdb gdbm gif gnome gpm gracenote gtk gtk2
gtkhtml guile imap imlib imlib2 java javascript jpeg kde libg++ libwww
linguas_de linguas_en linguas_fr linguas_pt lirc mad mbox mikmod mmx motif
mozilla mozsvg mpeg mysql ncurses nls oggvorbis opengl oss pam pdflib perl png
python qt quicktime readline rplay samba sdl slang spell sse ssl stroke svga
tcltk tcpd tetex tiff truetype usb wmf x86 xface xml xml2 xmms xv zlib"
Comment 2 SpanKY gentoo-dev 2004-02-14 16:16:53 UTC
if it failed to work then gethostbyname() would have returned null

i dont know why h_errno is being set to 1, but this behavior occurs with glibc-2.2.5 as well as the latest 2.3.3_pre that it's in portage

so perhaps the correct behavior would be to:
if (!h)
   herror("ERROR");
Comment 3 José Romildo Malaquias 2004-02-14 17:48:41 UTC
The original problem is that the noip2 proram from the net-dns/noip-updater package is not working and gives te message

Can't gethostbyname for dynupdate.no-ip.com

Then I wrote the test program to test it. But it seems that the problem is not with the gethostbyname() function, As it works in this test after changing the way the error condition is checked.

So I have openned a new bug 41608, "gethostbyname failure in net-dns/noip-updater".
Comment 4 SpanKY gentoo-dev 2004-02-14 17:53:56 UTC

*** This bug has been marked as a duplicate of 41608 ***
Comment 5 Martin Schlemmer (RETIRED) gentoo-dev 2004-02-14 23:59:42 UTC
Check the manpage (last sentence):

--
RETURN VALUE
       The gethostbyname() and gethostbyaddr() functions return the hostent structure or a NULL  pointer  if  an
       error occurs.  On error, the h_errno variable holds an error number.  When non-NULL, the return value may
       point at static data, see the Notes below.