Skip to content

Commit 0a4403a

Browse files
committed
CustomActions: correct destination path and permissions
This corrects the file handle to the temporary file to be opened with a shared disposition, drop write privileges as we will not modify the file, and correct the destination path. We were previously overwriting the temporary file with itself, which made the operation meaningless.
1 parent 6f4ade1 commit 0a4403a

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

platforms/Windows/CustomActions/SwiftInstaller/Sources/swift_installer.cc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,9 @@ bool replace_file(const std::filesystem::path &source,
348348

349349
// Rename file.
350350
HANDLE hFile = CreateFileW(temp.wstring().c_str(),
351-
GENERIC_READ | GENERIC_WRITE | DELETE, 0, nullptr,
351+
GENERIC_READ | DELETE,
352+
FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE,
353+
nullptr,
352354
OPEN_EXISTING,
353355
FILE_FLAG_BACKUP_SEMANTICS | FILE_FLAG_OPEN_REPARSE_POINT | FILE_FLAG_POSIX_SEMANTICS,
354356
nullptr);
@@ -359,7 +361,7 @@ bool replace_file(const std::filesystem::path &source,
359361

360362
windows::raii::handle handle(hFile);
361363

362-
std::wstring path = temp.wstring();
364+
std::wstring path = destination.wstring();
363365
std::vector<char> buffer(sizeof(FILE_RENAME_INFO) - sizeof(wchar_t) +
364366
(path.size() * sizeof(std::wstring::value_type)));
365367
FILE_RENAME_INFO &rename_info =

0 commit comments

Comments
 (0)