Merge branch 'dont-restrict-handles-on-vista'

It seems that our feature to restrict file handle inheritance to let
spawned processes inherit only the standard handles is a bit broken on
Vista.

This closes https://github.com/git-for-windows/git/issues/1742

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
Johannes Schindelin
2019-06-03 22:56:29 +02:00
2 changed files with 27 additions and 1 deletions

View File

@@ -570,6 +570,12 @@ core.unsetenvvars::
Defaults to `PERL5LIB` to account for the fact that Git for
Windows insists on using its own Perl interpreter.
core.restrictinheritedhandles::
Windows-only: override whether spawned processes inherit only standard
file handles (`stdin`, `stdout` and `stderr`) or all handles. Can be
`auto`, `true` or `false`. Defaults to `auto`, which means `true` on
Windows 7 and later, and `false` on older Windows versions.
core.createObject::
You can set this to 'link', in which case a hardlink followed by
a delete of the source are used to make sure that object creation

View File

@@ -259,6 +259,7 @@ static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
static char *unset_environment_variables;
int core_fscache;
int core_long_paths;
int core_restrict_inherited_handles = -1;
int mingw_core_config(const char *var, const char *value, void *cb)
{
@@ -286,6 +287,15 @@ int mingw_core_config(const char *var, const char *value, void *cb)
return 0;
}
if (!strcmp(var, "core.restrictinheritedhandles")) {
if (value && !strcasecmp(value, "auto"))
core_restrict_inherited_handles = -1;
else
core_restrict_inherited_handles =
git_config_bool(var, value);
return 0;
}
return 0;
}
@@ -1674,7 +1684,7 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
const char *dir, const char *prepend_cmd,
int fhin, int fhout, int fherr)
{
static int restrict_handle_inheritance = 1;
static int restrict_handle_inheritance = -1;
STARTUPINFOEXW si;
PROCESS_INFORMATION pi;
LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL;
@@ -1690,6 +1700,16 @@ static pid_t mingw_spawnve_fd(const char *cmd, const char **argv, char **deltaen
is_msys2_sh(*argv) ? quote_arg_msys2 : quote_arg_msvc;
const char *strace_env;
if (restrict_handle_inheritance < 0)
restrict_handle_inheritance = core_restrict_inherited_handles;
/*
* The following code to restrict which handles are inherited seems
* to work properly only on Windows 7 and later, so let's disable it
* on Windows Vista and 2008.
*/
if (restrict_handle_inheritance < 0)
restrict_handle_inheritance = GetVersion() >> 16 >= 7601;
do_unset_environment_variables();
/* Determine whether or not we are associated to a console */