summaryrefslogtreecommitdiff
path: root/src/buildtool/execution_api/local/local_action.cpp
diff options
context:
space:
mode:
authorPaul Cristian Sarbu <paul.cristian.sarbu@huawei.com>2023-07-25 15:37:53 +0200
committerKlaus Aehlig <klaus.aehlig@huawei.com>2023-08-08 10:56:20 +0200
commit63ff75d2818a3613b01c5ad322802c305d2282f8 (patch)
treee45ba21d34763d104874dc6b3b6e976edbf29cb5 /src/buildtool/execution_api/local/local_action.cpp
parent776347cd196ab16eec72e186dcf7f86dd620b42b (diff)
downloadjustbuild-63ff75d2818a3613b01c5ad322802c305d2282f8.tar.gz
just execute: Fix uncollected upwards symlinks
Upwards symlinks should still be collected from actions, even if only the non-upwards symlinks are supported artifact types. The client side is thus the one responsible with enforcing the non-upwardness condition.
Diffstat (limited to 'src/buildtool/execution_api/local/local_action.cpp')
-rw-r--r--src/buildtool/execution_api/local/local_action.cpp36
1 files changed, 12 insertions, 24 deletions
diff --git a/src/buildtool/execution_api/local/local_action.cpp b/src/buildtool/execution_api/local/local_action.cpp
index d3ad7fd9..3fcd8fe7 100644
--- a/src/buildtool/execution_api/local/local_action.cpp
+++ b/src/buildtool/execution_api/local/local_action.cpp
@@ -268,15 +268,14 @@ auto LocalAction::CollectOutputFileOrSymlink(
std::string const& local_path) const noexcept
-> std::optional<OutputFileOrSymlink> {
auto file_path = exec_path / local_path;
- auto type = FileSystemManager::Type(file_path);
+ auto type = FileSystemManager::Type(file_path, /*allow_upwards=*/true);
if (not type) {
Logger::Log(LogLevel::Error, "expected known type at {}", local_path);
return std::nullopt;
}
if (IsSymlinkObject(*type)) {
auto content = FileSystemManager::ReadSymlink(file_path);
- if (content and PathIsNonUpwards(*content) and
- storage_->CAS().StoreBlob(*content)) {
+ if (content and storage_->CAS().StoreBlob(*content)) {
auto out_symlink = bazel_re::OutputSymlink{};
out_symlink.set_path(local_path);
out_symlink.set_target(*content);
@@ -308,15 +307,14 @@ auto LocalAction::CollectOutputDirOrSymlink(
std::string const& local_path) const noexcept
-> std::optional<OutputDirOrSymlink> {
auto dir_path = exec_path / local_path;
- auto type = FileSystemManager::Type(dir_path);
+ auto type = FileSystemManager::Type(dir_path, /*allow_upwards=*/true);
if (not type) {
Logger::Log(LogLevel::Error, "expected known type at {}", local_path);
return std::nullopt;
}
if (IsSymlinkObject(*type)) {
auto content = FileSystemManager::ReadSymlink(dir_path);
- if (content and PathIsNonUpwards(*content) and
- storage_->CAS().StoreBlob(*content)) {
+ if (content and storage_->CAS().StoreBlob(*content)) {
auto out_symlink = bazel_re::OutputSymlink{};
out_symlink.set_path(local_path);
out_symlink.set_target(*content);
@@ -354,15 +352,10 @@ auto LocalAction::CollectAndStoreOutputs(
}
if (std::holds_alternative<bazel_re::OutputSymlink>(*out)) {
auto out_symlink = std::get<bazel_re::OutputSymlink>(*out);
- auto const& target = out_symlink.target();
- if (not PathIsNonUpwards(target)) {
- logger_.Emit(LogLevel::Error,
- "collected upwards output symlink {}",
- path);
- return false;
- }
- logger_.Emit(
- LogLevel::Trace, " - symlink {}: {}", path, target);
+ logger_.Emit(LogLevel::Trace,
+ " - symlink {}: {}",
+ path,
+ out_symlink.target());
result->mutable_output_file_symlinks()->Add(
std::move(out_symlink));
}
@@ -383,15 +376,10 @@ auto LocalAction::CollectAndStoreOutputs(
}
if (std::holds_alternative<bazel_re::OutputSymlink>(*out)) {
auto out_symlink = std::get<bazel_re::OutputSymlink>(*out);
- auto const& target = out_symlink.target();
- if (not PathIsNonUpwards(target)) {
- logger_.Emit(LogLevel::Error,
- "collected upwards output symlink {}",
- path);
- return false;
- }
- logger_.Emit(
- LogLevel::Trace, " - symlink {}: {}", path, target);
+ logger_.Emit(LogLevel::Trace,
+ " - symlink {}: {}",
+ path,
+ out_symlink.target());
result->mutable_output_file_symlinks()->Add(
std::move(out_symlink));
}