From 3aefd0f50bc1cbfd6e6c84ab6196417f8e062aa0 Mon Sep 17 00:00:00 2001 From: Yakov Olkhovskiy Date: Mon, 12 Feb 2024 18:01:43 +0000 Subject: [PATCH] copy on mac instead renaming --- utils/self-extracting-executable/decompressor.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/utils/self-extracting-executable/decompressor.cpp b/utils/self-extracting-executable/decompressor.cpp index 6614403c0ab..071ecb066cb 100644 --- a/utils/self-extracting-executable/decompressor.cpp +++ b/utils/self-extracting-executable/decompressor.cpp @@ -529,14 +529,22 @@ int main(int/* argc*/, char* argv[]) char decompressed_name[decompressed_name_len + 1]; (void)snprintf(decompressed_name, decompressed_name_len + 1, decompressed_name_fmt, self, decompressed_suffix); +#if defined(OS_DARWIN) + // We can't just rename it on Mac due to security issues, so we copy it... std::error_code ec; - + std::filesystem::copy_file(static_cast(decompressed_name), static_cast(self), ec); + if (ec) + { + std::cerr << ec.message() << std::endl; + return 1; + } +#else if (link(decompressed_name, self)) { perror("link"); return 1; } - +#endif if (chmod(self, static_cast(decompressed_umask))) { perror("chmod");