From 0b245b96e4c42ef90f98809ede7e4deaf942f3c2 Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Thu, 26 Nov 2015 22:35:22 -0700 Subject: [PATCH 1/6] Update docs for globalShortcut.register Document return value for globalShortcut.register and common failure scenario. Fix: #3600 --- docs/api/global-shortcut.md | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/docs/api/global-shortcut.md b/docs/api/global-shortcut.md index a0f069d7f1c..ab6123bd877 100644 --- a/docs/api/global-shortcut.md +++ b/docs/api/global-shortcut.md @@ -46,7 +46,10 @@ The `global-shortcut` module has the following methods: * `callback` Function Registers a global shortcut of `accelerator`. The `callback` is called when -the registered shortcut is pressed by the user. +the registered shortcut is pressed by the user. Returns `true` if the shortcut +`accelerator` was registered, `false` otherwise. For example, the specified +`accelerator` has already been registered by another caller or other native +applications. ### `globalShortcut.isRegistered(accelerator)` From 62c65280a177a50ba9d3aac8c2de4ee8a9908564 Mon Sep 17 00:00:00 2001 From: Stephen Niedzielski Date: Thu, 26 Nov 2015 23:16:00 -0700 Subject: [PATCH 2/6] Update docs for webContents.addWorkSpace Specify that webContents.addWorkSpace cannot be called before DevTools creation and include example. Fix: #3536 --- docs/api/web-contents.md | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/api/web-contents.md b/docs/api/web-contents.md index 2612d621227..e976b0ddb81 100644 --- a/docs/api/web-contents.md +++ b/docs/api/web-contents.md @@ -499,7 +499,14 @@ win.webContents.on("did-finish-load", function() { * `path` String -Adds the specified path to DevTools workspace. +Adds the specified path to DevTools workspace. Must be used after DevTools +creation: + +```javascript +mainWindow.webContents.on('devtools-opened', function() { + mainWindow.webContents.addWorkSpace(__dirname); +}); +``` ### `webContents.removeWorkSpace(path)` From a1fdc701eeab630b9652e1c992eaf24164612e84 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Nov 2015 21:29:31 +0800 Subject: [PATCH 3/6] docs: Add notes on spawn and exec --- docs/tutorial/application-packaging.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/docs/tutorial/application-packaging.md b/docs/tutorial/application-packaging.md index 45973e49eaa..c6e0ae3c410 100644 --- a/docs/tutorial/application-packaging.md +++ b/docs/tutorial/application-packaging.md @@ -132,6 +132,7 @@ work. This adds a little overhead for those APIs. APIs that requires extra unpacking are: * `child_process.execFile` +* `child_process.execFileSync` * `fs.open` * `fs.openSync` * `process.dlopen` - Used by `require` on native modules @@ -143,6 +144,17 @@ archives is generated by guessing, because those files do not exist on the filesystem. So you should not trust the `Stats` object except for getting file size and checking file type. +### Executing Binaries Inside `asar` Archive + +There are Node APIs that can execute binaries like `child_process.exec`, +`child_process.spawn` and `child_process.execFile`, but only `execFile` is +supported to execute binaries inside `asar` archive. + +This is because `exec` and `spawn` accept `command` instead of `file` as input, +and `command`s are executed under shell. There is no reliable way to determine +whether a command uses a file in asar archive, and even if we do, we can not be +sure whether we can replace the path in command without side effects. + ## Adding Unpacked Files in `asar` Archive As stated above, some Node APIs will unpack the file to filesystem when From 6ef6a830425ecab31ca94a48d12aea30f14e274d Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Nov 2015 21:38:43 +0800 Subject: [PATCH 4/6] spec: Test execFile and execFileSync --- spec/asar-spec.coffee | 16 ++++++++++++++++ spec/fixtures/asar/echo.asar | Bin 0 -> 18112 bytes 2 files changed, 16 insertions(+) create mode 100644 spec/fixtures/asar/echo.asar diff --git a/spec/asar-spec.coffee b/spec/asar-spec.coffee index ad480a58252..af39fa3ec5e 100644 --- a/spec/asar-spec.coffee +++ b/spec/asar-spec.coffee @@ -392,6 +392,22 @@ describe 'asar package', -> done() child.send file + describe 'child_process.execFile', -> + return unless process.platform is 'darwin' + + {execFile, execFileSync} = require 'child_process' + echo = path.join fixtures, 'asar', 'echo.asar', 'echo' + + it 'executes binaries', (done) -> + child = execFile echo, ['test'], (error, stdout) -> + assert.equal error, null + assert.equal stdout, 'test\n' + done() + + it 'execFileSync executes binaries', -> + output = execFileSync echo, ['test'] + assert.equal String(output), 'test\n' + describe 'internalModuleReadFile', -> internalModuleReadFile = process.binding('fs').internalModuleReadFile diff --git a/spec/fixtures/asar/echo.asar b/spec/fixtures/asar/echo.asar new file mode 100644 index 0000000000000000000000000000000000000000..4d72f7a92a7bbd6ccc205942348801eea307742e GIT binary patch literal 18112 zcmeHNcUV(N*S|LjO-ewdC<50A76fub6R;5_OQIl1u|o{W1tKKG6pEE1YD5++YeN*p zwV>-OqGA`6RV*u@=qkGS?%Lo*T|3y|n@M4T)!px}cfap>GEe57IWuR@ocT?;=gx$J zAP5`8KoA2!TtJHxCJ{24{{kApPe_JTCY(>u{29Kur-v&oIWA5{$Z7sGoaRa+(g?mn z&WlX~<#MTlShQ$S?T2R_1_*+Z5hQ~I^qGS=M-M@A5DcUcq(6wTJuWwl8N`~&3J-<3 zJpI^0{|3yr=N8hwzbXwqLITrOWGmkP!4n!?`t(x~eGT4~B5 z-#zrO6%=r}3UR7XEZ_>oamgya=Xexo^o41ZK)$z*?)tf0B7qwx<%tM&Zg2bkt|lC35Lk z^=Z{WJ>Bhs^TQBCZQyc~cz>nOTw`B=rUK-<>x1_7(JBMQUjKW)T|L2UMb%+FnCIwOB(D4Db>_3jhT_6+W>17+{P6Jva!gb3kD_ z3`7{9er<$!8o|u3galB(?-$Czv_>!x;c})cWKw#PFqSSzPZ9tg20IX;9eZky%l9>p z8gPL2mR8R?o8ScU%t1tq0a_rsXnB}-5i522Vv)u*-BO=J9mL$a9*Mzi}8@1 z(R^XjE!f%T&6%CGfQMcHNBIjgyOXp~FDOqi?lUuQ zwiC+ce`HrZp)}tG!2Q$ z+jeGm@N*S)XJLJ6V4G4=$EF6J1Hzo#sCJHW+6#^{s9mwXl?)oqUQ~xDtU#j;-5Skh zU1ch(Sve2ozRa`G=VoSpf+SG+fJqI#uTmVWe5Y(|rhztqEuC_V%|Fks`ZtAxUSJNt zr?|$bWM@~~&SK7HMl)lW-01TF!e>x8cT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0&d|H;?RBa@ZTJFxYYGW`-1Pj`QEi{o8h#u! z&8}Z#Uk_IcJrfG`yV8c=KD??HB{YSHo6=-8IWqg-r%Zmal5;R&9WjM=|8qdT_u+(q z@RQEpUj1-wVc)5@E9;{4j!Y~&!u#~y!qqX-`eBFdM~E6H#c$L5^!Uk)i4$TR7c3ol zrsKrQ5uSSM!m^KbY`#lAnHT%2zbJL>14XUR3`UHhC>k9|M1-$RN!wy$Z0@k`luyCb zNrCPg@9bi1e=#s_-KI#H<&i1Ar<`^a;o4O%MN_PLXF zzPSJX(I*PYmy$zP5H?`canr3!vvy?lb|Nhvk@+0%!JS&ej zh>L6>HheyC>b2w8x6wl@XX^QU^ZGyQr`bkV$A>WPzpQX-bge?_tX>`dF@(<>_RY}u z7vKFzde*i|h#c9**pM4GP&6tx)i!nN&BAet-wiikvPopKSZ-6=B#ZNBHP8=kTRrkj z5>am_YZw|ie#zvw)9=tYG30R%``X%`6zqQ4m-KP=%7*XCa!&2COXFq>6XvDpmDXJM zinm|L*wLcAJ@e`Y+qLg@d9GR$aQyqD^~P7w%wnLJU|z82^5hK!<=10UZK51at`K5P%5$52E*41^@s6 literal 0 HcmV?d00001 From cfdcfcbd80c43fa124b6926ebd6a355f4c6cc5ce Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Nov 2015 22:06:37 +0800 Subject: [PATCH 5/6] Add executable permission in CopyFileOut --- atom/common/api/atom_api_asar.cc | 1 - atom/common/asar/archive.cc | 10 ++++++++-- atom/common/asar/archive.h | 2 +- atom/common/lib/asar.coffee | 11 ----------- 4 files changed, 9 insertions(+), 15 deletions(-) diff --git a/atom/common/api/atom_api_asar.cc b/atom/common/api/atom_api_asar.cc index 489118bd70a..4ea7d8c5c36 100644 --- a/atom/common/api/atom_api_asar.cc +++ b/atom/common/api/atom_api_asar.cc @@ -54,7 +54,6 @@ 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 61b22e9013f..ab93e301b1a 100644 --- a/atom/common/asar/archive.cc +++ b/atom/common/asar/archive.cc @@ -13,6 +13,7 @@ #include "atom/common/asar/scoped_temporary_file.h" #include "base/files/file.h" +#include "base/files/file_util.h" #include "base/logging.h" #include "base/pickle.h" #include "base/json/json_reader.h" @@ -96,7 +97,6 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, return false; info->size = static_cast(size); - info->unpacked = false; if (node->GetBoolean("unpacked", &info->unpacked) && info->unpacked) return true; @@ -107,7 +107,6 @@ bool FillFileInfoWithNode(Archive::FileInfo* info, return false; info->offset += header_size; - info->executable = false; node->GetBoolean("executable", &info->executable); return true; @@ -276,6 +275,13 @@ bool Archive::CopyFileOut(const base::FilePath& path, base::FilePath* out) { if (!temp_file->InitFromFile(&file_, info.offset, info.size)) return false; +#if defined(OS_POSIX) + if (info.executable) { + // chmod a+x temp_file; + base::SetPosixFilePermissions(temp_file->path(), 0755); + } +#endif + *out = temp_file->path(); external_files_.set(path, temp_file.Pass()); return true; diff --git a/atom/common/asar/archive.h b/atom/common/asar/archive.h index fb52c6265d3..de5b9de605a 100644 --- a/atom/common/asar/archive.h +++ b/atom/common/asar/archive.h @@ -25,7 +25,7 @@ class ScopedTemporaryFile; class Archive { public: struct FileInfo { - FileInfo() : size(0), offset(0) {} + FileInfo() : unpacked(false), executable(false), size(0), offset(0) {} bool unpacked; bool executable; uint32 size; diff --git a/atom/common/lib/asar.coffee b/atom/common/lib/asar.coffee index fba3faed8ce..f7eeceb3f31 100644 --- a/atom/common/lib/asar.coffee +++ b/atom/common/lib/asar.coffee @@ -1,6 +1,5 @@ asar = process.binding 'atom_common_asar' child_process = require 'child_process' -fs = require 'fs' path = require 'path' util = require 'util' @@ -84,11 +83,6 @@ 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 @@ -108,11 +102,6 @@ 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 From 62add3abccf7b192e222c54071202c0ddf934470 Mon Sep 17 00:00:00 2001 From: Cheng Zhao Date: Fri, 27 Nov 2015 22:23:19 +0800 Subject: [PATCH 6/6] Bump v0.35.2 --- atom.gyp | 2 +- atom/browser/resources/mac/Info.plist | 4 ++-- atom/browser/resources/win/atom.rc | 8 ++++---- atom/common/atom_version.h | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/atom.gyp b/atom.gyp index 9d667410523..202a414003f 100644 --- a/atom.gyp +++ b/atom.gyp @@ -4,7 +4,7 @@ 'product_name%': 'Electron', 'company_name%': 'GitHub, Inc', 'company_abbr%': 'github', - 'version%': '0.35.1', + 'version%': '0.35.2', }, 'includes': [ 'filenames.gypi', diff --git a/atom/browser/resources/mac/Info.plist b/atom/browser/resources/mac/Info.plist index 481945b8e89..fb4a2332334 100644 --- a/atom/browser/resources/mac/Info.plist +++ b/atom/browser/resources/mac/Info.plist @@ -17,9 +17,9 @@ CFBundleIconFile atom.icns CFBundleVersion - 0.35.1 + 0.35.2 CFBundleShortVersionString - 0.35.1 + 0.35.2 LSApplicationCategoryType public.app-category.developer-tools LSMinimumSystemVersion diff --git a/atom/browser/resources/win/atom.rc b/atom/browser/resources/win/atom.rc index 875727cdaff..773871fd558 100644 --- a/atom/browser/resources/win/atom.rc +++ b/atom/browser/resources/win/atom.rc @@ -56,8 +56,8 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 0,35,1,0 - PRODUCTVERSION 0,35,1,0 + FILEVERSION 0,35,2,0 + PRODUCTVERSION 0,35,2,0 FILEFLAGSMASK 0x3fL #ifdef _DEBUG FILEFLAGS 0x1L @@ -74,12 +74,12 @@ BEGIN BEGIN VALUE "CompanyName", "GitHub, Inc." VALUE "FileDescription", "Electron" - VALUE "FileVersion", "0.35.1" + VALUE "FileVersion", "0.35.2" VALUE "InternalName", "electron.exe" VALUE "LegalCopyright", "Copyright (C) 2015 GitHub, Inc. All rights reserved." VALUE "OriginalFilename", "electron.exe" VALUE "ProductName", "Electron" - VALUE "ProductVersion", "0.35.1" + VALUE "ProductVersion", "0.35.2" VALUE "SquirrelAwareVersion", "1" END END diff --git a/atom/common/atom_version.h b/atom/common/atom_version.h index 093da7b5c60..b5cc0982d0d 100644 --- a/atom/common/atom_version.h +++ b/atom/common/atom_version.h @@ -7,7 +7,7 @@ #define ATOM_MAJOR_VERSION 0 #define ATOM_MINOR_VERSION 35 -#define ATOM_PATCH_VERSION 1 +#define ATOM_PATCH_VERSION 2 #define ATOM_VERSION_IS_RELEASE 1