This is the mail archive of the
glibc-linux@ricardo.ecn.wfu.edu
mailing list for the glibc project.
Namespace pollution?
- To: glibc-linux at ricardo dot ecn dot wfu dot edu
- Subject: Namespace pollution?
- From: Steve Baker <ice at mama dot indstate dot edu>
- Date: Mon, 1 Nov 1999 18:18:38 -0500
- Reply-To: glibc-linux at ricardo dot ecn dot wfu dot edu
After spending many an hour debugging a program I have been working on
I've distilled a problem to the following (apologies if this is a known
problem):
-------
#include <stdio.h>
#include <sys/types.h>
#include <pwd.h>
int uname;
main()
{
struct passwd *pwd;
pwd = getpwuid(0);
if (pwd) printf("%s\n",pwd->pw_name);
}
-------
Using glibc 2.1.2 on slack 7.0, the above program will segfault if the
following two conditions are met:
1) there is a global variable by the name of "uname", like above.
2) the passwd entry in the /etc/nsswitch.conf is set to "compat"
(and one reported case where its set to: files nisplus nis).
If the passwd line is set to files, all is well. The gdb trace I have
includes:
#0 0x80495cd in ?? ()
#1 0x4010f6f6 in ?? () from /lib/libnsl.so.1
#2 0x40101295 in ?? () from /lib/libnss_compat.so.2
#3 0x4010350a in ?? () from /lib/libnss_compat.so.2
#4 0x400a1c00 in getpwuid_r () from /lib/libc.so.6
#5 0x400a14ec in getpwuid () from /lib/libc.so.6
#6 0x8048415 in main () at t.c:11
Sorry, no debugging symbols for the libs, I don't have that much time to
devote to the problem. Have fun.
- Steve