Skip to content

Hack to make Fedora hosts not warn about unexpected open fd

Evan Klitzke requested to merge eklitzke/waypipe:sssd_cache into master

I found an issue related to #40 (closed), when the remote/child host is Fedora I always get the following message from the child when shutting down waypipe:

[src/util.c:238] Unexpected open fd 11

The warning itself is harmless, but I wanted to see what was going on. I figured out this is caused by an open handle to /var/lib/sss/mc/passwd which is due to the following change in Fedora: https://fedoraproject.org/wiki/Changes/SSSDCacheForLocalUsers

The change I've implemented here is pretty gross, but it does work. Basically we just force an NSS user resolution before constructing inherited_fds, which will cause any SSSD cache handles to be opened at that time. Unfortunately this means waypipe will do an unnecessary NSS resolution on other distros.

An alternative way to fix this issue is to only call getpwuid() if libnss_sss.so is loaded, which can be approximated using dlsym() like this:

if (dlsym(RTLD_DEFAULT, "_nss_sss_getpwnam_r") != NULL) {
	getpwuid(getuid());
}

I couldn't figure out how to get this to actually work with Meson, the issue is that it requires linking with -ldl which isn't a real library on Linux, instead there's some magic glibc stuff that makes RTLD_DEFAULT visible when -ldl is used. I'm not really convinced this is a better approach anyway since it's a lot more complicated.

Merge request reports