diff --git a/atom/common/api/atom_api_asar.cc b/atom/common/api/atom_api_asar.cc index 4ea7d8c5c362..489118bd70af 100644 --- a/atom/common/api/atom_api_asar.cc +++ b/atom/common/api/atom_api_asar.cc @@ -54,6 +54,7 @@ class Archive : public mate::Wrappable { mate::Dictionary dict(isolate, v8::Object::New(isolate)); dict.Set("size", stats.size); dict.Set("offset", stats.offset); + dict.Set("executable", stats.executable); dict.Set("isFile", stats.is_file); dict.Set("isDirectory", stats.is_directory); dict.Set("isLink", stats.is_link); diff --git a/atom/common/asar/archive.cc b/atom/common/asar/archive.cc index 969f958956ca..61b22e9013f6 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -107,6 +107,9 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, return false; info->offset += header_size; + info->executable = false; + node->GetBoolean("executable", &info->executable); + return true; } diff --git a/atom/common/asar/archive.h b/atom/common/asar/archive.h index f2ff2f76d676..fb52c6265d31 100644 --- a/atom/common/asar/archive.h +++ b/atom/common/asar/archive.h @@ -27,6 +27,7 @@ class Archive { struct FileInfo { FileInfo() : size(0), offset(0) {} bool unpacked; + bool executable; uint32 size; uint64 offset; }; diff --git a/atom/common/lib/asar.coffee b/atom/common/lib/asar.coffee index f7eeceb3f314..fba3faed8ce2 100644 --- a/atom/common/lib/asar.coffee +++ b/atom/common/lib/asar.coffee @@ -1,5 +1,6 @@ asar = process.binding 'atom_common_asar' child_process = require 'child_process' +fs = require 'fs' path = require 'path' util = require 'util' @@ -83,6 +84,11 @@ overrideAPISync = (module, name, arg = 0) -> newPath = archive.copyFileOut filePath notFoundError asarPath, filePath unless newPath + stat = archive.stat filePath + + if stat.executable + fs.chmodSync(newPath, 0o755) + arguments[arg] = newPath old.apply this, arguments @@ -102,6 +108,11 @@ overrideAPI = (module, name, arg = 0) -> newPath = archive.copyFileOut filePath return notFoundError asarPath, filePath, callback unless newPath + stat = archive.stat filePath + + if stat.executable + fs.chmodSync(newPath, 0o755) + arguments[arg] = newPath old.apply this, arguments