diff options
author | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2003-06-04 01:57:44 +0000 |
---|---|---|
committer | Pierre Humblet <phumblet@phumblet.no-ip.org> | 2003-06-04 01:57:44 +0000 |
commit | 9f033c223c294b4cdee198f396fb08dd1fe864b3 (patch) | |
tree | ec94dcd1a341842bdd6fc9446bd819606e369a91 /winsup/cygwin/fhandler_disk_file.cc | |
parent | 1e61337ccf9ca5693d38f6f4b0a0637c60974824 (diff) | |
download | cygnal-9f033c223c294b4cdee198f396fb08dd1fe864b3.tar.gz cygnal-9f033c223c294b4cdee198f396fb08dd1fe864b3.tar.bz2 cygnal-9f033c223c294b4cdee198f396fb08dd1fe864b3.zip |
2003-06-03 Pierre Humblet <pierre.humblet@ieee.org>
* fhandler_disk_file.cc (fhandler_disk_file::fstat): Mark the pc
as non-executable if the file cannot be opened for read. Retry query
open only if errno is EACCES. Never change the mode, even if it is 000
when query open() fails.
Diffstat (limited to 'winsup/cygwin/fhandler_disk_file.cc')
-rw-r--r-- | winsup/cygwin/fhandler_disk_file.cc | 35 |
1 files changed, 10 insertions, 25 deletions
diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index c595022f7..c9570b851 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -137,8 +137,6 @@ fhandler_disk_file::fstat (struct __stat64 *buf, path_conv *pc) { int res = -1; int oret; - __uid32_t uid; - __gid32_t gid; int open_flags = O_RDONLY | O_BINARY | O_DIROPEN; bool query_open_already; @@ -159,27 +157,15 @@ fhandler_disk_file::fstat (struct __stat64 *buf, path_conv *pc) if (query_open_already && strncasematch (pc->volname (), "FAT", 3) && !strpbrk (get_win32_name (), "?*|<>")) oret = 0; - else if (!(oret = open (pc, open_flags, 0))) + else if (!(oret = open (pc, open_flags, 0)) + && !query_open_already + && get_errno () == EACCES) { - mode_t ntsec_atts = 0; /* If we couldn't open the file, try a "query open" with no permissions. This will allow us to determine *some* things about the file, at least. */ + pc->set_exec (0); set_query_open (true); - if (!query_open_already && (oret = open (pc, open_flags, 0))) - /* ok */; - else if (allow_ntsec && pc->has_acls () && get_errno () == EACCES - && !get_file_attribute (TRUE, get_win32_name (), &ntsec_atts, &uid, &gid) - && !ntsec_atts && uid == myself->uid && gid == myself->gid) - { - /* Check a special case here. If ntsec is ON it happens - that a process creates a file using mode 000 to disallow - other processes access. In contrast to UNIX, this results - in a failing open call in the same process. Check that - case. */ - set_file_attribute (TRUE, get_win32_name (), 0400); - oret = open (pc, open_flags, 0); - set_file_attribute (TRUE, get_win32_name (), ntsec_atts); - } + oret = open (pc, open_flags, 0); } if (!oret || get_nohandle ()) @@ -217,7 +203,11 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc, to_timestruc_t (&ftCreationTime, &buf->st_ctim); buf->st_dev = pc->volser (); buf->st_size = ((_off64_t)nFileSizeHigh << 32) + nFileSizeLow; - /* Unfortunately the count of 2 confuses `find (1)' command. So + /* The number of links to a directory includes the + number of subdirectories in the directory, since all + those subdirectories point to it. + This is too slow on remote drives, so we do without it. + Setting the count to 2 confuses `find (1)' command. So let's try it with `1' as link count. */ if (pc->isdir () && !pc->isremote () && nNumberOfLinks == 1) buf->st_nlink = num_entries (pc->get_win32 ()); @@ -336,11 +326,6 @@ fhandler_disk_file::fstat_helper (struct __stat64 *buf, path_conv *pc, buf->st_mode &= ~(cygheap->umask); } - /* The number of links to a directory includes the - number of subdirectories in the directory, since all - those subdirectories point to it. - This is too slow on remote drives, so we do without it and - set the number of links to 2. */ done: syscall_printf ("0 = fstat (, %p) st_atime=%x st_size=%D, st_mode=%p, st_ino=%d, sizeof=%d", buf, buf->st_atime, buf->st_size, buf->st_mode, |