Merge pull request #4684 from sjackman/check-tmpdir-executable

Check that HOMEBREW_TEMP permits executing programs
This commit is contained in:
Shaun Jackman 2018-08-14 12:22:35 -07:00 committed by GitHub
commit 9039e41ebe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -17,6 +17,23 @@ module Homebrew
EOS
end
def check_tmpdir_executable
f = Tempfile.new(%w[homebrew_check_tmpdir_executable .sh], HOMEBREW_TEMP)
f.write "#!/bin/sh\n"
f.chmod 0700
f.close
return if system f.path
<<~EOS.undent
The directory #{HOMEBREW_TEMP} does not permit executing
programs. It is likely mounted as "noexec". Please set HOMEBREW_TEMP
in your #{shell_profile} to a different directory, for example:
export HOMEBREW_TEMP=~/tmp
echo 'export HOMEBREW_TEMP=~/tmp' >> #{shell_profile}
EOS
ensure
f.unlink
end
def check_xdg_data_dirs
return if ENV["XDG_DATA_DIRS"].to_s.empty?
return if ENV["XDG_DATA_DIRS"].split("/").include?(HOMEBREW_PREFIX/"share")