-
Notifications
You must be signed in to change notification settings - Fork 4
/
0007-scratchbox2-Allow-specifying-of-nsswitch.conf-path.patch
46 lines (40 loc) · 1.63 KB
/
0007-scratchbox2-Allow-specifying-of-nsswitch.conf-path.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Bj=C3=B6rn=20Bidar?= <[email protected]>
Date: Tue, 31 Aug 2021 01:51:17 +0300
Subject: [PATCH] (scratchbox2) Allow specifying of nsswitch.conf path
This patch makes location of the /etc/nsswitch.conf file
to be run-time configurable via an environment variable.
This is needed for correct operation with Scratchbox 2.
Without this, the sb2-virtualized environment will
always read /etc/nsswitch.conf from the host.
---
nss/nsswitch.c | 12 +++++++++++-
1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/nss/nsswitch.c b/nss/nsswitch.c
index c4a9ffb5750436ad55262aad9fbd7fd1401a8bc4..eac5970d519879888776d4f031c7d0f4fcd1f475 100644
--- a/nss/nsswitch.c
+++ b/nss/nsswitch.c
@@ -50,6 +50,8 @@
# define DEFAULT_DEFCONFIG "files"
#endif
+#include <unistd.h> /* __libc_enable_secure */
+
/* Prototypes for the local functions. */
static name_database *nss_parse_file (const char *fname);
static name_database_entry *nss_getline (char *line);
@@ -131,8 +133,16 @@ __nss_database_lookup2 (const char *database, const char *alternate_name,
/* Are we initialized yet? */
if (service_table == NULL)
+ {
+ const char *ext_nss_config_file = NULL;
+ if (__libc_enable_secure == 0)
+ {
+ ext_nss_config_file = getenv ("NSSWITCH_CONF_PATH");
+ }
/* Read config file. */
- service_table = nss_parse_file (_PATH_NSSWITCH_CONF);
+ service_table = nss_parse_file (ext_nss_config_file ?
+ ext_nss_config_file : _PATH_NSSWITCH_CONF);
+ }
/* Test whether configuration data is available. */
if (service_table != NULL)