* fhandler_disk_file.cc (fhandler_disk_file::fchmod): Don't allow
FileAttributes set to 0 when calling NtSetInformationFile since it has a special meaning. (fhandler_disk_file::facl): Ditto. (fhandler_disk_file::link): Only set attributes after copying files. Use SetFileAttributesW. * syscalls.cc (unlink_nt): Only care for actual FILE_ATTRIBUTE_READONLY. Don't allow FileAttributes set to 0 when calling NtSetInformationFile. After marking for deletion, restore R/O attribute on files to accommodate hardlinks.
This commit is contained in:
@ -776,7 +776,7 @@ fhandler_disk_file::fchmod (mode_t mode)
|
||||
FILE_BASIC_INFORMATION fbi;
|
||||
fbi.CreationTime.QuadPart = fbi.LastAccessTime.QuadPart
|
||||
= fbi.LastWriteTime.QuadPart = fbi.ChangeTime.QuadPart = 0LL;
|
||||
fbi.FileAttributes = pc.file_attributes ();
|
||||
fbi.FileAttributes = pc.file_attributes () ?: FILE_ATTRIBUTE_NORMAL;
|
||||
NTSTATUS status = NtSetInformationFile (get_handle (), &io, &fbi, sizeof fbi,
|
||||
FileBasicInformation);
|
||||
if (!NT_SUCCESS (status))
|
||||
@ -914,8 +914,9 @@ fhandler_disk_file::facl (int cmd, int nentries, __aclent32_t *aclbufp)
|
||||
= fbi.LastAccessTime.QuadPart
|
||||
= fbi.LastWriteTime.QuadPart
|
||||
= fbi.ChangeTime.QuadPart = 0LL;
|
||||
fbi.FileAttributes = pc.file_attributes ()
|
||||
& ~FILE_ATTRIBUTE_READONLY;
|
||||
fbi.FileAttributes = (pc.file_attributes ()
|
||||
& ~FILE_ATTRIBUTE_READONLY)
|
||||
?: FILE_ATTRIBUTE_NORMAL;
|
||||
NtSetInformationFile (get_handle (), &io, &fbi, sizeof fbi,
|
||||
FileBasicInformation);
|
||||
}
|
||||
@ -1124,6 +1125,10 @@ fhandler_disk_file::link (const char *newpath)
|
||||
__seterrno ();
|
||||
return -1;
|
||||
}
|
||||
if (!allow_winsymlinks && pc.is_lnk_special ())
|
||||
SetFileAttributesW (newpcw, pc.file_attributes ()
|
||||
| FILE_ATTRIBUTE_SYSTEM
|
||||
| FILE_ATTRIBUTE_READONLY);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1131,10 +1136,6 @@ fhandler_disk_file::link (const char *newpath)
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
if (!allow_winsymlinks && pc.is_lnk_special ())
|
||||
SetFileAttributes (newpc, (DWORD) pc
|
||||
| FILE_ATTRIBUTE_SYSTEM
|
||||
| FILE_ATTRIBUTE_READONLY);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user