copy on mac instead renaming

This commit is contained in:
Yakov Olkhovskiy 2024-02-12 18:01:43 +00:00
parent 407b7a4651
commit 3aefd0f50b

View File

@ -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<char *>(decompressed_name), static_cast<char *>(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<uint32_t>(decompressed_umask)))
{
perror("chmod");