about summary refs log tree commit diff
path: root/nss/nss_compat
diff options
context:
space:
mode:
authorDJ Delorie <dj@redhat.com>2021-02-15 21:34:23 -0500
committerDJ Delorie <dj@redhat.com>2021-03-09 14:34:50 -0500
commit9b456c5da968ee832ea4b2b73a18a5bf6d2118a6 (patch)
treee0f9e838dd5862499207e16cf6e8b3d15d49d374 /nss/nss_compat
parent24eb3be5db5befefe4bcf0f438bf6629a9c3a608 (diff)
downloadglibc-9b456c5da968ee832ea4b2b73a18a5bf6d2118a6.tar.gz
glibc-9b456c5da968ee832ea4b2b73a18a5bf6d2118a6.tar.xz
glibc-9b456c5da968ee832ea4b2b73a18a5bf6d2118a6.zip
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.
Diffstat (limited to 'nss/nss_compat')
-rw-r--r--nss/nss_compat/compat-grp.c2
-rw-r--r--nss/nss_compat/compat-initgroups.c2
-rw-r--r--nss/nss_compat/compat-pwd.c2
-rw-r--r--nss/nss_compat/compat-spwd.c3
4 files changed, 4 insertions, 5 deletions
diff --git a/nss/nss_compat/compat-grp.c b/nss/nss_compat/compat-grp.c
index eb4c68d5d4..aaf35e75b4 100644
--- a/nss/nss_compat/compat-grp.c
+++ b/nss/nss_compat/compat-grp.c
@@ -81,7 +81,7 @@ static bool in_blacklist (const char *, int, ent_t *);
 static void
 init_nss_interface (void)
 {
-  if (__nss_database_lookup2 ("group_compat", NULL, "nis", &ni) >= 0)
+  if (__nss_database_get (nss_database_group_compat, &ni))
     {
       setgrent_impl = __nss_lookup_function (ni, "setgrent");
       getgrnam_r_impl = __nss_lookup_function (ni, "getgrnam_r");
diff --git a/nss/nss_compat/compat-initgroups.c b/nss/nss_compat/compat-initgroups.c
index cfd36b64b8..c3b065c931 100644
--- a/nss/nss_compat/compat-initgroups.c
+++ b/nss/nss_compat/compat-initgroups.c
@@ -91,7 +91,7 @@ init_nss_interface (void)
 
   /* Retest.  */
   if (ni == NULL
-      && __nss_database_lookup2 ("group_compat", NULL, "nis", &ni) >= 0)
+      && __nss_database_get (nss_database_group_compat, &ni))
     {
       initgroups_dyn_impl = __nss_lookup_function (ni, "initgroups_dyn");
       getgrnam_r_impl = __nss_lookup_function (ni, "getgrnam_r");
diff --git a/nss/nss_compat/compat-pwd.c b/nss/nss_compat/compat-pwd.c
index f536754559..64d708ff63 100644
--- a/nss/nss_compat/compat-pwd.c
+++ b/nss/nss_compat/compat-pwd.c
@@ -91,7 +91,7 @@ static bool in_blacklist (const char *, int, ent_t *);
 static void
 init_nss_interface (void)
 {
-  if (__nss_database_lookup2 ("passwd_compat", NULL, "nis", &ni) >= 0)
+  if (__nss_database_get (nss_database_passwd_compat, &ni))
     {
       setpwent_impl = __nss_lookup_function (ni, "setpwent");
       getpwnam_r_impl = __nss_lookup_function (ni, "getpwnam_r");
diff --git a/nss/nss_compat/compat-spwd.c b/nss/nss_compat/compat-spwd.c
index 5c91f9572a..b548dfbee1 100644
--- a/nss/nss_compat/compat-spwd.c
+++ b/nss/nss_compat/compat-spwd.c
@@ -88,8 +88,7 @@ static bool in_blacklist (const char *, int, ent_t *);
 static void
 init_nss_interface (void)
 {
-  if (__nss_database_lookup2 ("shadow_compat", "passwd_compat",
-			      "nis", &ni) >= 0)
+  if (__nss_database_get (nss_database_shadow_compat, &ni))
     {
       setspent_impl = __nss_lookup_function (ni, "setspent");
       getspnam_r_impl = __nss_lookup_function (ni, "getspnam_r");