nss: fix nss_database_lookup2's alternate handling [BZ #27416]
commit9b456c5da968ee832ea4b2b73a18a5bf6d2118a6
authorDJ Delorie <dj@redhat.com>
Tue, 16 Feb 2021 02:34:23 +0000 (15 21:34 -0500)
committerDJ Delorie <dj@redhat.com>
Tue, 9 Mar 2021 19:34:50 +0000 (9 14:34 -0500)
treee0f9e838dd5862499207e16cf6e8b3d15d49d374
parent24eb3be5db5befefe4bcf0f438bf6629a9c3a608
nss: fix nss_database_lookup2's alternate handling [BZ #27416]

__nss_database_lookup2's extra arguments were left unused in the
nsswitch reloading patch set; this broke compat (default config
ignored) and shadow files (secondary name ignored) which relies on
these fallbacks.

This patch adds in the previous behavior by correcting the
initialization of the database list to reflect the fallbacks.  This
means that the nss_database_lookup2 interface no longer needs to be
passed the fallback info, so API and callers were adjusted.

Since all callers needed to be edited anyway, the calls were changed
from __nss_database_lookup2 to the faster __nss_database_get.  This
was an intended optimization which was deferred during the initial
lookup changes to avoid touching so many files.

The test case verifies that compat targets work (passwd) and that the
default configuration works (group).  Tested on x86-64.
32 files changed:
nscd/aicache.c
nscd/initgrcache.c
nscd/netgroupcache.c
nss/Makefile
nss/Versions
nss/XXX-lookup.c
nss/databases.def
nss/grp-lookup.c
nss/hosts-lookup.c
nss/key-lookup.c
nss/network-lookup.c
nss/nss_compat/compat-grp.c
nss/nss_compat/compat-initgroups.c
nss/nss_compat/compat-pwd.c
nss/nss_compat/compat-spwd.c
nss/nss_database.c
nss/nss_database.h
nss/nss_module.c
nss/nss_test.h
nss/nss_test1.c
nss/nsswitch.c
nss/nsswitch.h
nss/pwd-lookup.c
nss/sgrp-lookup.c
nss/spwd-lookup.c
nss/tst-nss-compat1.c [new file with mode: 0644]
nss/tst-nss-compat1.root/etc/group [new file with mode: 0644]
nss/tst-nss-compat1.root/etc/nsswitch.conf [new file with mode: 0644]
nss/tst-nss-compat1.root/etc/passwd [new file with mode: 0644]
nss/tst-nss-compat1.root/etc/shadow [new file with mode: 0644]
nss/tst-nss-compat1.root/tst-nss-compat1.script [new file with mode: 0644]
sysdeps/posix/getaddrinfo.c