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

Cask: constrain quarantine support status #4866

Merged
merged 1 commit into from
Sep 14, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions Library/Homebrew/cask/cmd/doctor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,7 @@ def check_environment_variables
def check_quarantine_support
ohai "Gatekeeper support"

status = Quarantine.check_quarantine_support

case status
case Quarantine.check_quarantine_support
when :quarantine_available
puts "Enabled"
when :no_swift
Expand Down
51 changes: 29 additions & 22 deletions Library/Homebrew/cask/quarantine.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,24 @@ def check_quarantine_support

if swift.nil?
odebug "Swift is not available on this system."
return :no_swift
end

api_check = system_command(swift, args: [QUARANTINE_SCRIPT])
:no_swift
else
api_check = system_command(swift,
args: [QUARANTINE_SCRIPT],
print_stderr: false)

if api_check.exit_status == 5
odebug "This feature requires the macOS 10.10 SDK or higher."
return :no_quarantine
case api_check.exit_status
when 5
odebug "This feature requires the macOS 10.10 SDK or higher."
:no_quarantine
when 2
odebug "Quarantine is available."
:quarantine_available
else
odebug "Unknown support status"
:unknown
end
end

odebug "Quarantine is available."
:quarantine_available
end

def available?
Expand Down Expand Up @@ -73,12 +79,12 @@ def release!(download_path: nil)
odebug "Releasing #{download_path} from quarantine"

quarantiner = system_command("/usr/bin/xattr",
args: [
"-d",
QUARANTINE_ATTRIBUTE,
download_path,
],
print_stderr: false)
args: [
"-d",
QUARANTINE_ATTRIBUTE,
download_path,
],
print_stderr: false)

return if quarantiner.success?

Expand All @@ -93,12 +99,13 @@ def cask!(cask: nil, download_path: nil, action: true)
odebug "Quarantining #{download_path}"

quarantiner = system_command(swift,
args: [
QUARANTINE_SCRIPT,
download_path,
cask.url.to_s,
cask.homepage.to_s,
])
args: [
QUARANTINE_SCRIPT,
download_path,
cask.url.to_s,
cask.homepage.to_s,
],
print_stderr: false)

return if quarantiner.success?

Expand Down