]> git.ipfire.org Git - thirdparty/make.git/commit
Disable the jobserver in non-recursive children
authorPaul Smith <psmith@gnu.org>
Sun, 24 Jul 2022 18:14:32 +0000 (14:14 -0400)
committerPaul Smith <psmith@gnu.org>
Sat, 30 Jul 2022 22:40:28 +0000 (18:40 -0400)
commit16e14b4114c0c9cc14d15e818bf22588a79e39da
tree6d8bfab54e795a38766edcccc1ba3dba040a3503
parent77881d2281035e2ace1e30800ff3528e1ef1fd98
Disable the jobserver in non-recursive children

Savannah issues such as SV 57242 and SV 62397 show how passing
references to closed file descriptors via the --jobserver-auth option
in MAKEFLAGS can lead to problematic outcomes.

When computing the child environment for a non-recursive shell, add
an extra option to MAKEFLAGS to disable the file descriptors for the
jobserver.

Unfortunately this doesn't modify the value of the make variable
MAKEFLAGS, it only modifies the value of the sub-shell environment
variable MAKEFLAGS.  This can lead to confusion if the user is not
considering the distinction.

* src/makeint.h: Publish the jobserver-auth value.  Add a global
definition of the name of the command line option.
* src/os.h (jobserver_get_invalid_auth): New function to return a
string invalidating the jobserver-auth option.
* src/w32/w32os.c (jobserver_get_invaid_auth): Implement it.  On
Windows we use a semaphore so there's no need to invalidate.
* src/posixos.c (jobserver_parse_auth): If we parse the invalid
auth string, don't set up the jobserver.
(jobserver_get_invalid_auth): Return an invalid option.
* src/variable.h (target_environment): Specify if the target
environment is for a recursive shell or non-recursive shell.
* src/variable.c (target_environment): Move checking for MAKELEVEL
into the loop rather than doing it at the end.
Along with this, check for MAKEFLAGS and MFLAGS, and update them
based on whether we're invoking a recursive or non-recursive child,
and also on whether it's necessary to invalidate the jobserver.
* src/function.c (func_shell_base): Shell functions can never be
recursive to pass 0 to target_environment().
* src/job.c (start_job_command): Specify whether the child is
recursive when calling target_environment().
* src/main.c: Export jobserver_auth.  sync_mutex doesn't need to
be exported.  Use the global definition for the option name.
* tests/scripts/variables/MAKEFLAGS: Add tests for $MAKEFLAGS.
NEWS
src/function.c
src/job.c
src/main.c
src/makeint.h
src/os.h
src/posixos.c
src/variable.c
src/variable.h
src/w32/w32os.c
tests/scripts/variables/MAKEFLAGS