[Bug 727360] New: glibc's HOSTALIASES does not work as described (for non suid/sgid binaries)
https://bugzilla.novell.com/show_bug.cgi?id=727360 https://bugzilla.novell.com/show_bug.cgi?id=727360#c0 Summary: glibc's HOSTALIASES does not work as described (for non suid/sgid binaries) Classification: openSUSE Product: openSUSE 11.2 Version: Final Platform: All OS/Version: SLES 11 Status: NEW Severity: Normal Priority: P5 - None Component: Development AssignedTo: pth@suse.com ReportedBy: brian.cain@gmail.com QAContact: qa@suse.de Found By: --- Blocker: --- User-Agent: Mozilla/5.0 (Windows NT 5.1) AppleWebKit/535.2 (KHTML, like Gecko) Chrome/15.0.874.106 Safari/535.2 The HOSTALIASES environment variable does not modify gethostbyname() as documented, but it is effective on other distros (with earlier upstream glibc releases). Is there a way to override this behavior on SLES, or has glibc been built such as to disable the feature entirely? Reproducible: Always Steps to Reproduce: ~~~~~~~ cat <<EOF > lookup.c #include <netdb.h> #include <stdlib.h> #include <stdio.h> int main(int argc, const char *argv[]) { const char *hostname_to_lookup = "z"; setenv("HOSTALIASES", "fakehosts", 1); struct hostent *foo = gethostbyname(hostname_to_lookup); if (!foo) { herror("error in hostname resolution"); } else { printf("w00t\n"); } return 0; } EOF echo "z localhost" > fakehosts gcc -o lookup lookup.c stat -c '%A' ./lookup -rwxrwxr-x /lookup ~~~~~~~ gethostbyname(3) excerpt: ~~~~~~~ .. in_addr equivalent into the h_addr_list[0] field of the returned hostent structure. If name doesn't end in a dot and the environment variable HOSTALIASES is set, the alias file pointed to by HOSTALIASES will first be searched for name (see hostname(7) for the file format). The current domain and its parents are searched unless name ends in a dot. .. ~~~~~~~ Actual Results: Fails (prints "error in hostname resolution") Expected Results: Succeeds (prints "w00t") on CentOS 5.6 (glibc 2.5) and Red Hat Linux release 9 (Shrike) w/glibc 2.3.3. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=727360 https://bugzilla.novell.com/show_bug.cgi?id=727360#c Philipp Thomas <pth@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |pth@suse.com AssignedTo|pth@suse.com |aj@suse.com -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=727360 https://bugzilla.novell.com/show_bug.cgi?id=727360#c2 Michael Matz <matz@suse.com> changed: What |Removed |Added ---------------------------------------------------------------------------- Status|NEW |RESOLVED Resolution| |UPSTREAM --- Comment #2 from Michael Matz <matz@suse.com> 2011-11-02 15:38:39 UTC --- Debian switches off caching of the hosts database in nscd for instance (since glibc 2.5), that's why it works there. I guess Redhat either does the same, or these old glibcs really behaved differently. I can't see how how current libcs would ever have worked differently. With nscd hosts caching the __libc_res_nquery routine never is entered (and never was), and that's the only one that calls res_hostalias, and that's the only one that respects this environment variable. It's either a documentation bug or a code bug, but in any case it's an upstream bug, now reported here: http://sourceware.org/bugzilla/show_bug.cgi?id=13375 -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
https://bugzilla.novell.com/show_bug.cgi?id=727360 https://bugzilla.novell.com/show_bug.cgi?id=727360#c3 --- Comment #3 from Brian Cain <brian.cain@gmail.com> 2011-11-02 15:50:12 UTC --- (In reply to comment #2)
Debian switches off caching of the hosts database in nscd for instance (since glibc 2.5), that's why it works there. I guess Redhat either does the same, or these old glibcs really behaved differently. I can't see how how current libcs would ever have worked differently. With nscd hosts caching the __libc_res_nquery routine never is entered (and never was), and that's the only one that calls res_hostalias, and that's the only one that respects this environment variable.
So barring nscd caching might re-enable the feature? Can you imagine any other workarounds?
It's either a documentation bug or a code bug, but in any case it's an upstream bug, now reported here: http://sourceware.org/bugzilla/show_bug.cgi?id=13375
Thanks. -- Configure bugmail: https://bugzilla.novell.com/userprefs.cgi?tab=email ------- You are receiving this mail because: ------- You are on the CC list for the bug.
participants (1)
-
bugzilla_noreply@novell.com