From 78c06cc3949bd1f2f33e94320a353f9f545410a1 Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Tue, 1 Aug 2023 12:30:48 -0300 Subject: [PATCH 1/2] Fixes wrong error message when running as root in sandbox mode When running as root the error reported is misleading: There are no available ports between 8000 and 9000 for debugging This commit fixes this and reports the proper (new) error RunningAsRootWithoutNoSandbox: You need to set the sandbox(false) option when running as root --- src/browser/process.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/browser/process.rs b/src/browser/process.rs index dfff8600..4bfb2c20 100644 --- a/src/browser/process.rs +++ b/src/browser/process.rs @@ -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)] @@ -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/.*)$")?; @@ -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()); } From 788b84baed4c799d7cf82e909631f15cef24e0ef Mon Sep 17 00:00:00 2001 From: Felipe Coury Date: Sun, 8 Oct 2023 20:44:08 -0300 Subject: [PATCH 2/2] Fixes cargo check error for a mut where not needed --- src/browser/process.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/browser/process.rs b/src/browser/process.rs index 4bfb2c20..c732a030 100644 --- a/src/browser/process.rs +++ b/src/browser/process.rs @@ -273,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 {