Commit graph

25 commits

Author SHA1 Message Date
Kevin Sawicki
b119704ea9 Use 2 space indent instead of 3 2016-01-15 10:05:35 -08:00
Ivo Georgiev
7586078d0a Ensure we close FD on Windows 2016-01-15 16:54:29 +02:00
Juan Cruz Viotti
a99c193cf2 🏁 Preserve file extension when extracting from asar
Currently, when calling `copyFileOut`, the original extension from the
file is lost, and a generic `*.tmp` is added instead.

This becomes problematic in the scenario where we use
`child_process.execFile` on a Windows Batch script that lives inside the
`asar` package.

Windows relies on the extension being present in order to interpret the
script accordingly, which results in the following bug because the
operating system doesn't know what do to with this `*.tmp` file:

```
Error: spawn UNKNOWN
```

Steps to reproduce:

1. Create a dummy batch script (test.bat):

```
@echo off
echo "Hello world"
```

2. Create an electron app that attemps to call this script with
`child_process.execFile`:

```js
var child_process = require('child_process');
var path = require('path');

child_process.execFile(path.join(__dirname, 'test.bat'), function(error, stdout) {
    if (error) throw error;
    console.log(stdout);
});
```

3. Package this small application as an asar archive:

```sh
> asar pack mytestapp app.asar
```

4. Execute the application:

```sh
> electron.exe app.asar
```
2015-12-01 14:55:58 -04:00
Cheng Zhao
cfdcfcbd80 Add executable permission in CopyFileOut 2015-11-27 22:06:37 +08:00
Juan Cruz Viotti
585ff9062c 🐛 Fix missing execution permission bit in execFile override
Consider an electron application that uses `execFile` to run a script
that lives within the application code base:

```coffee
child_process = require 'child_process'
child_process.execFile __dirname + '/script.sh', (error) ->
  throw error if error?
```

An application like this will fail when being packaged in an `asar` with
an following error:

```
Error: spawn EACCES
```

Electron overrides certain `fs` functions to make them work within an
`asar` package. In the case of `execFile`, the file to be executed is
extracted from the `asar` package into a temporary file and ran from
there.

The problem is that during the extraction, the original permissions of
the file are lost.

We workaround this by:

1. Extending `asar.stat` to return whether a file is executable or not,
  which is information that's already saved in the `asar` header.

2. Setting execution permissions on the extracted file if the above
  property holds true.

Fixes: https://github.com/atom/electron/issues/3512
2015-11-26 23:30:23 -04:00
Cheng Zhao
9e90ea8734 win: Fix leaking of fd when reading file in asar 2015-09-24 12:11:07 +08:00
Cheng Zhao
45491ca7ab Fix API changes 2015-09-03 17:50:23 +09:00
Cheng Zhao
a2c26b8c74 Fix hanlding trailing slash in asar package, close #2222 2015-07-16 03:49:26 -07:00
Cheng Zhao
01e891652f Fix compilation errors 2015-05-22 15:24:34 +08:00
Cheng Zhao
d8d7e5b9bb Add Archive::GetFD 2015-05-11 11:02:17 +08:00
Cheng Zhao
f8e1dfbbc6 Keep archive's file opened in the archive's whole life time 2015-05-11 10:47:29 +08:00
Cheng Zhao
b5a8cfb704 Recognize asar archive with unpacked files 2015-03-20 20:34:58 +08:00
Kevin Sawicki
b6b6fc3bfd Remove All Rights Reserved after GitHub copyright
Closes #762
2014-10-31 11:17:05 -07:00
Cheng Zhao
301014e4a6 win: asar: Support "\" as path separator 2014-09-30 20:12:48 +08:00
Cheng Zhao
885ac53a48 asar: Add support in fs.realpathSync 2014-09-30 14:53:58 +08:00
Cheng Zhao
3c412e1cb8 Fix readdir on a linked directory 2014-09-29 15:23:28 +08:00
Cheng Zhao
cebafeae40 Fix getting file from symbol linked directory. 2014-09-28 22:46:29 +08:00
Cheng Zhao
4006b6407c Just use plain pointer for weak reference. 2014-09-25 20:38:12 +08:00
Cheng Zhao
c95a93ef1c Add a way to copy a file in archive into filesystem. 2014-09-25 16:56:50 +08:00
Cheng Zhao
e5e1e207b6 Also search for app.asar when starting app. 2014-09-24 20:09:41 +08:00
Cheng Zhao
0cab034dab Make fs.readdir support asar package. 2014-09-24 18:44:00 +08:00
Cheng Zhao
fa287c2422 Fix getting information for root. 2014-09-24 13:42:04 +08:00
Cheng Zhao
8199ad2ae6 Add asar.stat method. 2014-09-24 12:02:33 +08:00
Cheng Zhao
b01db4aa09 Send file content in asar:// 2014-09-23 20:30:07 +08:00
Cheng Zhao
6d712da7e3 Read the archive's header when there is a url request 2014-09-23 19:14:30 +08:00