summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <cgf@redhat.com>2004-01-25 23:39:55 +0000
committerChristopher Faylor <cgf@redhat.com>2004-01-25 23:39:55 +0000
commit5a6652bc830305fe04587bf98cf2e4f110a10a1d (patch)
tree94e254c9b651d7d874ec4a8a2b34740152d9a87e
parent08f43572287ad5016ebbbaf46a69b51b61b83bdd (diff)
downloadgdb-5a6652bc830305fe04587bf98cf2e4f110a10a1d.tar.gz
* fhandler.cc (fhandler_base::fhaccess): Avoid always setting errno to EACCESS
when return value is < 0. Rely on errno being set properly.
-rw-r--r--winsup/cygwin/ChangeLog5
-rw-r--r--winsup/cygwin/fhandler.cc31
2 files changed, 22 insertions, 14 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 9289a4af6a0..26f3f92b414 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,5 +1,10 @@
2004-01-25 Christopher Faylor <cgf@redhat.com>
+ * fhandler.cc (fhandler_base::fhaccess): Avoid always setting errno to
+ EACCESS when return value is < 0. Rely on errno being set properly.
+
+2004-01-25 Christopher Faylor <cgf@redhat.com>
+
* sigproc.cc (proc_subproc): Don't protect *child's* handle.
2004-01-24 Christopher Faylor <cgf@redhat.com>
diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc
index 38b95d42b88..2b86d3c5158 100644
--- a/winsup/cygwin/fhandler.cc
+++ b/winsup/cygwin/fhandler.cc
@@ -353,12 +353,12 @@ fhandler_base::fhaccess (int flags)
if (is_fs_special ())
/* short circuit */;
else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK))
+ goto eaccess_done;
+ else if (has_acls () && allow_ntsec)
{
- set_errno (EACCES);
+ res = check_file_access (get_win32_name (), flags);
goto done;
}
- else if (has_acls () && allow_ntsec)
- return check_file_access (get_win32_name (), flags);
struct __stat64 st;
if (fstat (&st))
@@ -369,15 +369,15 @@ fhandler_base::fhaccess (int flags)
if (st.st_uid == myself->uid)
{
if (!(st.st_mode & S_IRUSR))
- goto done;
+ goto eaccess_done;
}
else if (st.st_gid == myself->gid)
{
if (!(st.st_mode & S_IRGRP))
- goto done;
+ goto eaccess_done;
}
else if (!(st.st_mode & S_IROTH))
- goto done;
+ goto eaccess_done;
}
if (flags & W_OK)
@@ -385,15 +385,15 @@ fhandler_base::fhaccess (int flags)
if (st.st_uid == myself->uid)
{
if (!(st.st_mode & S_IWUSR))
- goto done;
+ goto eaccess_done;
}
else if (st.st_gid == myself->gid)
{
if (!(st.st_mode & S_IWGRP))
- goto done;
+ goto eaccess_done;
}
else if (!(st.st_mode & S_IWOTH))
- goto done;
+ goto eaccess_done;
}
if (flags & X_OK)
@@ -401,20 +401,23 @@ fhandler_base::fhaccess (int flags)
if (st.st_uid == myself->uid)
{
if (!(st.st_mode & S_IXUSR))
- goto done;
+ goto eaccess_done;
}
else if (st.st_gid == myself->gid)
{
if (!(st.st_mode & S_IXGRP))
- goto done;
+ goto eaccess_done;
}
else if (!(st.st_mode & S_IXOTH))
- goto done;
+ goto eaccess_done;
}
+
res = 0;
+ goto done;
+
+eaccess_done:
+ set_errno (EACCES);
done:
- if (res)
- set_errno (EACCES);
debug_printf ("returning %d", res);
return res;
}