auto disable sandbox for interactive shell
Closes Homebrew/homebrew#38792. Signed-off-by: Xu Cheng <xucheng@me.com>
This commit is contained in:
parent
895983fed5
commit
8cebb64eec
@ -15,8 +15,12 @@ module Homebrew
|
|||||||
#{formula.path}
|
#{formula.path}
|
||||||
].concat(ARGV.options_only)
|
].concat(ARGV.options_only)
|
||||||
|
|
||||||
|
if Sandbox.available? && ARGV.sandbox? && Sandbox.auto_disable?
|
||||||
|
Sandbox.print_autodisable_warning
|
||||||
|
end
|
||||||
|
|
||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox? && !Sandbox.auto_disable?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
formula.logs.mkpath
|
formula.logs.mkpath
|
||||||
sandbox.record_log(formula.logs/"sandbox.postinstall.log")
|
sandbox.record_log(formula.logs/"sandbox.postinstall.log")
|
||||||
|
@ -35,8 +35,12 @@ module Homebrew
|
|||||||
#{f.path}
|
#{f.path}
|
||||||
].concat(ARGV.options_only)
|
].concat(ARGV.options_only)
|
||||||
|
|
||||||
|
if Sandbox.available? && ARGV.sandbox? && Sandbox.auto_disable?
|
||||||
|
Sandbox.print_autodisable_warning
|
||||||
|
end
|
||||||
|
|
||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox? && !Sandbox.auto_disable?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
f.logs.mkpath
|
f.logs.mkpath
|
||||||
sandbox.record_log(f.logs/"sandbox.test.log")
|
sandbox.record_log(f.logs/"sandbox.test.log")
|
||||||
|
@ -486,8 +486,12 @@ class FormulaInstaller
|
|||||||
#{formula.path}
|
#{formula.path}
|
||||||
].concat(build_argv)
|
].concat(build_argv)
|
||||||
|
|
||||||
|
if Sandbox.available? && ARGV.sandbox? && Sandbox.auto_disable?
|
||||||
|
Sandbox.print_autodisable_warning
|
||||||
|
end
|
||||||
|
|
||||||
Utils.safe_fork do
|
Utils.safe_fork do
|
||||||
if Sandbox.available? && ARGV.sandbox?
|
if Sandbox.available? && ARGV.sandbox? && !Sandbox.auto_disable?
|
||||||
sandbox = Sandbox.new
|
sandbox = Sandbox.new
|
||||||
formula.logs.mkpath
|
formula.logs.mkpath
|
||||||
sandbox.record_log(formula.logs/"sandbox.build.log")
|
sandbox.record_log(formula.logs/"sandbox.build.log")
|
||||||
|
@ -8,6 +8,18 @@ class Sandbox
|
|||||||
OS.mac? && File.executable?(SANDBOX_EXEC)
|
OS.mac? && File.executable?(SANDBOX_EXEC)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
# there are times the sandbox cannot be used.
|
||||||
|
def self.auto_disable?
|
||||||
|
@auto_disable ||= ARGV.interactive? || ARGV.debug?
|
||||||
|
end
|
||||||
|
|
||||||
|
def self.print_autodisable_warning
|
||||||
|
unless @print_autodisable_warning
|
||||||
|
opoo "The sandbox cannot be used in debug or interactive mode."
|
||||||
|
@print_autodisable_warning = true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def initialize
|
def initialize
|
||||||
@profile = SandboxProfile.new
|
@profile = SandboxProfile.new
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user