Index: fhandler_disk_file.cc =================================================================== RCS file: /cvs/src/src/winsup/cygwin/fhandler_disk_file.cc,v retrieving revision 1.89 diff -u -p -r1.89 fhandler_disk_file.cc --- fhandler_disk_file.cc 16 Apr 2004 21:22:13 -0000 1.89 +++ fhandler_disk_file.cc 17 Apr 2004 00:44:57 -0000 @@ -387,16 +387,19 @@ fhandler_disk_file::fchmod (mode_t mode) if (!(oret = open_fs (O_BINARY, 0))) return -1; } - } - if (!allow_ntsec && allow_ntea) /* Not necessary when manipulating SD. */ - SetFileAttributes (pc, (DWORD) pc & ~FILE_ATTRIBUTE_READONLY); - if (pc.isdir ()) - mode |= S_IFDIR; - if (!set_file_attribute (pc.has_acls (), get_io_handle (), pc, - ILLEGAL_UID, ILLEGAL_GID, mode) - && allow_ntsec) - res = 0; + if (!allow_ntsec && allow_ntea) /* Not necessary when manipulating SD. */ + SetFileAttributes (pc, (DWORD) pc & ~FILE_ATTRIBUTE_READONLY); + if (pc.isdir ()) + mode |= S_IFDIR; + if (!set_file_attribute (pc.has_acls (), get_io_handle (), pc, + ILLEGAL_UID, ILLEGAL_GID, mode) + && allow_ntsec) + res = 0; + + if (oret) + close_fs (); + } /* if the mode we want has any write bits set, we can't be read only. */ if (mode & (S_IWUSR | S_IWGRP | S_IWOTH)) @@ -413,9 +416,6 @@ fhandler_disk_file::fchmod (mode_t mode) /* Correct NTFS security attributes have higher priority */ res = 0; - if (oret) - close_fs (); - return res; } @@ -424,6 +424,13 @@ fhandler_disk_file::fchown (__uid32_t ui { int oret = 0; + if (!pc.has_acls () || !allow_ntsec) + { + /* fake - if not supported, pretend we're like win95 + where it just works */ + return 0; + } + enable_restore_privilege (); if (!get_io_handle ()) { @@ -439,12 +446,6 @@ fhandler_disk_file::fchown (__uid32_t ui if (!res) res = set_file_attribute (pc.has_acls (), get_io_handle (), pc, uid, gid, attrib); - if (res && (!pc.has_acls () || !allow_ntsec)) - { - /* fake - if not supported, pretend we're like win95 - where it just works */ - res = 0; - } if (oret) close_fs ();