mirror of
https://git.savannah.gnu.org/git/make.git
synced 2025-01-27 01:27:58 +00:00
[SV 57674] Use the system default PATH if $PATH is not set
When using execvp() if $PATH is not present in the environment it will automatically search the system default PATH string. Emulate this by passing the system default PATH to find_in_given_path() if we don't find PATH in the environment. * src/job.c (child_execute_job): Use confstr(_CS_PATH) if PATH is not found.
This commit is contained in:
parent
f79bde1a6d
commit
0c326a66c9
2 changed files with 19 additions and 0 deletions
12
src/job.c
12
src/job.c
|
@ -2381,6 +2381,18 @@ child_execute_job (struct childbase *child, int good_stdin, char **argv)
|
|||
break;
|
||||
}
|
||||
|
||||
/* execvp() will use a default PATH if none is set; emulate that. */
|
||||
if (p == NULL)
|
||||
{
|
||||
size_t l = confstr (_CS_PATH, NULL, 0);
|
||||
if (l)
|
||||
{
|
||||
char *dp = alloca (l);
|
||||
confstr (_CS_PATH, dp, l);
|
||||
p = dp;
|
||||
}
|
||||
}
|
||||
|
||||
cmd = (char *)find_in_given_path (argv[0], p, 0);
|
||||
}
|
||||
|
||||
|
|
|
@ -118,4 +118,11 @@ all: ; $sname
|
|||
|
||||
unlink($sname);
|
||||
|
||||
# SV 57674: ensure we use a system default PATH if one is not set
|
||||
delete $ENV{PATH};
|
||||
run_make_test(q!
|
||||
a: ; @echo hi
|
||||
!,
|
||||
'', "hi\n");
|
||||
|
||||
1;
|
||||
|
|
Loading…
Reference in a new issue