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

Fix bug when sysctl is not available #25

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/processor/linux.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,13 @@ class ChromeProcessor::Linux < ChromeProcessor::UNIX

def sanity_check
super
if `sysctl -n kernel.unprivileged_userns_clone`.chomp != "1"
begin
sysctl = `sysctl -n kernel.unprivileged_userns_clone`
rescue Errno::ENOENT
sysctl = ''
end

if sysctl.chomp != "1"
STDERR.puts "[!!!] WARNING: Namespace sandboxes are not available. Please run the following as root to fix:"
STDERR.puts "[!!!] sysctl kernel.unprivileged_userns_clone=1"
STDERR.puts "[!!!] Otherwise, the Chromium sandbox will be disabled."
Expand Down Expand Up @@ -55,10 +61,16 @@ def tweak_install
"--user-data-dir=#{@profiledir}",
]

begin
sysctl = `sysctl -n kernel.unprivileged_userns_clone`
rescue Errno::ENOENT
sysctl = ''
end

if Process.uid == 0
STDERR.puts "WARNING: sandbox disabled due to running as root"
opts.push "--no-sandbox"
elsif `sysctl -n kernel.unprivileged_userns_clone`.chomp != "1"
elsif sysctl.chomp != "1"
STDERR.puts "WARNING: sandbox disabled due to kernel.unprivileged_userns_clone=0"
opts.push "--no-sandbox"
end
Expand Down