Welcome to mirror list, hosted at ThFree Co, Russian Federation.

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2011-02-15 18:25:59 +0300
committerCorinna Vinschen <corinna@vinschen.de>2011-02-15 18:25:59 +0300
commita413f8a20eb6831d0162aab4b94c4d25f203e9be (patch)
tree942d858840367be3238e96a1c1a85a43bd4d6f64 /winsup/cygwin/spawn.cc
parentfe222f22104df2192684f04fab0847831d114705 (diff)
* 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.
Diffstat (limited to 'winsup/cygwin/spawn.cc')
-rw-r--r--winsup/cygwin/spawn.cc66
1 files changed, 37 insertions, 29 deletions
diff --git a/winsup/cygwin/spawn.cc b/winsup/cygwin/spawn.cc
index 1b268e4a7..68e5572a3 100644
--- a/winsup/cygwin/spawn.cc
+++ b/winsup/cygwin/spawn.cc
@@ -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)