feat: validate Ubuntu version if launching firefox (#3156)

The original plan was to rnu some checks against libc version the
binary is compiled with, but these turn out to be a little complicated:
parsing out libc version from both static binary and host system
requires text processing, and it's hard to make sure it works reliably
across distributions.

Instead, let's start with a very particular check against running
Firefox on Ubuntu 16.04.

References #2745
This commit is contained in:
Andrey Lushnikov 2020-07-24 16:14:14 -07:00 committed by GitHub
parent 549a37b939
commit d4b707861c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 3 deletions

View File

@ -33,7 +33,7 @@ import * as types from '../types';
import { TimeoutSettings } from '../timeoutSettings';
import { WebSocketServer } from './webSocketServer';
import { LoggerSink } from '../loggerSink';
import { validateDependencies } from './validateDependencies';
import { validateHostRequirements } from './validateDependencies';
type FirefoxPrefsOptions = { firefoxUserPrefs?: { [key: string]: string | number | boolean } };
type LaunchOptions = types.LaunchOptions & { logger?: LoggerSink };
@ -193,7 +193,7 @@ export abstract class BrowserTypeBase implements BrowserType {
if (!executablePath) {
// We can only validate dependencies for bundled browsers.
await validateDependencies(this._browserPath, this._browserDescriptor);
await validateHostRequirements(this._browserPath, this._browserDescriptor);
}
// Note: it is important to define these variables before launchProcess, so that we don't get

View File

@ -26,7 +26,14 @@ const checkExecutable = (filePath: string) => accessAsync(filePath, fs.constants
const statAsync = util.promisify(fs.stat.bind(fs));
const readdirAsync = util.promisify(fs.readdir.bind(fs));
export async function validateDependencies(browserPath: string, browser: BrowserDescriptor) {
export async function validateHostRequirements(browserPath: string, browser: BrowserDescriptor) {
const ubuntuVersion = await getUbuntuVersion();
if (browser.name === 'firefox' && ubuntuVersion === '16.04')
throw new Error(`Cannot launch firefox on Ubuntu 16.04! Minimum required Ubuntu version for Firefox browser is 18.04`);
await validateDependencies(browserPath, browser);
}
async function validateDependencies(browserPath: string, browser: BrowserDescriptor) {
// We currently only support Linux.
if (os.platform() !== 'linux')
return;