From Bugzilla Helper: User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.10) Gecko/20050720 Fedora/1.0.6-1.1.fc3 Firefox/1.0.6 Description of problem: /etc/nsswitch.conf contains: passwd: compat Here is a.c: ----#include <unistd.h> #include <sys/types.h> #include <pwd.h> main() { struct passwd *p; p = getpwuid(303); if (p != NULL) printf("%s\n",p -> pw_name); exit (0); } --- Output: gcc -o a a.c; ./a => correct (displays good username) gcc -o a a.c -lbind; ./a => incorrect (no display) Version-Release number of selected component (if applicable): bind-libs-9.3.1-4 How reproducible: Always Steps to Reproduce: 1. Use Fedora Core 3 or Fedora Core 4 2. Set up /etc/nsswitch.conf with 'passwd:compat' 3. Compile my program with ou without '-lbind' Additional info:
I cannot reproduce this problem. Firstly, the bind-libbind package provides the BIND 8 resolver library for applications that specifically require it, not as the system default resolver. Unless you specifically require use of the BIND resolver, use the system resolver. The system resolver is in glibc; you use it automatically with this compile: # gcc -o a a.c See man resolver(3) Only the system resolver uses /etc/nsswitch.conf; libbind uses /etc/irs.conf (see man libbind-irs.conf). In order to use libbind, you need to include the headers in /usr/include/bind BEFORE the system headers, and link with libbind BEFORE glibc - ie. : --- #include <bind/irs.h> #include <bind/resolv.h> #include <bind/arpa/inet.h> #include <bind/arpa/nameser.h> #include <unistd.h> #include <sys/types.h> #include <stdio.h> #include <stdlib.h> main() { struct passwd *p; p = getpwuid(25); if (p != NULL) printf("%s\n",p -> pw_name); exit (0); } --- This works fine on my system for local users: # gcc -o a a.c -lbind # ./a named You'd need to configure /etc/irs.conf to retrieve information about NIS, NISPLUS, LDAP, or Hesiod users. If you require to use the libbind library, and after having followed the above steps to pick up the correct includes, and having configured irs.conf if you need to resolve non-local users, you still have a problem, please re-open this bug; I'm closing it as NOTABUG since I cannot reproduce it with correct use of the libbind library.