Red Hat Bugzilla – Bug 89122
getpwnam in static executables segfaults if "compat" is listed for passwd in /etc/nsswitch.conf
Last modified: 2016-11-24 09:53:18 EST
From Bugzilla Helper:
User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.3) Gecko/20030319
Description of problem:
static binaries (like, say "rpm") will segfault on calls to getpwnam if "compat"
is listed in "passwd" line on /etc/nsswitch.conf, and you have an NIS keyword in
/etc/passwd (+@netgroup). This does not happen for dynamic-link binaries,
I imagine it's the magic used to dlopen the libnss_compat library into a static
binary's execution space, but gdb lost its mind when I tried to trace through
Version-Release number of selected component (if applicable):
Steps to Reproduce:
1. Add "+@bogus" to the end of /etc/passwd
2. Make sure "compat" is listed on the "passwd:" line of /etc/nsswitch.conf
3. Make an static binary with a call to "getpwnam" in it.
4. Run the binary. (or use "rpm" to install a src rpm)
Actual Results: # ./getpwnam.static rusty
Expected Results: # ./getpwnam rusty
No such user 'rusty'
If you "step" though it with gdb, you can see the execution about as far as the
calls in glibc's nss/getXXbyYY_r.c, but after the DL_CALL_FCT gdb loses it's
mind. It does, however, appear to end up in the nis/nss_compat/compat-pwd.c
Created attachment 91179 [details]
Output from gdb
Created attachment 91180 [details]
Minimal example code
I very much doubt that I'll fix that. NSS in statically linked apps is only
minimally supported, only simple services. In fact, static linking should be
avoided for almost any cost, it's evil and will always have problems.
Statically linked binaries are much less stable after runtime upgrades.
I'll look at the code but better get rid of either static linking or this NIS hack.
Well, it's pretty confusing to have "rpm" segfault. On the machines we
kickstart, we can't have our NIS running until all the RPMs are installed. Do
glibc 2.3.x's nss_compat libraries seg fault?
Sure you can use rpm. rpm is dynamically linked in RHL9.
As I said, I'll look briefly at it. If I cannot reproduce it or it turns out to
be more complicated than a tiny little change it'll not be fixed. Static
linking is bad. NIS is horrible. Combinbed it's a desaster.