diff options
Diffstat (limited to 'winsup/cygwin/path.cc')
-rw-r--r-- | winsup/cygwin/path.cc | 88 |
1 files changed, 55 insertions, 33 deletions
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc index d381c4c61..d3d560fc1 100644 --- a/winsup/cygwin/path.cc +++ b/winsup/cygwin/path.cc @@ -793,7 +793,17 @@ out: if (!allow_smbntsec && fs.is_remote_drive) set_has_acls (false); else - set_has_acls (fs.flags & FS_PERSISTENT_ACLS); + { + set_has_acls (fs.flags & FS_PERSISTENT_ACLS); + if (exec_state () != dont_know_if_executable) + /* ok */; + else if (isdir ()) + set_exec (1); + else if (issymlink () || issocket () + || allow_ntsec && wincap.has_security ()) + set_exec (0); + + } /* Known file systems with buggy open calls. Further explanation in fhandler.cc (fhandler_disk_file::open). */ set_has_buggy_open (strcmp (fs.name, "SUNWNFS") == 0); @@ -1379,6 +1389,41 @@ set_flags (unsigned *flags, unsigned val) } } +void +mount_item::fnmunge (char *dst, const char *src) +{ + strcpy (dst, src); + backslashify (dst, dst, 0); +} + +void +mount_item::build_win32 (char *dst, const char *src, unsigned *outflags, unsigned chroot_pathlen) +{ + int n; + const char *real_native_path; + int real_posix_pathlen; + set_flags (outflags, (unsigned) flags); + if (!cygheap->root.exists () || posix_pathlen != 1 || posix_path[0] != '/') + { + n = native_pathlen; + real_native_path = native_path; + real_posix_pathlen = chroot_pathlen ?: posix_pathlen; + } + else + { + n = cygheap->root.native_length (); + real_native_path = cygheap->root.native_path (); + real_posix_pathlen = posix_pathlen; + } + memcpy (dst, real_native_path, n + 1); + const char *p = src + real_posix_pathlen; + if (*p == '/') + /* nothing */; + else if ((isdrive (dst) && !dst[2]) || *p) + dst[n++] = '\\'; + fnmunge (dst + n, p); +} + /* conv_to_win32_path: Ensure src_path is a pure Win32 path and store the result in win32_path. @@ -1405,7 +1450,6 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, int src_path_len = strlen (src_path); MALLOC_CHECK; unsigned dummy_flags; - int chroot_ok = !cygheap->root.exists (); devn = FH_BAD; unit = 0; @@ -1511,8 +1555,8 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, return ENOENT; } - int chrooted_path_len; - chrooted_path_len = 0; + int chroot_pathlen; + chroot_pathlen = 0; /* Check the mount table for prefix matches. */ for (i = 0; i < nmounts; i++) { @@ -1529,11 +1573,11 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, else if (cygheap->root.posix_ok (mi->posix_path)) { path = cygheap->root.unchroot (mi->posix_path); - chrooted_path_len = len = strlen (path); + chroot_pathlen = len = strlen (path); } else { - chrooted_path_len = 0; + chroot_pathlen = 0; continue; } @@ -1541,40 +1585,18 @@ mount_info::conv_to_win32_path (const char *src_path, char *dst, break; } + bool chroot_ok; + chroot_ok = false; // sigh. stop gcc warning if (i >= nmounts) { backslashify (pathbuf, dst, 0); /* just convert */ set_flags (flags, PATH_BINARY); + chroot_ok = !cygheap->root.exists (); } else { - int n; - const char *native_path; - int posix_pathlen; - if (chroot_ok || chrooted_path_len || mi->posix_pathlen != 1 - || mi->posix_path[0] != '/') - { - n = mi->native_pathlen; - native_path = mi->native_path; - posix_pathlen = chrooted_path_len ?: mi->posix_pathlen; - chroot_ok = 1; - } - else - { - n = cygheap->root.native_length (); - native_path = cygheap->root.native_path (); - posix_pathlen = mi->posix_pathlen; - chroot_ok = 1; - } - memcpy (dst, native_path, n + 1); - const char *p = pathbuf + posix_pathlen; - if (*p == '/') - /* nothing */; - else if ((isdrive (dst) && !dst[2]) || *p) - dst[n++] = '\\'; - strcpy (dst + n, p); - backslashify (dst, dst, 0); - set_flags (flags, (unsigned) mi->flags); + mi->build_win32 (dst, pathbuf, flags, chroot_pathlen); + chroot_ok = true; } if (!isvirtual_dev (devn)) |