Skip to content

Commit

Permalink
devops: remove warnings when running under root without sandbox (#3749)
Browse files Browse the repository at this point in the history
As discussed offline, our testing scenarios assume running trusted
web content - so this warning is just a noise for this usecases.

When it comes to dealing with untrusted web content though, automation
authors need to make sure to not launch browsers under root in the first
place.
  • Loading branch information
aslushnikov authored Sep 3, 2020
1 parent 2d46cd8 commit 7671e8e
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 6 deletions.
4 changes: 1 addition & 3 deletions src/server/chromium/chromium.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,8 @@ export class Chromium extends BrowserTypeBase {
if (browserArguments.indexOf('--no-sandbox') !== -1)
return browserArguments;
const runningAsRoot = process.geteuid && process.geteuid() === 0;
if (runningAsRoot) {
console.warn('WARNING: Playwright is being run under "root" user - disabling Chromium sandbox! Run under regular user to get rid of this warning.');
if (runningAsRoot)
return ['--no-sandbox', ...browserArguments];
}
return browserArguments;
}

Expand Down
4 changes: 1 addition & 3 deletions src/server/electron/electron.ts
Original file line number Diff line number Diff line change
Expand Up @@ -153,10 +153,8 @@ export class Electron {

if (os.platform() === 'linux') {
const runningAsRoot = process.geteuid && process.geteuid() === 0;
if (runningAsRoot && electronArguments.indexOf('--no-sandbox') === -1) {
console.warn('WARNING: Playwright is being run under "root" user - disabling Electron sandbox! Run under regular user to get rid of this warning.');
if (runningAsRoot && electronArguments.indexOf('--no-sandbox') === -1)
electronArguments.push('--no-sandbox');
}
}

const { launchedProcess, gracefullyClose, kill } = await launchProcess({
Expand Down

0 comments on commit 7671e8e

Please sign in to comment.