From 786803bc705131cda803c821d0b620902ef31616 Mon Sep 17 00:00:00 2001 From: Miguel <1889916+miguelfrde@users.noreply.github.com> Date: Fri, 3 Feb 2023 16:03:36 -0600 Subject: [PATCH] [fuchsia] fdio_service_connect no longer provides rights which we need (flutter/engine#39374) fdio_service_connect no longer provides rights. Since we need the READABLE right when opening the debug/ctrl/diagnostics directories, this change uses fdio_open_at. This change also fixes the Clone to remove specific rights and instead use CLONE_SAME_RIGHTS. Verified locally that we no longer get ACCESS_DENIED on the diagnostics directory when opening in component manager. --- .../shell/platform/fuchsia/flutter/component_v1.cc | 10 ++++++---- .../shell/platform/fuchsia/flutter/component_v2.cc | 10 ++++++---- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc index 3f21401c36..b869edbdd9 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v1.cc @@ -217,8 +217,7 @@ ComponentV1::ComponentV1( // Clone and check if client is servicing the directory. directory_ptr_->Clone(fuchsia::io::OpenFlags::DESCRIBE | - fuchsia::io::OpenFlags::RIGHT_READABLE | - fuchsia::io::OpenFlags::RIGHT_WRITABLE, + fuchsia::io::OpenFlags::CLONE_SAME_RIGHTS, cloned_directory_ptr_.NewRequest()); cloned_directory_ptr_.events().OnOpen = [this](zx_status_t status, @@ -234,8 +233,11 @@ ComponentV1::ComponentV1( for (auto& dir_str : other_dirs) { fuchsia::io::DirectoryHandle dir; auto request = dir.NewRequest().TakeChannel(); - auto status = fdio_service_connect_at(directory_ptr_.channel().get(), - dir_str, request.release()); + auto status = fdio_open_at( + directory_ptr_.channel().get(), dir_str, + static_cast(fuchsia::io::OpenFlags::DIRECTORY | + fuchsia::io::OpenFlags::RIGHT_READABLE), + request.release()); if (status == ZX_OK) { outgoing_dir_->AddEntry( dir_str, std::make_unique(dir.TakeChannel())); diff --git a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc index fdd577469d..9893de69e1 100644 --- a/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc +++ b/engine/src/flutter/shell/platform/fuchsia/flutter/component_v2.cc @@ -267,8 +267,7 @@ ComponentV2::ComponentV2( // Clone and check if client is servicing the directory. directory_ptr_->Clone(fuchsia::io::OpenFlags::DESCRIBE | - fuchsia::io::OpenFlags::RIGHT_READABLE | - fuchsia::io::OpenFlags::RIGHT_WRITABLE, + fuchsia::io::OpenFlags::CLONE_SAME_RIGHTS, cloned_directory_ptr_.NewRequest()); // Collect our standard set of directories along with directories that are @@ -291,8 +290,11 @@ ComponentV2::ComponentV2( for (auto& dir_str : other_dirs) { fuchsia::io::DirectoryHandle dir; auto request = dir.NewRequest().TakeChannel(); - auto status = fdio_service_connect_at(directory_ptr_.channel().get(), - dir_str.c_str(), request.release()); + auto status = fdio_open_at( + directory_ptr_.channel().get(), dir_str.c_str(), + static_cast(fuchsia::io::OpenFlags::DIRECTORY | + fuchsia::io::OpenFlags::RIGHT_READABLE), + request.release()); if (status == ZX_OK) { outgoing_dir_->AddEntry( dir_str.c_str(),