From 20f5a26dc70a9450ba410fc70c01b6eb184013d0 Mon Sep 17 00:00:00 2001 From: Zachary Anderson Date: Fri, 5 Aug 2022 16:37:41 -0700 Subject: [PATCH] [impellerc] Set file access mode of .iplr output to 0644 (#35186) --- impeller/compiler/impellerc_main.cc | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/impeller/compiler/impellerc_main.cc b/impeller/compiler/impellerc_main.cc index 79ff437355df9..1b752ab120662 100644 --- a/impeller/compiler/impellerc_main.cc +++ b/impeller/compiler/impellerc_main.cc @@ -3,6 +3,7 @@ // found in the LICENSE file. #include +#include #include "flutter/fml/backtrace.h" #include "flutter/fml/command_line.h" @@ -20,6 +21,21 @@ namespace impeller { namespace compiler { +// Sets the file access mode of the file at path 'p' to 0644. +static bool SetPermissiveAccess(const std::filesystem::path& p) { + auto permissions = + std::filesystem::perms::owner_read | std::filesystem::perms::owner_write | + std::filesystem::perms::group_read | std::filesystem::perms::others_read; + std::error_code error; + std::filesystem::permissions(p, permissions, error); + if (error) { + std::cerr << "Failed to set access on file '" << p + << "': " << error.message() << std::endl; + return false; + } + return true; +} + bool Main(const fml::CommandLine& command_line) { fml::InstallCrashHandler(); if (command_line.HasOption("help")) { @@ -110,6 +126,11 @@ bool Main(const fml::CommandLine& command_line) { << std::endl; return false; } + // Tools that consume the runtime stage data expect the access mode to + // be 0644. + if (!SetPermissiveAccess(sl_file_name)) { + return false; + } } else { if (!fml::WriteAtomically(*switches.working_directory, sl_file_name.string().c_str(),