From 41f17389623b68cff40b4648b35b585bc7e68e8a Mon Sep 17 00:00:00 2001 From: Paul Cristian Sarbu Date: Wed, 28 Aug 2024 10:39:39 +0200 Subject: FileSystemManager: Implicit copy should not follow symlinks The default options of std::filesystem::copy include following symlinks, resulting in file repositories creating wrong trees if containing unresolved symlinks, or failing unexpectedly early if symlink cycles existed. This is fixed by ensuring the copy_symlinks option is always used. --- src/buildtool/file_system/file_system_manager.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/buildtool/file_system/file_system_manager.hpp b/src/buildtool/file_system/file_system_manager.hpp index 6cf8f256..514fadd2 100644 --- a/src/buildtool/file_system/file_system_manager.hpp +++ b/src/buildtool/file_system/file_system_manager.hpp @@ -418,11 +418,11 @@ class FileSystemManager { dst.string()); return false; } - std::filesystem::copy(src, - dst, - recursively - ? std::filesystem::copy_options::recursive - : std::filesystem::copy_options::none); + auto const opts = + std::filesystem::copy_options::copy_symlinks | + (recursively ? std::filesystem::copy_options::recursive + : std::filesystem::copy_options::none); + std::filesystem::copy(src, dst, opts); return true; } catch (std::exception const& e) { Logger::Log(LogLevel::Error, -- cgit v1.2.3