244
HIDE_DOTFILES_DOTGITONLY
245
};
246
247
-static int core_restrict_inherited_handles = -1;
247
static enum hide_dotfiles_type hide_dotfiles = HIDE_DOTFILES_DOTGITONLY;
248
static char *unset_environment_variables;
249
267
return 0;
268
}
269
271
- if (!strcmp(var, "core.restrictinheritedhandles")) {
272
- if (value && !strcasecmp(value, "auto"))
273
- core_restrict_inherited_handles = -1;
274
- else
275
- core_restrict_inherited_handles =
276
- git_config_bool(var, value);
277
- return 0;
278
- }
279
-
270
return 0;
271
}
272
1657
const char *dir,
1658
int prepend_cmd, int fhin, int fhout, int fherr)
1659
{
1670
- static int restrict_handle_inheritance = -1;
1660
STARTUPINFOEXW si;
1661
PROCESS_INFORMATION pi;
1662
LPPROC_THREAD_ATTRIBUTE_LIST attr_list = NULL;
1676
/* Make sure to override previous errors, if any */
1677
errno = 0;
1678
1690
- if (restrict_handle_inheritance < 0)
1691
- restrict_handle_inheritance = core_restrict_inherited_handles;
1692
- /*
1693
- * The following code to restrict which handles are inherited seems
1694
- * to work properly only on Windows 7 and later, so let's disable it
1695
- * on Windows Vista and 2008.
1696
- */
1697
- if (restrict_handle_inheritance < 0)
1698
- restrict_handle_inheritance = GetVersion() >> 16 >= 7601;
1699
-
1679
do_unset_environment_variables();
1680
1681
/* Determine whether or not we are associated to a console */
1777
wenvblk = make_environment_block(deltaenv);
1778
1779
memset(&pi, 0, sizeof(pi));
1801
- if (restrict_handle_inheritance && stdhandles_count &&
1780
+ if (stdhandles_count &&
1781
(InitializeProcThreadAttributeList(NULL, 1, 0, &size) ||
1782
GetLastError() == ERROR_INSUFFICIENT_BUFFER) &&
1783
(attr_list = (LPPROC_THREAD_ATTRIBUTE_LIST)
1798
&si.StartupInfo, &pi);
1799
1800
/*
1822
- * On Windows 2008 R2, it seems that specifying certain types of handles
1823
- * (such as FILE_TYPE_CHAR or FILE_TYPE_PIPE) will always produce an
1824
- * error. Rather than playing finicky and fragile games, let's just try
1825
- * to detect this situation and simply try again without restricting any
1826
- * handle inheritance. This is still better than failing to create
1827
- * processes.
1801
+ * On the off-chance that something with the file handle restriction
1802
+ * went wrong, silently fall back to trying without it.
1803
*/
1829
- if (!ret && restrict_handle_inheritance && stdhandles_count) {
1804
+ if (!ret && stdhandles_count) {
1805
DWORD err = GetLastError();
1806
struct strbuf buf = STRBUF_INIT;
1807
1833
- if (err != ERROR_NO_SYSTEM_RESOURCES &&
1834
- /*
1835
- * On Windows 7 and earlier, handles on pipes and character
1836
- * devices are inherited automatically, and cannot be
1837
- * specified in the thread handle list. Rather than trying
1838
- * to catch each and every corner case (and running the
1839
- * chance of *still* forgetting a few), let's just fall
1840
- * back to creating the process without trying to limit the
1841
- * handle inheritance.
1842
- */
1843
- !(err == ERROR_INVALID_PARAMETER &&
1844
- GetVersion() >> 16 < 9200) &&
1845
- !getenv("SUPPRESS_HANDLE_INHERITANCE_WARNING")) {
1846
- DWORD fl = 0;
1847
- int i;
1848
-
1849
- setenv("SUPPRESS_HANDLE_INHERITANCE_WARNING", "1", 1);
1850
-
1851
- for (i = 0; i < stdhandles_count; i++) {
1852
- HANDLE h = stdhandles[i];
1853
- strbuf_addf(&buf, "handle #%d: %p (type %lx, "
1854
- "handle info (%d) %lx\n", i, h,
1855
- GetFileType(h),
1856
- GetHandleInformation(h, &fl),
1857
- fl);
1858
- }
1859
- strbuf_addstr(&buf, "\nThis is a bug; please report it "
1860
- "at\nhttps://github.com/git-for-windows/"
1861
- "git/issues/new\n\n"
1862
- "To suppress this warning, please set "
1863
- "the environment variable\n\n"
1864
- "\tSUPPRESS_HANDLE_INHERITANCE_WARNING=1"
1865
- "\n");
1866
- }
1867
- restrict_handle_inheritance = 0;
1808
flags &= ~EXTENDED_STARTUPINFO_PRESENT;
1809
ret = CreateProcessW(*wcmd ? wcmd : NULL, wargs, NULL, NULL,
1810
TRUE, flags, wenvblk, dir ? wdir : NULL,