From 456fb08bb9072aea79b98c19f455df80ed1ef9e8 Mon Sep 17 00:00:00 2001 From: Mattias Andrée Date: Sun, 20 Dec 2015 19:26:36 +0100 Subject: compile-time configurable default value for path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Mattias Andrée --- src/unistd/searchpath3.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'src/unistd') diff --git a/src/unistd/searchpath3.c b/src/unistd/searchpath3.c index 5fabc62..4ab49fe 100644 --- a/src/unistd/searchpath3.c +++ b/src/unistd/searchpath3.c @@ -24,6 +24,15 @@ +/** + * The default value for the PATH environment variable. + */ +#ifndef DEFAULT_PATH +# define DEFAULT_PATH "/usr/local/bin:/bin:/usr/bin" +#endif + + + /** * Search the environment variable $PATH for an executable * file whose name is the specified name. Slashes are ignored @@ -95,10 +104,10 @@ char* searchpath3(const char* name, const char* fallback, const char* first) } if (path == NULL) { - path = malloc(strlen(first) * sizeof(char) + sizeof(":/usr/local/bin:/bin:/usr/bin")); + path = malloc(strlen(first) * sizeof(char) + sizeof(":" DEFAULT_PATH)); if (path == NULL) goto fail; - stpcpy(stpcpy(path, first), ":/usr/local/bin:/bin:/usr/bin"); + stpcpy(stpcpy(path, first), ":" DEFAULT_PATH); } } else -- cgit v1.2.3-70-g09d2