diff options
author | Paul Smith <psmith@gnu.org> | 2022-07-24 14:14:32 -0400 |
---|---|---|
committer | Paul Smith <psmith@gnu.org> | 2022-07-30 18:40:28 -0400 |
commit | 16e14b4114c0c9cc14d15e818bf22588a79e39da (patch) | |
tree | 6d8bfab54e795a38766edcccc1ba3dba040a3503 /src/makeint.h | |
parent | 77881d2281035e2ace1e30800ff3528e1ef1fd98 (diff) | |
download | make-git-16e14b4114c0c9cc14d15e818bf22588a79e39da.tar.gz |
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.
Diffstat (limited to 'src/makeint.h')
-rw-r--r-- | src/makeint.h | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/makeint.h b/src/makeint.h index e355051d..e711a3c8 100644 --- a/src/makeint.h +++ b/src/makeint.h @@ -710,6 +710,9 @@ extern int batch_mode_shell; #define RECIPEPREFIX_DEFAULT '\t' extern char cmd_prefix; +#define JOBSERVER_AUTH_OPT "jobserver-auth" + +extern char *jobserver_auth; extern unsigned int job_slots; extern double max_load_average; |