From 9b456c5da968ee832ea4b2b73a18a5bf6d2118a6 Mon Sep 17 00:00:00 2001 From: DJ Delorie Date: Mon, 15 Feb 2021 21:34:23 -0500 Subject: 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. --- nss/tst-nss-compat1.root/etc/group | 1 + nss/tst-nss-compat1.root/etc/nsswitch.conf | 3 +++ nss/tst-nss-compat1.root/etc/passwd | 3 +++ nss/tst-nss-compat1.root/etc/shadow | 2 ++ nss/tst-nss-compat1.root/tst-nss-compat1.script | 1 + 5 files changed, 10 insertions(+) create mode 100644 nss/tst-nss-compat1.root/etc/group create mode 100644 nss/tst-nss-compat1.root/etc/nsswitch.conf create mode 100644 nss/tst-nss-compat1.root/etc/passwd create mode 100644 nss/tst-nss-compat1.root/etc/shadow create mode 100644 nss/tst-nss-compat1.root/tst-nss-compat1.script (limited to 'nss/tst-nss-compat1.root') diff --git a/nss/tst-nss-compat1.root/etc/group b/nss/tst-nss-compat1.root/etc/group new file mode 100644 index 0000000000..ee467c7950 --- /dev/null +++ b/nss/tst-nss-compat1.root/etc/group @@ -0,0 +1 @@ +wilma:x:100: diff --git a/nss/tst-nss-compat1.root/etc/nsswitch.conf b/nss/tst-nss-compat1.root/etc/nsswitch.conf new file mode 100644 index 0000000000..7fe69d5ffa --- /dev/null +++ b/nss/tst-nss-compat1.root/etc/nsswitch.conf @@ -0,0 +1,3 @@ +passwd : compat +passwd_compat : test1 + diff --git a/nss/tst-nss-compat1.root/etc/passwd b/nss/tst-nss-compat1.root/etc/passwd new file mode 100644 index 0000000000..84635587bd --- /dev/null +++ b/nss/tst-nss-compat1.root/etc/passwd @@ -0,0 +1,3 @@ +name5:x:5:555:name5 for testing:/home/name5:/bin/nologin ++name100 ++name30 diff --git a/nss/tst-nss-compat1.root/etc/shadow b/nss/tst-nss-compat1.root/etc/shadow new file mode 100644 index 0000000000..cba3152172 --- /dev/null +++ b/nss/tst-nss-compat1.root/etc/shadow @@ -0,0 +1,2 @@ ++name100 ++name30 diff --git a/nss/tst-nss-compat1.root/tst-nss-compat1.script b/nss/tst-nss-compat1.root/tst-nss-compat1.script new file mode 100644 index 0000000000..fe6e863f01 --- /dev/null +++ b/nss/tst-nss-compat1.root/tst-nss-compat1.script @@ -0,0 +1 @@ +cp $B/nss/libnss_test1.so $L/libnss_test1.so.2 -- cgit 1.4.1