* cygheap.cc (init_cygheap::close_ctty): Protect YA vforkism.
* fhandler.h (fhandler_base::has_acls): Make pass through for path_conv method. (fhandler_base::isremote): Ditto. (fhandler_base::is_fs_special): Ditto. (fhandler_base::has_attribute): Ditto. Define new function. (fhandler_base::fhaccess): Declare new function based on access_worker. (fhandler_base::set_has_acls): Eliminate obsolete function. (fhandler_base::set_isremote): Ditto. * fhandler.cc (fhandler_base::fhaccess): Move from syscalls.cc and into fhandler_base class. Use fhandler methods to access data rather than path_conv stuff. (fhandler_base::device_access_denied): Use fhaccess method. * fhandler_disk_file.cc (fhandler_disk_file::opendir): Ditto. (fhandler_base::open_fs): Remove calls to obsolete functions. * fhandler_virtual.cc (fhandler_virtual::open): Ditto. * winsup.h (access_worker): Remove obsolete access_worker declaration. *syscalls.cc (access_worker): Move function to fhandler.cc. (access): Use fhaccess method. * pinfo.cc (_pinfo::set_ctty): Clarify debugging output. * sigproc.cc (sig_dispatch_pending): Ditto. * syscalls.cc (setsid): Perform minor rearrangement.
This commit is contained in:
@@ -328,7 +328,92 @@ fhandler_base::device_access_denied (int flags)
|
||||
if (!mode)
|
||||
mode |= R_OK;
|
||||
|
||||
return access_worker (pc, mode, this);
|
||||
return fhaccess (mode);
|
||||
}
|
||||
|
||||
bool
|
||||
fhandler_base::fhaccess (int flags)
|
||||
{
|
||||
if (error ())
|
||||
{
|
||||
set_errno (error ());
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!exists ())
|
||||
{
|
||||
set_errno (ENOENT);
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(flags & (R_OK | W_OK | X_OK)))
|
||||
return 0;
|
||||
|
||||
if (is_fs_special ())
|
||||
/* short circuit */;
|
||||
else if (has_attribute (FILE_ATTRIBUTE_READONLY) && (flags & W_OK))
|
||||
{
|
||||
set_errno (EACCES);
|
||||
return -1;
|
||||
}
|
||||
else if (has_acls () && allow_ntsec)
|
||||
return check_file_access (get_win32_name (), flags);
|
||||
|
||||
struct __stat64 st;
|
||||
int r = fstat (&st);
|
||||
if (r)
|
||||
return -1;
|
||||
r = -1;
|
||||
if (flags & R_OK)
|
||||
{
|
||||
if (st.st_uid == myself->uid)
|
||||
{
|
||||
if (!(st.st_mode & S_IRUSR))
|
||||
goto done;
|
||||
}
|
||||
else if (st.st_gid == myself->gid)
|
||||
{
|
||||
if (!(st.st_mode & S_IRGRP))
|
||||
goto done;
|
||||
}
|
||||
else if (!(st.st_mode & S_IROTH))
|
||||
goto done;
|
||||
}
|
||||
if (flags & W_OK)
|
||||
{
|
||||
if (st.st_uid == myself->uid)
|
||||
{
|
||||
if (!(st.st_mode & S_IWUSR))
|
||||
goto done;
|
||||
}
|
||||
else if (st.st_gid == myself->gid)
|
||||
{
|
||||
if (!(st.st_mode & S_IWGRP))
|
||||
goto done;
|
||||
}
|
||||
else if (!(st.st_mode & S_IWOTH))
|
||||
goto done;
|
||||
}
|
||||
if (flags & X_OK)
|
||||
{
|
||||
if (st.st_uid == myself->uid)
|
||||
{
|
||||
if (!(st.st_mode & S_IXUSR))
|
||||
goto done;
|
||||
}
|
||||
else if (st.st_gid == myself->gid)
|
||||
{
|
||||
if (!(st.st_mode & S_IXGRP))
|
||||
goto done;
|
||||
}
|
||||
else if (!(st.st_mode & S_IXOTH))
|
||||
goto done;
|
||||
}
|
||||
r = 0;
|
||||
done:
|
||||
if (r)
|
||||
set_errno (EACCES);
|
||||
return r;
|
||||
}
|
||||
|
||||
/* Open system call handler function. */
|
||||
|
Reference in New Issue
Block a user