* fhandler.h (fhandler_base::fhaccess): Return int for compatibility with
access. * fhandler.cc (fhandler_base::fhaccess): Return int. Use consistent variable name for exit value. Exit at bottom, printing debugging information, like other cygwin functions.
This commit is contained in:
parent
d5f60b41f4
commit
9157f0f3ec
|
@ -1,3 +1,11 @@
|
||||||
|
2004-01-24 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
|
* fhandler.h (fhandler_base::fhaccess): Return int for compatibility
|
||||||
|
with access.
|
||||||
|
* fhandler.cc (fhandler_base::fhaccess): Return int. Use consistent
|
||||||
|
variable name for exit value. Exit at bottom, printing debugging
|
||||||
|
information, like other cygwin functions.
|
||||||
|
|
||||||
2004-01-23 Christopher Faylor <cgf@redhat.com>
|
2004-01-23 Christopher Faylor <cgf@redhat.com>
|
||||||
|
|
||||||
* cygheap.cc (init_cygheap::close_ctty): Protect YA vforkism.
|
* cygheap.cc (init_cygheap::close_ctty): Protect YA vforkism.
|
||||||
|
|
|
@ -331,19 +331,20 @@ fhandler_base::device_access_denied (int flags)
|
||||||
return fhaccess (mode);
|
return fhaccess (mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool
|
int
|
||||||
fhandler_base::fhaccess (int flags)
|
fhandler_base::fhaccess (int flags)
|
||||||
{
|
{
|
||||||
|
int res = -1;
|
||||||
if (error ())
|
if (error ())
|
||||||
{
|
{
|
||||||
set_errno (error ());
|
set_errno (error ());
|
||||||
return -1;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!exists ())
|
if (!exists ())
|
||||||
{
|
{
|
||||||
set_errno (ENOENT);
|
set_errno (ENOENT);
|
||||||
return -1;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!(flags & (R_OK | W_OK | X_OK)))
|
if (!(flags & (R_OK | W_OK | X_OK)))
|
||||||
|
@ -354,16 +355,15 @@ fhandler_base::fhaccess (int flags)
|
||||||
else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK))
|
else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK))
|
||||||
{
|
{
|
||||||
set_errno (EACCES);
|
set_errno (EACCES);
|
||||||
return -1;
|
goto done;
|
||||||
}
|
}
|
||||||
else if (has_acls () && allow_ntsec)
|
else if (has_acls () && allow_ntsec)
|
||||||
return check_file_access (get_win32_name (), flags);
|
return check_file_access (get_win32_name (), flags);
|
||||||
|
|
||||||
struct __stat64 st;
|
struct __stat64 st;
|
||||||
int r = fstat (&st);
|
if (fstat (&st))
|
||||||
if (r)
|
goto done;
|
||||||
return -1;
|
|
||||||
r = -1;
|
|
||||||
if (flags & R_OK)
|
if (flags & R_OK)
|
||||||
{
|
{
|
||||||
if (st.st_uid == myself->uid)
|
if (st.st_uid == myself->uid)
|
||||||
|
@ -379,6 +379,7 @@ fhandler_base::fhaccess (int flags)
|
||||||
else if (!(st.st_mode & S_IROTH))
|
else if (!(st.st_mode & S_IROTH))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & W_OK)
|
if (flags & W_OK)
|
||||||
{
|
{
|
||||||
if (st.st_uid == myself->uid)
|
if (st.st_uid == myself->uid)
|
||||||
|
@ -394,6 +395,7 @@ fhandler_base::fhaccess (int flags)
|
||||||
else if (!(st.st_mode & S_IWOTH))
|
else if (!(st.st_mode & S_IWOTH))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (flags & X_OK)
|
if (flags & X_OK)
|
||||||
{
|
{
|
||||||
if (st.st_uid == myself->uid)
|
if (st.st_uid == myself->uid)
|
||||||
|
@ -409,11 +411,12 @@ fhandler_base::fhaccess (int flags)
|
||||||
else if (!(st.st_mode & S_IXOTH))
|
else if (!(st.st_mode & S_IXOTH))
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
r = 0;
|
res = 0;
|
||||||
done:
|
done:
|
||||||
if (r)
|
if (res)
|
||||||
set_errno (EACCES);
|
set_errno (EACCES);
|
||||||
return r;
|
debug_printf ("returning %d", res);
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Open system call handler function. */
|
/* Open system call handler function. */
|
||||||
|
|
|
@ -364,7 +364,7 @@ class fhandler_base
|
||||||
bool is_auto_device () {return isdevice () && !dev ().isfs ();}
|
bool is_auto_device () {return isdevice () && !dev ().isfs ();}
|
||||||
bool is_fs_special () {return pc.is_fs_special ();}
|
bool is_fs_special () {return pc.is_fs_special ();}
|
||||||
bool device_access_denied (int) __attribute__ ((regparm (2)));
|
bool device_access_denied (int) __attribute__ ((regparm (2)));
|
||||||
bool fhaccess (int flags) __attribute__ ((regparm (2)));
|
int fhaccess (int flags) __attribute__ ((regparm (2)));
|
||||||
};
|
};
|
||||||
|
|
||||||
class fhandler_socket: public fhandler_base
|
class fhandler_socket: public fhandler_base
|
||||||
|
|
Loading…
Reference in New Issue