From 2c1ffdbf5e6f2767ab63e67834530539d36c6c0b Mon Sep 17 00:00:00 2001 From: Corinna Vinschen Date: Mon, 16 Oct 2006 12:26:59 +0000 Subject: * autoload.cc (PrivilegeCheck): Define. * fhandler.cc (fhandler_base::open): Always try opening with backup resp. restore intent. * fhandler_disk_file.cc (fhandler_disk_file::opendir): Always try opening with backup intent. (fhandler_disk_file::readdir): Ditto when trying to retrieve file id explicitely. * security.cc (check_file_access): Replace pbuf with correctly PPRIVILEGE_SET typed pset. Check explicitely for backup and/or restore privileges when AccessCheck fails, to circumvent AccessCheck shortcoming. Add comment to explain. --- winsup/cygwin/fhandler.cc | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) (limited to 'winsup/cygwin/fhandler.cc') diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index 00e987587..672b434e5 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -620,13 +620,22 @@ fhandler_base::open (int flags, mode_t mode) create_options = FILE_OPEN_FOR_BACKUP_INTENT | FILE_OPEN_FOR_RECOVERY; break; default: - create_options = 0; if ((flags & O_ACCMODE) == O_RDONLY) - access = GENERIC_READ; + { + access = GENERIC_READ; + create_options = FILE_OPEN_FOR_BACKUP_INTENT; + } else if ((flags & O_ACCMODE) == O_WRONLY) - access = GENERIC_WRITE | FILE_READ_ATTRIBUTES; + { + access = GENERIC_WRITE | FILE_READ_ATTRIBUTES; + create_options = FILE_OPEN_FOR_RECOVERY; + } else - access = GENERIC_READ | GENERIC_WRITE; + { + access = GENERIC_READ | GENERIC_WRITE; + create_options = FILE_OPEN_FOR_BACKUP_INTENT + | FILE_OPEN_FOR_RECOVERY; + } if (flags & O_SYNC) create_options |= FILE_WRITE_THROUGH; if (flags & O_DIRECT) -- cgit v1.2.3