[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Bug#381373: nscd: Sporadic gethostbyname() hostname failures



Package: nscd
Version: 2.3.2.ds1-22sarge3
Severity: important


I have not been able to determine the trigger but after some period of
time nscd will start returning failures for any attempt get the system 
hostname. Here's an example from an amd64 (i386 is also affected) sarge
system:

cadams@node5:~ $ hostname
node5
cadams@node5:~ $ hostname --fqdn
hostname: Unknown host
cadams@node5:~ $ sudo /etc/init.d/nscd stop
Stopping Name Service Cache Daemon: nscd.
cadams@node5:~ $ hostname --fqdn
node5.hydra.snl.salk.edu
cadams@node5:~ $ sudo /etc/init.d/nscd start
Starting Name Service Cache Daemon: nscd.
cadams@node5:~ $ hostname --fqdn
node5.hydra.snl.salk.edu

One the failure has happened all future attempts to get the system's
hostname will fail, which is why I've labeled this bug "important" as
we've run into a number of programs which do not handle that situation
gracefully.

I've used the program below to collect some some stats on which of our
hundred-odd Debian machines are currently experiencing failures so I could
verify that there wasn't some sort of unusual DNS glitch or network failure.
 
#include <unistd.h>
#include <netdb.h>
#include <syslog.h>
#include <stdlib.h>
#include <stdio.h>

char hostname[128];
struct hostent *he;

int main (int argc, char const* argv[]) {
        openlog(argv[0], LOG_PERROR | LOG_CONS | LOG_PID, LOG_LOCAL0);

        gethostname(hostname, sizeof(hostname));

        he = gethostbyname(hostname);
        if (he == NULL) {
                syslog(LOG_ERR, "gethostbyname(%s) failed: %m");
                exit(EXIT_FAILURE);
        } else {
                printf("System hostname: %s\n", hostname);
                unsigned int i=0;
                while ( he->h_addr_list[i] != NULL) {
                        printf("Resolved address: %s\n", inet_ntoa( *( struct in_addr*)( he->h_addr_list[i])));
                        i++;
       }
                exit(EXIT_SUCCESS);
        }

        closelog();
}



-- System Information:
Debian Release: 3.1
Architecture: i386 (x86_64)
Kernel: Linux 2.6.8-12-amd64-k8-smp
Locale: LANG=C, LC_CTYPE=C (charmap=ANSI_X3.4-1968)

Versions of packages nscd depends on:
ii  libc6                 2.3.2.ds1-22sarge3 GNU C Library: Shared libraries an

-- no debconf information



Reply to: