fix(BrowserFetcher): ensure executable has proper permissions (#2342)
This patch ensures Chromium executable has permissions to be executed by non-owner users. Fixes #2283.
This commit is contained in:
parent
beea6f9c82
commit
5089d2ec2e
@ -38,6 +38,7 @@ const downloadURLs = {
|
|||||||
const readdirAsync = helper.promisify(fs.readdir.bind(fs));
|
const readdirAsync = helper.promisify(fs.readdir.bind(fs));
|
||||||
const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
|
const mkdirAsync = helper.promisify(fs.mkdir.bind(fs));
|
||||||
const unlinkAsync = helper.promisify(fs.unlink.bind(fs));
|
const unlinkAsync = helper.promisify(fs.unlink.bind(fs));
|
||||||
|
const chmodAsync = helper.promisify(fs.chmod.bind(fs));
|
||||||
|
|
||||||
function existsAsync(filePath) {
|
function existsAsync(filePath) {
|
||||||
let fulfill = null;
|
let fulfill = null;
|
||||||
@ -115,7 +116,10 @@ class BrowserFetcher {
|
|||||||
if (await existsAsync(zipPath))
|
if (await existsAsync(zipPath))
|
||||||
await unlinkAsync(zipPath);
|
await unlinkAsync(zipPath);
|
||||||
}
|
}
|
||||||
return this.revisionInfo(revision);
|
const revisionInfo = this.revisionInfo(revision);
|
||||||
|
if (revisionInfo)
|
||||||
|
await chmodAsync(revisionInfo.executablePath, 0o755);
|
||||||
|
return revisionInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -20,6 +20,7 @@ const path = require('path');
|
|||||||
const {helper} = require('../lib/helper');
|
const {helper} = require('../lib/helper');
|
||||||
const mkdtempAsync = helper.promisify(fs.mkdtemp);
|
const mkdtempAsync = helper.promisify(fs.mkdtemp);
|
||||||
const readFileAsync = helper.promisify(fs.readFile);
|
const readFileAsync = helper.promisify(fs.readFile);
|
||||||
|
const statAsync = helper.promisify(fs.stat);
|
||||||
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
|
const TMP_FOLDER = path.join(os.tmpdir(), 'pptr_tmp_folder-');
|
||||||
const utils = require('./utils');
|
const utils = require('./utils');
|
||||||
|
|
||||||
@ -51,6 +52,8 @@ module.exports.addTests = function({testRunner, expect, PROJECT_ROOT, defaultBro
|
|||||||
revisionInfo = await browserFetcher.download('123456');
|
revisionInfo = await browserFetcher.download('123456');
|
||||||
expect(revisionInfo.local).toBe(true);
|
expect(revisionInfo.local).toBe(true);
|
||||||
expect(await readFileAsync(revisionInfo.executablePath, 'utf8')).toBe('LINUX BINARY\n');
|
expect(await readFileAsync(revisionInfo.executablePath, 'utf8')).toBe('LINUX BINARY\n');
|
||||||
|
const expectedPermissions = os.platform() === 'win32' ? 0666 : 0755;
|
||||||
|
expect((await statAsync(revisionInfo.executablePath)).mode & 0777).toBe(expectedPermissions);
|
||||||
expect(await browserFetcher.localRevisions()).toEqual(['123456']);
|
expect(await browserFetcher.localRevisions()).toEqual(['123456']);
|
||||||
await browserFetcher.remove('123456');
|
await browserFetcher.remove('123456');
|
||||||
expect(await browserFetcher.localRevisions()).toEqual([]);
|
expect(await browserFetcher.localRevisions()).toEqual([]);
|
||||||
|
Loading…
Reference in New Issue
Block a user