diff options
author | DJ Delorie <dj@redhat.com> | 2021-02-15 21:34:23 -0500 |
---|---|---|
committer | DJ Delorie <dj@redhat.com> | 2021-03-09 14:34:50 -0500 |
commit | 9b456c5da968ee832ea4b2b73a18a5bf6d2118a6 (patch) | |
tree | e0f9e838dd5862499207e16cf6e8b3d15d49d374 /nss/nss_module.c | |
parent | 24eb3be5db5befefe4bcf0f438bf6629a9c3a608 (diff) | |
download | glibc-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_module.c')
-rw-r--r-- | nss/nss_module.c | 20 |
1 files changed, 6 insertions, 14 deletions
diff --git a/nss/nss_module.c b/nss/nss_module.c index 6c5f341f3e..60c070c851 100644 --- a/nss/nss_module.c +++ b/nss/nss_module.c @@ -31,14 +31,6 @@ #include <stdlib.h> #include <string.h> -#ifdef LINK_OBSOLETE_NSL -# define DEFAULT_CONFIG "compat [NOTFOUND=return] files" -# define DEFAULT_DEFCONFIG "nis [NOTFOUND=return] files" -#else -# define DEFAULT_CONFIG "files" -# define DEFAULT_DEFCONFIG "files" -#endif - /* Suffix after .so of NSS service modules. This is a bit of magic, but we assume LIBNSS_FILES_SO looks like "libnss_files.so.2" and we want a pointer to the ".2" part. We have no API to extract this @@ -292,11 +284,11 @@ __nss_module_get_function (struct nss_module *module, const char *name) #if defined SHARED && defined USE_NSCD /* Load all libraries for the service. */ static void -nss_load_all_libraries (const char *service, const char *def) +nss_load_all_libraries (enum nss_database service) { nss_action_list ni = NULL; - if (__nss_database_lookup2 (service, NULL, def, &ni) == 0) + if (__nss_database_get (service, &ni)) while (ni->module != NULL) { __nss_module_load (ni->module); @@ -323,10 +315,10 @@ __nss_disable_nscd (void (*cb) (size_t, struct traced_file *)) is_nscd = true; /* Find all the relevant modules so that the init functions are called. */ - nss_load_all_libraries ("passwd", DEFAULT_CONFIG); - nss_load_all_libraries ("group", DEFAULT_CONFIG); - nss_load_all_libraries ("hosts", "dns [!UNAVAIL=return] files"); - nss_load_all_libraries ("services", NULL); + nss_load_all_libraries (nss_database_passwd); + nss_load_all_libraries (nss_database_group); + nss_load_all_libraries (nss_database_hosts); + nss_load_all_libraries (nss_database_services); /* Make sure NSCD purges its cache if nsswitch.conf changes. */ init_traced_file (&pwd_traced_file.file, _PATH_NSSWITCH_CONF, 0); |