[impellerc] Set file access mode of .iplr output to 0644 (flutter/engine#35186)

This commit is contained in:
Zachary Anderson
2022-08-05 16:37:41 -07:00
committed by GitHub
parent 5ee9b35316
commit b4d22926c0

View File

@@ -3,6 +3,7 @@
// found in the LICENSE file.
#include <filesystem>
#include <system_error>
#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(),