forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
nixos/nscd: disable, provide NSS modules globally
NSS modules are now globally provided (by providing a `/run/nss-modules` symlink), similar to how we handle OpenGL drivers. This removes the need for nscd as a proxy for all NSS requests, and avoids DNS requests leaking across network namespaces. While doing this upgrade, existing applications need to be restarted, so they know how to pick up NSS modules from `/run/nss-modules`. If you want to defer application restart to a later time, explicitly enable `nscd` via `services.nscd.enable` until the application restart. We can mix NSS modules from any version of glibc according to https://sourceware.org/legacy-ml/libc-help/2016-12/msg00008.html, so glibc upgrades shouldn't break old userland loading more recent NSS modules (and most likely, NSS modules are already loaded) Fixes: NixOS#55276 Fixes: NixOS#135888 Fixes: NixOS#105353 Cc: NixOS#52411 (comment)
- Loading branch information
Showing
9 changed files
with
120 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
...velopment/libraries/glibc/0001-nss_module.c-try-loading-NSS-modules-from-run-nss-mo.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
From 65a211ee3604733dceba13062f956256a573f27c Mon Sep 17 00:00:00 2001 | ||
From: Florian Klink <[email protected]> | ||
Date: Sun, 19 Sep 2021 13:26:33 +0200 | ||
Subject: [PATCH] nss_module.c: try loading NSS modules from /run/nss-modules | ||
as a fallback | ||
|
||
On NixOS, glibc only looks for NSS modules in ${glibc.out}/lib, and what | ||
LD_LIBRARY_PATH is set to. | ||
|
||
LD_LIBRARY_PATH is very invasive, so we don't want to set that globally. | ||
We previously worked this around by running nscd with LD_LIBRARY_PATH | ||
set, but nscd has some caching issues, and leak of resolution traffic, | ||
so it's cleaner to have glibc look for NSS modules in an additional | ||
path, that's provided by NixOS. | ||
|
||
On non-NixOS distributions, this shouldn't change behaviour, as the path | ||
doesn't exist there. | ||
--- | ||
nss/nss_module.c | 16 ++++++++++++++++ | ||
1 file changed, 16 insertions(+) | ||
|
||
diff --git a/nss/nss_module.c b/nss/nss_module.c | ||
index 6c5f341f..44cfc2a4 100644 | ||
--- a/nss/nss_module.c | ||
+++ b/nss/nss_module.c | ||
@@ -133,6 +133,22 @@ module_load (struct nss_module *module) | ||
return false; | ||
|
||
handle = __libc_dlopen (shlib_name); | ||
+ | ||
+ /* After loading from the default locations, try loading from | ||
+ /run/nss-modules, to allow loading NixOS-provided NSS modules. */ | ||
+ if(handle == NULL) | ||
+ { | ||
+ const char *nix_glibc_nss_path = "/run/nss-modules/"; | ||
+ char shlib_path[1024]; | ||
+ size_t shlib_pathlen = strlen(nix_glibc_nss_path) + strlen(shlib_name); | ||
+ | ||
+ if (shlib_pathlen < sizeof (shlib_path)) | ||
+ { | ||
+ __stpcpy (__stpcpy (&shlib_path[0], nix_glibc_nss_path), shlib_name); | ||
+ handle = __libc_dlopen (shlib_path); | ||
+ } | ||
+ } | ||
+ | ||
free (shlib_name); | ||
} | ||
|
||
-- | ||
2.32.0 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters