[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
NSS and static binaries
From: |
Neal H Walfield |
Subject: |
NSS and static binaries |
Date: |
Thu, 16 Aug 2001 19:37:55 +0200 |
User-agent: |
Mutt/1.3.18i |
When using NSS functionality in a static binary, NSS still uses shared
libraries. This is explained in the libc faq, section 2.22.
Unfortunentally, this does not work on the Hurd. Here is a small test
case using initgroups:
initgroups.c:
#define _GNU_SOURCE
#include <grp.h>
#include <stdio.h>
#include <errno.h>
#include <error.h>
int
main (int argc, char *argv[])
{
int err;
err = initgroups ("neal", -1);
if (err == -1)
error (1, errno, "initgroups");
printf ("Success.\n");
return 0;
}
Here is the output on GNU/Linux with glibc 2.2.3-9:
neal@bassanio:~/initgroups (0)$ make
cc -Wall -g -static -o initgroups-static initgroups.c
cc -Wall -g -o initgroups initgroups.c
neal@bassanio:~/initgroups (0)$ ./initgroups
./initgroups: initgroups: Operation not permitted
neal@bassanio:~/initgroups (1)$ ./initgroups-static
./initgroups-static: initgroups: Operation not permitted
neal@bassanio:~/initgroups (1)$
and on the GNU/Hurd with glibc 2.2.3-9:
neal@desdemona:~/initgroups (0)$ make
cc -Wall -g -static -o initgroups-static initgroups.c
cc -Wall -g -o initgroups initgroups.c
neal@desdemona:~/initgroups (0)$ ./initgroups
./initgroups: initgroups: Operation not permitted
neal@desdemona:~/initgroups (1)$ ./initgroups-static
Segmentation fault
neal@desdemona:~/initgroups (139)$ gdb initgroups-static
GNU gdb 5.0
[ snip ]
This GDB was configured as "i386-unknown-gnu0.2"...
(gdb) run
Starting program: /home/neal/initgroups/initgroups-static
Program received signal SIGSEGV, Segmentation fault.
0x10bc301 in ?? ()
(gdb) bt
#0 0x10bc301 in ?? ()
#1 0x10bc478 in ?? ()
#2 0x10bca36 in ?? ()
#3 0x10b470a in ?? ()
#4 0x10bbb6c in ?? ()
#5 0x1072ee6 in ?? ()
#6 0x1072ac0 in ?? ()
#7 0x8086853 in call_init ()
#8 0x808698d in _dl_init ()
#9 0x80774d4 in dl_open_worker ()
#10 0x80762bf in _dl_catch_error ()
#11 0x80775dd in _dl_open ()
#12 0x8051f18 in do_dlopen ()
#13 0x80762bf in _dl_catch_error ()
#14 0x8051ed3 in dlerror_run ()
#15 0x8051f88 in __libc_dlopen ()
#16 0x805150d in __nss_lookup_function ()
#17 0x804ef73 in initgroups ()
#18 0x8048225 in main (argc=1, argv=0x1000ea4) at initgroups.c:12
#19 0x80486a0 in __libc_start_main ()
(gdb) quit
The program is running. Exit anyway? (y or n) y
neal@desdemona:~/initgroups (0)$ exit
pgpAqhN60dcpG.pgp
Description: PGP signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- NSS and static binaries,
Neal H Walfield <=