aboutsummaryrefslogtreecommitdiff
path: root/winsup/cygwin
diff options
context:
space:
mode:
authorCorinna Vinschen <corinna@vinschen.de>2001-02-06 14:07:02 +0000
committerCorinna Vinschen <corinna@vinschen.de>2001-02-06 14:07:02 +0000
commitd7ed877ba3bf05bc13b7f90000d1d6e7a299c85d (patch)
tree8f0047d380fd61d4f0955e84afc189f468443300 /winsup/cygwin
parent31f5feea33601dc33b66c55d7163e7cf29b381a3 (diff)
downloadnewlib-d7ed877ba3bf05bc13b7f90000d1d6e7a299c85d.zip
newlib-d7ed877ba3bf05bc13b7f90000d1d6e7a299c85d.tar.gz
newlib-d7ed877ba3bf05bc13b7f90000d1d6e7a299c85d.tar.bz2
* syscalls.cc (stat_worker): Add a check for the special case when
a process creates a file using mode 000 using ntsec.
Diffstat (limited to 'winsup/cygwin')
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/syscalls.cc60
2 files changed, 47 insertions, 18 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index b0db4a5..aa137bc 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,8 @@
+Tue Feb 6 15:04:00 2001 Corinna Vinschen <corinna@vinschen.de>
+
+ * syscalls.cc (stat_worker): Add a check for the special case when
+ a process creates a file using mode 000 using ntsec.
+
Mon Feb 5 17:00:00 2001 Corinna Vinschen <corinna@vinschen.de>
* fhandler.cc (fhandler_base::open): Always add GENERIC_READ access
diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc
index c7d70fd..5fa6714 100644
--- a/winsup/cygwin/syscalls.cc
+++ b/winsup/cygwin/syscalls.cc
@@ -1027,6 +1027,11 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
int res = -1;
int oret = 1;
int atts;
+
+ int attribute = 0;
+ uid_t uid;
+ gid_t gid;
+
char root[MAX_PATH];
UINT dtype;
fhandler_disk_file fh (NULL);
@@ -1060,25 +1065,44 @@ stat_worker (const char *caller, const char *name, struct stat *buf,
if ((atts == -1 || !(atts & FILE_ATTRIBUTE_DIRECTORY) ||
(os_being_run == winNT
&& dtype != DRIVE_NO_ROOT_DIR
- && dtype != DRIVE_UNKNOWN))
- && (oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
- (nofollow ? O_NOSYMLINK : 0), 0)))
- {
- res = fh.fstat (buf);
- fh.close ();
- /* 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. */
- /* Unfortunately the count of 2 confuses `find(1)' command. So
- let's try it with `1' as link count. */
- if (atts != -1 && (atts & FILE_ATTRIBUTE_DIRECTORY))
- buf->st_nlink =
- (dtype == DRIVE_REMOTE ? 1 : num_entries (real_path.get_win32 ()));
+ && dtype != DRIVE_UNKNOWN)))
+ {
+ oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
+ (nofollow ? O_NOSYMLINK : 0), 0);
+ /* 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. */
+ if (!oret && allow_ntsec && get_errno () == EACCES
+ && !get_file_attribute (TRUE, real_path, &attribute, &uid, &gid)
+ && !attribute && uid == myself->uid && gid == myself->gid)
+ {
+ set_file_attribute (TRUE, real_path, 0400);
+ oret = fh.open (real_path, O_RDONLY | O_BINARY | O_DIROPEN |
+ (nofollow ? O_NOSYMLINK : 0), 0);
+ set_file_attribute (TRUE, real_path.get_win32 (), 0);
+ }
+ if (oret)
+ {
+ res = fh.fstat (buf);
+ fh.close ();
+ /* 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. */
+ /* Unfortunately the count of 2 confuses `find(1)' command. So
+ let's try it with `1' as link count. */
+ if (atts != -1 && (atts & FILE_ATTRIBUTE_DIRECTORY))
+ buf->st_nlink = (dtype == DRIVE_REMOTE
+ ? 1
+ : num_entries (real_path.get_win32 ()));
+ goto done;
+ }
}
- else if (atts != -1 || (!oret && get_errno () != ENOENT
- && get_errno () != ENOSHARE))
+ if (atts != -1 || (!oret && get_errno () != ENOENT
+ && get_errno () != ENOSHARE))
{
/* Unfortunately, the above open may fail if the file exists, though.
So we have to care for this case here, too. */