diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b37f23d07..8e4825975 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,10 @@ +2011-07-05 Corinna Vinschen + + * fhandler.cc (fhandler_base::open): Never create files with WRITE_DAC + access. Explain why. + * fhandler_disk_file.cc (fhandler_base::fstat_helper): Improve debug + output. + 2011-07-05 Corinna Vinschen * fhandler.cc (fhandler_base::open): Don't open file with WRITE_DAC diff --git a/winsup/cygwin/fhandler.cc b/winsup/cygwin/fhandler.cc index d41a37347..b72e03d60 100644 --- a/winsup/cygwin/fhandler.cc +++ b/winsup/cygwin/fhandler.cc @@ -613,20 +613,15 @@ fhandler_base::open (int flags, mode_t mode) /* If mode has no write bits set, and ACLs are not used, we set the DOS R/O attribute. */ file_attributes |= FILE_ATTRIBUTE_READONLY; - else if (!exists () && has_acls () && !isremote ()) - /* If we are about to create the file and the filesystem supports - ACLs, we will overwrite the DACL after the call to NtCreateFile. - This requires a handle with additional WRITE_DAC access, - otherwise set_file_sd has to open the file again. - FIXME: On remote NTFS shares open sometimes fails because even - the creator of the file doesn't have the right to change the - DACL. I don't know what setting that is or howq to recognize - such a share, so for now we don't request WRITE_DAC on remote - drives. */ - access |= WRITE_DAC; - /* The file attributes are needed for later use in, e.g. fchmod. */ pc.file_attributes (file_attributes); + /* Never set the WRITE_DAC flag here. Calls to fstat may return + wrong st_ctime information after calls to fchmod, fchown, etc + because Windows only gurantees to update the metadata when + the handle is closed or flushed. However, flushing the file + on every fstat to enforce POSIXy stat behaviour is exceessivly + slow, compared to open/close the file when changing the file's + security descriptor. */ } } diff --git a/winsup/cygwin/fhandler_disk_file.cc b/winsup/cygwin/fhandler_disk_file.cc index 36af9a50d..48ffd6060 100644 --- a/winsup/cygwin/fhandler_disk_file.cc +++ b/winsup/cygwin/fhandler_disk_file.cc @@ -659,10 +659,15 @@ fhandler_base::fstat_helper (struct __stat64 *buf, } done: - syscall_printf ("0 = fstat (%S, %p) st_atime=%x st_size=%D, st_mode=%p, " - "st_ino=%D, sizeof=%d", - pc.get_nt_native_path (), buf, buf->st_atime, buf->st_size, - buf->st_mode, buf->st_ino, sizeof (*buf)); + syscall_printf ("0 = fstat (%S, %p) st_size=%D, st_mode=%p, st_ino=%D" + "st_atim=%x.%x st_ctim=%x.%x " + "st_mtim=%x.%x st_birthtim=%x.%x", + pc.get_nt_native_path (), buf, + buf->st_size, buf->st_mode, buf->st_ino, + buf->st_atim.tv_sec, buf->st_atim.tv_nsec, + buf->st_ctim.tv_sec, buf->st_ctim.tv_nsec, + buf->st_mtim.tv_sec, buf->st_mtim.tv_nsec, + buf->st_birthtim.tv_sec, buf->st_birthtim.tv_nsec); return 0; }