From: Robert Byrnes Date: Thu, 5 Nov 2015 13:38:13 +0000 (+0100) Subject: Inherit PATH from the crond environment if -P option is used. X-Git-Tag: cronie-1.5.1~14 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=56c0fa2f7785c103cb5b431a5892b83978514755;p=cronie Inherit PATH from the crond environment if -P option is used. --- diff --git a/src/entry.c b/src/entry.c index 3638207..ce37756 100644 --- a/src/entry.c +++ b/src/entry.c @@ -343,8 +343,18 @@ entry *load_entry(FILE * file, void (*error_func) (), struct passwd *pw, e->envp = tenvp; #ifndef LOGIN_CAP /* If login.conf is in used we will get the default PATH later. */ - if (ChangePath && !env_get("PATH", e->envp)) { - if (glue_strings(envstr, sizeof envstr, "PATH", _PATH_DEFPATH, '=')) { + if (!env_get("PATH", e->envp)) { + char *defpath; + + if (ChangePath) + defpath = _PATH_DEFPATH; + else { + defpath = getenv("PATH"); + if (defpath == NULL) + defpath = _PATH_DEFPATH; + } + + if (glue_strings(envstr, sizeof envstr, "PATH", defpath, '=')) { if ((tenvp = env_set(e->envp, envstr)) == NULL) { ecode = e_memory; goto eof;