fakechroot
fakechroot copied to clipboard
Wrap all functions accessing /etc/passwd, /etc/group and /etc/shadow for glibc >= 2.34
closes: #97
Starting with glibc 2.32 the compat nss module for getpwnam calls __nss_files_fopen (which is a GLIBC_PRIVATE symbol provided by glibc) instead of fopen (see 299210c1fa67e2dfb564475986fce11cd33db9ad). This leads to getpwnam calls accessing /etc/passwd from outside the chroot and as a result programs like adduser do not work correctly anymore under fakechroot.
Starting with glibc 2.34 the __nss_files_fopen was moved from nss to libc.so and thus wrapping it with LD_PRELOAD has no affect anymore (see 6212bb67f4695962748a5981e1b9fea105af74f6).
So now we also wrap all the functions accessing /etc/passwd, /etc/group and /etc/shadow. This solution will ignore NIS, LDAP or other local files as potentially configured in /etc/nsswitch.conf.