* devices.in: Throughout use slashes instead of backslashes in the

native path of devices not backed by native NT devices.
	* devices.cc: Regenerate.
	* globals.cc (ro_u_pmem): Use correct case.
	(ro_u_globalroot): New R/O unicode string.
	* path.cc (path_conv::check): Fix incorrect handling of /proc/sys
	block devices if they are just visited due to a component check.
	(symlink_info::posixify): Fix typo in comment.
	(cygwin_conv_path): Use ro_u_globalroot instead of string constant.
	(fast_cwd_version): New shared variable to store FAST_CWD version
	used on the system.
	(find_fast_cwd_pointer): Rename from find_fast_cwd_pointers.  Don't
	set global fast_cwd_ptr pointer here.  Return pointer value instead.
	(find_fast_cwd): New function to set fast_cwd_ptr and fast_cwd_version.
	(cwdstuff::override_win32_cwd): Call find_fast_cwd from here.
	Check for fast_cwd_version to differ between old and new FAST_CWD
	structure.  Check old_cwd for NULL to avoid SEGV.  Don't set CWD if
	we have neitehr a valid fast_cwd_ptr, nor a valid CWD handle in the
	process parameter block.
	(cwdstuff::set): Create Win32 path taking /proc/sys paths into account.
	* spawn.cc (spawn_guts): Recode creating runpath.  Also take /proc/sys
	paths into account.  Drop special CWD handling when starting non-Cygwin
	processes.
This commit is contained in:
Corinna Vinschen
2011-02-15 15:25:59 +00:00
parent fe222f2210
commit a413f8a20e
6 changed files with 299 additions and 196 deletions

View File

@ -490,26 +490,43 @@ spawn_guts (const char *prog_arg, const char *const *argv,
system_printf ("duplicate to pid_handle failed, %E");
}
runpath = null_app_name ? NULL : real_path.get_wide_win32_path (runpath);
if (runpath)
{ /* If the executable path length is < MAX_PATH, make sure the long path
win32 prefix is removed from the path to make subsequent native Win32
child processes happy which are not long path aware. */
USHORT len = real_path.get_nt_native_path ()->Length;
if (len < (MAX_PATH + 4) * sizeof (WCHAR)
|| (runpath[5] != L':' /* UNC path */
&& len < (MAX_PATH + 6) * sizeof (WCHAR)))
if (null_app_name)
runpath = NULL;
else
{
USHORT len = real_path.get_nt_native_path ()->Length / sizeof (WCHAR);
if (RtlEqualUnicodePathPrefix (real_path.get_nt_native_path (),
&ro_u_natp, FALSE))
{
PWCHAR r = runpath + 4;
if (r[1] != L':') /* UNC path */
*(r += 2) = L'\\';
if (!RtlIsDosDeviceName_U (r))
runpath = r;
else if (*r == L'\\')
*r = L'C';
runpath = real_path.get_wide_win32_path (runpath);
/* If the executable path length is < MAX_PATH, make sure the long
path win32 prefix is removed from the path to make subsequent
not long path aware native Win32 child processes happy. */
if (len < MAX_PATH + 4)
{
if (runpath[5] == ':')
runpath += 4;
else if (len < MAX_PATH + 6)
*(runpath += 6) = L'\\';
}
}
else if (len < NT_MAX_PATH - ro_u_globalroot.Length / sizeof (WCHAR))
{
UNICODE_STRING rpath;
RtlInitEmptyUnicodeString (&rpath, runpath,
(NT_MAX_PATH - 1) * sizeof (WCHAR));
RtlCopyUnicodeString (&rpath, &ro_u_globalroot);
RtlAppendUnicodeStringToString (&rpath,
real_path.get_nt_native_path ());
}
else
{
set_errno (ENAMETOOLONG);
res = -1;
goto out;
}
}
syscall_printf ("null_app_name %d (%W, %.9500W)", null_app_name,
runpath, wone_line);
@ -551,14 +568,8 @@ spawn_guts (const char *prog_arg, const char *const *argv,
loop:
cygheap->user.deimpersonate ();
PWCHAR cwd;
cwd = NULL;
if (!real_path.iscygexec ())
{
myself->process_state |= PID_NOTCYGWIN;
cygheap->cwd.cwd_lock.acquire ();
cwd = cygheap->cwd.win32.Buffer;
}
myself->process_state |= PID_NOTCYGWIN;
if (!cygheap->user.issetuid ()
|| (cygheap->user.saved_uid == cygheap->user.real_uid
@ -573,7 +584,7 @@ loop:
TRUE, /* inherit handles from parent */
c_flags,
envblock, /* environment */
cwd,
NULL,
&si,
&pi);
}
@ -636,7 +647,7 @@ loop:
TRUE, /* inherit handles from parent */
c_flags,
envblock, /* environment */
cwd,
NULL,
&si,
&pi);
if (hwst)
@ -651,9 +662,6 @@ loop:
}
}
if (!real_path.iscygexec())
cygheap->cwd.cwd_lock.release ();
/* Restore impersonation. In case of _P_OVERLAY this isn't
allowed since it would overwrite child data. */
if (mode != _P_OVERLAY || !rc)