[MSI] Remove read-only bit when copying the package file

CopyFileW also copies the file attributes, and the copy will be opened with
write access later on.

This is import of Wine commit:
e830975806

Fixes MS Office 2000/2003 installers and probably others. CORE-17693
This commit is contained in:
Jérôme Gardou 2021-02-12 14:46:56 +01:00 committed by Stanislav Motylkov
parent e8a7e0da2b
commit 63bb43adbb
No known key found for this signature in database
GPG Key ID: AFE513258CBA9E92

View File

@ -1498,6 +1498,8 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
r = get_local_package( file, localfile );
if (r != ERROR_SUCCESS || GetFileAttributesW( localfile ) == INVALID_FILE_ATTRIBUTES)
{
DWORD localfile_attr;
r = msi_create_empty_local_file( localfile, dotmsi );
if (r != ERROR_SUCCESS)
{
@ -1514,6 +1516,11 @@ UINT MSI_OpenPackageW(LPCWSTR szPackage, MSIPACKAGE **pPackage)
return r;
}
delete_on_close = TRUE;
/* Remove read-only bit, we are opening it with write access in MSI_OpenDatabaseW below. */
localfile_attr = GetFileAttributesW( localfile );
if (localfile_attr & FILE_ATTRIBUTE_READONLY)
SetFileAttributesW( localfile, localfile_attr & ~FILE_ATTRIBUTE_READONLY);
}
TRACE("opening package %s\n", debugstr_w( localfile ));
r = MSI_OpenDatabaseW( localfile, MSIDBOPEN_TRANSACT, &db );