Cask: constrain quarantine support status
Quarantine is available ONLY if the script exits with '2'. It is definitely NOT available if Swift doesn't exist or if it exits with '5' (incompatible SDK). All other cases are from now on treated as unsupported. Also print to standard error only when explictly required (via an exception).
This commit is contained in:
parent
76b41ba3f7
commit
123dda09f0
@ -120,9 +120,7 @@ module Cask
|
||||
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
|
||||
|
||||
@ -17,18 +17,24 @@ module Cask
|
||||
|
||||
if swift.nil?
|
||||
odebug "Swift is not available on this system."
|
||||
return :no_swift
|
||||
:no_swift
|
||||
else
|
||||
api_check = system_command(swift,
|
||||
args: [QUARANTINE_SCRIPT],
|
||||
print_stderr: false)
|
||||
|
||||
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
|
||||
|
||||
api_check = system_command(swift, args: [QUARANTINE_SCRIPT])
|
||||
|
||||
if api_check.exit_status == 5
|
||||
odebug "This feature requires the macOS 10.10 SDK or higher."
|
||||
return :no_quarantine
|
||||
end
|
||||
|
||||
odebug "Quarantine is available."
|
||||
:quarantine_available
|
||||
end
|
||||
|
||||
def available?
|
||||
@ -73,12 +79,12 @@ module Cask
|
||||
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?
|
||||
|
||||
@ -93,12 +99,13 @@ module Cask
|
||||
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?
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user