aboutsummaryrefslogtreecommitdiffstats
path: root/unmaintained/nldev/0002-Preserve-the-PATH-environment-variable.patch
blob: d6c4ffec67c927ceb6641a1d731b2280da04a2f3 (plain)
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 980c9181b9bf44be6007462ef54568759aabbc5a Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?S=C3=B6ren=20Tempel?= <soeren+git@soeren-tempel.net>
Date: Wed, 10 Feb 2016 23:26:23 +0100
Subject: [PATCH 2/4] Preserve the PATH environment variable

No idea why this wasn't done before...
---
 nldev.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/nldev.c b/nldev.c
index 9153fd2..deabf10 100644
--- a/nldev.c
+++ b/nldev.c
@@ -193,7 +193,7 @@ main(int argc, char *argv[])
 	struct msghdr hdr;
 	struct iovec iov;
 	char buf[4097], *subsystem, *runpath, *key, *value,
-	     cbuf[CMSG_SPACE(sizeof(struct ucred))];
+	     *origpath, cbuf[CMSG_SPACE(sizeof(struct ucred))];
 	struct cmsghdr *chdr;
 	struct ucred *cred;
 	int i, len, slen, showudev, showkernel;
@@ -203,6 +203,10 @@ main(int argc, char *argv[])
 	subsystem = NULL;
 	runpath = "/bin/mdev";
 
+	origpath = getenv("PATH");
+	if (!origpath || strlen(origpath) <= 0)
+		origpath = "/sbin:/bin";
+
 	ARGBEGIN {
 	case 'b':
 		dofork = 1;
@@ -242,7 +246,7 @@ main(int argc, char *argv[])
 	buf[sizeof(buf)-1] = '\0';
 	while (poll(&fds, 1, -1) > -1) {
 		clearenv();
-		setenv("PATH", "/sbin:/bin", 1);
+		setenv("PATH", origpath, 1);
 
 		iov.iov_base = &buf;
 		iov.iov_len = sizeof(buf);
-- 
2.7.2