From b4d22926c0d9bd39a589016e053c2addbbe752f4 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 (flutter/engine#35186) --- .../impeller/compiler/impellerc_main.cc | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/engine/src/flutter/impeller/compiler/impellerc_main.cc b/engine/src/flutter/impeller/compiler/impellerc_main.cc index 76d844c070..b78807699f 100644 --- a/engine/src/flutter/impeller/compiler/impellerc_main.cc +++ b/engine/src/flutter/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(),