Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes wrong error message when running as root in sandbox mode #406

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 8 additions & 1 deletion src/browser/process.rs
Expand Up @@ -50,6 +50,8 @@ enum ChromeLaunchError {
NoAvailablePorts,
#[error("The chosen debugging port is already in use")]
DebugPortInUse,
#[error("You need to set the sandbox(false) option when running as root")]
RunningAsRootWithoutNoSandbox,
}

#[cfg(windows)]
Expand Down Expand Up @@ -271,7 +273,7 @@ impl Process {
attempts += 1;
}

let mut child = process.0.borrow_mut();
let child = process.0.borrow_mut();
child.stderr = None;

Ok(Self {
Expand Down Expand Up @@ -409,6 +411,7 @@ impl Process {
R: Read,
{
let port_taken_re = Regex::new(r"ERROR.*bind\(\)")?;
let root_sandbox = "Running as root without --no-sandbox is not supported";

let re = Regex::new(r"listening on (.*/devtools/browser/.*)$")?;

Expand All @@ -422,6 +425,10 @@ impl Process {
let chrome_output = line?;
trace!("Chrome output: {}", chrome_output);

if chrome_output.contains(root_sandbox) {
return Err(ChromeLaunchError::RunningAsRootWithoutNoSandbox {}.into());
}

if port_taken_re.is_match(&chrome_output) {
return Err(ChromeLaunchError::DebugPortInUse {}.into());
}
Expand Down