From 980c9181b9bf44be6007462ef54568759aabbc5a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=B6ren=20Tempel?= 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