htop icon indicating copy to clipboard operation
htop copied to clipboard

Disable user name lookup in static builds against glibc

Open cgzones opened this issue 1 year ago • 4 comments

Static linking against glibc might crash due to usage of NSS modules, e.g. via getpwuid() (see #503). The linker also warns about it:

warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

cgzones avatar Aug 24 '24 19:08 cgzones

@cgzones Anything still missing here?

BenBE avatar Sep 18 '24 21:09 BenBE

There might be still hidden usage of NSS modules, e.g. a static build reports:

/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `get_group_creds':
(.text.get_group_creds+0x84): warning: Using 'getgrgid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `getgrgid_malloc':
(.text.getgrgid_malloc+0x80): warning: Using 'getgrgid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `get_group_creds':
(.text.get_group_creds+0xe4): warning: Using 'getgrnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `getgrnam_malloc':
(.text.getgrnam_malloc+0x7c): warning: Using 'getgrnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_libsystemd_sd-bus_sd-bus.c.o): in function `bus_start_address.part.0':
(.text.bus_start_address.part.0+0x962): warning: Using 'getaddrinfo' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: Action.o: in function `Action_setUserOnly':
./Action.c:120:(.text+0x2158): warning: Using 'getpwnam' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `getpwnam_malloc':
(.text.getpwnam_malloc+0x7c): warning: Using 'getpwnam_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: Settings.o: in function `Settings_new':
./Settings.c:828:(.text+0x2928): warning: Using 'getpwuid' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/14/../../../x86_64-linux-gnu/libsystemd.a(src_basic_user-util.c.o): in function `getpwuid_malloc':
(.text.getpwuid_malloc+0x80): warning: Using 'getpwuid_r' in statically linked applications requires at runtime the shared libraries from the glibc version used for linking

Maybe it's best to recommend not using static builds on Linux against glibc?

cgzones avatar Oct 03 '24 14:10 cgzones

Can we check for glibc+static build in configure.ac and just issue a warning about this?

BenBE avatar Oct 03 '24 15:10 BenBE

I think we need to replace these NSS / getpwuid uses with alternate implementations. Can't have a static htop not even display users. It could just read (and cache) /etc/passwd.

Moving to the 3.5.0 milestone.

fasterit avatar Feb 20 '25 10:02 fasterit