mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-10 08:16:15 +02:00
preloadNSS: fixup nss_dns load
Before this commit, the dns lookup in preloadNSS would still go through nscd. This did not have the effect of loading the nss_dns.so as expected (nss_dns.so being out of reach from within the sandbox). Should LOCALDOMAIN environment variable be defined, nss will completely avoid nscd and will do its dns resolution on its own. By temporarly setting LOCALDOMAIN variable before calling in NSS, we can force NSS to load the shared libraries as expected. Fixes #5089 Signed-off-by: Arthur Gautier <baloo@superbaloo.net>
This commit is contained in:
parent
af94b54db3
commit
0b42a0f781
1 changed files with 11 additions and 1 deletions
|
@ -354,9 +354,19 @@ static void preloadNSS() {
|
|||
std::call_once(dns_resolve_flag, []() {
|
||||
struct addrinfo *res = NULL;
|
||||
|
||||
if (getaddrinfo("this.pre-initializes.the.dns.resolvers.invalid.", "http", NULL, &res) != 0) {
|
||||
/* nss will only force the "local" (not through nscd) dns resolution if its on the LOCALDOMAIN.
|
||||
We need the resolution to be done locally, as nscd socket will not be accessible in the
|
||||
sandbox. */
|
||||
char * previous_env = getenv("LOCALDOMAIN");
|
||||
setenv("LOCALDOMAIN", "invalid", 1);
|
||||
if (getaddrinfo("this.pre-initializes.the.dns.resolvers.invalid.", "http", NULL, &res) == 0) {
|
||||
if (res) freeaddrinfo(res);
|
||||
}
|
||||
if (previous_env) {
|
||||
setenv("LOCALDOMAIN", previous_env, 1);
|
||||
} else {
|
||||
unsetenv("LOCALDOMAIN");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue