diff options
| author | Xu Cheng | 2015-04-16 21:41:59 +0800 | 
|---|---|---|
| committer | Xu Cheng | 2015-04-17 14:09:24 +0800 | 
| commit | 91111be58cc110b1b75e23399d9275e0bb0bfca4 (patch) | |
| tree | db9b4f22a2a3d0a41df244f4e3a303f136d09aa4 /Library/Homebrew/sandbox.rb | |
| parent | eb5d0c4cb1f486ce152dff67c423500b25fe6450 (diff) | |
| download | homebrew-91111be58cc110b1b75e23399d9275e0bb0bfca4.tar.bz2 | |
sandbox: record log
Closes #38711.
Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/sandbox.rb')
| -rw-r--r-- | Library/Homebrew/sandbox.rb | 17 | 
1 files changed, 17 insertions, 0 deletions
| diff --git a/Library/Homebrew/sandbox.rb b/Library/Homebrew/sandbox.rb index 0fd3055e5..9ad920926 100644 --- a/Library/Homebrew/sandbox.rb +++ b/Library/Homebrew/sandbox.rb @@ -12,6 +12,10 @@ class Sandbox      @profile = SandboxProfile.new    end +  def record_log(file) +    @log = file +  end +    def add_rule(rule)      @profile.add_rule(rule)    end @@ -54,6 +58,7 @@ class Sandbox        seatbelt = Tempfile.new(["homebrew", ".sb"], HOMEBREW_TEMP)        seatbelt.write(@profile.dump)        seatbelt.close +      @start = Time.now        safe_system SANDBOX_EXEC, "-f", seatbelt.path, *args      rescue        if ARGV.verbose? @@ -63,6 +68,18 @@ class Sandbox        raise      ensure        seatbelt.unlink +      unless @log.nil? +        sleep 0.1 # wait for a bit to let syslog catch up the latest events. +        syslog_args = %W[ +          -F '$((Time)(local))\ $(Sender)[$(PID)]:\ $Message' +          -k Time ge #{@start.to_i.to_s} +          -k Sender kernel +          -o +          -k Time ge #{@start.to_i.to_s} +          -k Sender sandboxd +        ] +        quiet_system "syslog #{syslog_args * " "} | grep deny > #{@log}" +      end      end    end | 
