https://git.reactos.org/?p=reactos.git;a=commitdiff;h=63bb43adbb83f47df121d00e7578490bf59b5c01

commit 63bb43adbb83f47df121d00e7578490bf59b5c01
Author:     Jérôme Gardou <[email protected]>
AuthorDate: Fri Feb 12 14:46:56 2021 +0100
Commit:     Stanislav Motylkov <[email protected]>
CommitDate: Sat Dec 18 15:44:04 2021 +0300

    [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:
    
https://source.winehq.org/git/wine.git/commit/e830975806df9ef283c89f7153b06b145dfb2cec
    
    Fixes MS Office 2000/2003 installers and probably others. CORE-17693
---
 dll/win32/msi/package.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/dll/win32/msi/package.c b/dll/win32/msi/package.c
index 5aa3dd0e128..f65e2eea4cf 100644
--- a/dll/win32/msi/package.c
+++ b/dll/win32/msi/package.c
@@ -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 );

Reply via email to