-
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsandboxhelper.js
36 lines (33 loc) · 1.11 KB
/
sandboxhelper.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
'use strict'
const fs = require('fs-extra')
const path = require('path')
/**
* Returns the path to chrome-sandbox if it exists, undefined otherwise.
*/
async function sandboxHelperPath (appDir) {
const helperPath = path.join(appDir, 'chrome-sandbox')
if (await fs.pathExists(helperPath)) {
return helperPath
}
}
module.exports = {
hasSandboxHelper: async function hasSandboxHelper (appDir) {
return typeof (await sandboxHelperPath(appDir)) !== 'undefined'
},
/**
* For Electron versions that support the setuid sandbox on Linux, changes the permissions of
* the `chrome-sandbox` executable as appropriate.
*
* The sandbox helper executable must have the setuid (`+s` / `0o4000`) bit set.
*
* This doesn't work on Windows because you can't set that bit there.
*
* See: https://github.com/electron/electron/pull/17269#issuecomment-470671914
*/
updateSandboxHelperPermissions: async function updateSandboxHelperPermissions (appDir) {
const helperPath = await sandboxHelperPath(appDir)
if (typeof helperPath !== 'undefined') {
return fs.chmod(helperPath, 0o4755)
}
}
}