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/XXX-lookup.c | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) (limited to 'nss/XXX-lookup.c') diff --git a/nss/XXX-lookup.c b/nss/XXX-lookup.c index 48fc7b92fc..f1c97f7c8e 100644 --- a/nss/XXX-lookup.c +++ b/nss/XXX-lookup.c @@ -37,27 +37,20 @@ #define CONCAT3_1(Pre, Name, Post) CONCAT3_2 (Pre, Name, Post) #define CONCAT3_2(Pre, Name, Post) Pre##Name##Post +#define DATABASE_NAME_ID CONCAT2_1 (nss_database_, DATABASE_NAME) +#define CONCAT2_1(Pre, Name) CONCAT2_2 (Pre, Name) +#define CONCAT2_2(Pre, Name) Pre##Name + #define DATABASE_NAME_SYMBOL CONCAT3_1 (__nss_, DATABASE_NAME, _database) #define DATABASE_NAME_STRING STRINGIFY1 (DATABASE_NAME) #define STRINGIFY1(Name) STRINGIFY2 (Name) #define STRINGIFY2(Name) #Name -#ifdef ALTERNATE_NAME -#define ALTERNATE_NAME_STRING STRINGIFY1 (ALTERNATE_NAME) -#else -#define ALTERNATE_NAME_STRING NULL -#endif - -#ifndef DEFAULT_CONFIG -#define DEFAULT_CONFIG NULL -#endif - int DB_LOOKUP_FCT (nss_action_list *ni, const char *fct_name, const char *fct2_name, void **fctp) { - if (__nss_database_lookup2 (DATABASE_NAME_STRING, ALTERNATE_NAME_STRING, - DEFAULT_CONFIG, &DATABASE_NAME_SYMBOL) < 0) + if (! __nss_database_get (DATABASE_NAME_ID, &DATABASE_NAME_SYMBOL)) return -1; *ni = DATABASE_NAME_SYMBOL; -- cgit v1.2.3