aboutsummaryrefslogtreecommitdiffstats
path: root/Library/Homebrew/postinstall.rb
diff options
context:
space:
mode:
authorXu Cheng2015-04-13 18:16:27 +0800
committerXu Cheng2015-04-15 19:51:54 +0800
commitd1617e86d0ab3c9ee4742c9be1dd913b50b716fd (patch)
treee23633a0cc11973b419108f0b14444cc9f278534 /Library/Homebrew/postinstall.rb
parentb621edf89dba704f7165fff0f0311f9e0c05bc34 (diff)
downloadbrew-d1617e86d0ab3c9ee4742c9be1dd913b50b716fd.tar.bz2
sandbox postinstall
Closes Homebrew/homebrew#38479. Signed-off-by: Xu Cheng <xucheng@me.com>
Diffstat (limited to 'Library/Homebrew/postinstall.rb')
-rw-r--r--Library/Homebrew/postinstall.rb21
1 files changed, 21 insertions, 0 deletions
diff --git a/Library/Homebrew/postinstall.rb b/Library/Homebrew/postinstall.rb
new file mode 100644
index 000000000..14e578128
--- /dev/null
+++ b/Library/Homebrew/postinstall.rb
@@ -0,0 +1,21 @@
+old_trap = trap("INT") { exit! 130 }
+
+require "global"
+require "debrew"
+require "fcntl"
+require "socket"
+
+begin
+ error_pipe = UNIXSocket.open(ENV["HOMEBREW_ERROR_PIPE"], &:recv_io)
+ error_pipe.fcntl(Fcntl::F_SETFD, Fcntl::FD_CLOEXEC)
+
+ trap("INT", old_trap)
+
+ formula = ARGV.formulae.first
+ formula.extend(Debrew::Formula) if ARGV.debug?
+ formula.run_post_install
+rescue Exception => e
+ Marshal.dump(e, error_pipe)
+ error_pipe.close
+ exit! 1
+end