diff --git a/Library/Homebrew/cask/cask.rb b/Library/Homebrew/cask/cask.rb index f0f5e3b392..a8312cb86d 100644 --- a/Library/Homebrew/cask/cask.rb +++ b/Library/Homebrew/cask/cask.rb @@ -135,7 +135,6 @@ module Cask "depends_on" => depends_on, "conflicts_with" => conflicts_with.to_a, "container" => container, - "accessibility_access" => accessibility_access, "auto_updates" => auto_updates, } end diff --git a/Library/Homebrew/cask/cmd/upgrade.rb b/Library/Homebrew/cask/cmd/upgrade.rb index 33d9d6380f..021ff4d06f 100644 --- a/Library/Homebrew/cask/cmd/upgrade.rb +++ b/Library/Homebrew/cask/cmd/upgrade.rb @@ -83,8 +83,6 @@ module Cask new_cask_installer.install_artifacts new_artifacts_installed = true - new_cask_installer.enable_accessibility_access - # If successful, wipe the old Cask from staging old_cask_installer.finalize_upgrade rescue CaskError => e diff --git a/Library/Homebrew/cask/dsl.rb b/Library/Homebrew/cask/dsl.rb index 5cfb108abe..45ce56be56 100644 --- a/Library/Homebrew/cask/dsl.rb +++ b/Library/Homebrew/cask/dsl.rb @@ -54,7 +54,6 @@ module Cask ].freeze DSL_METHODS = Set.new [ - :accessibility_access, :appcast, :artifacts, :auto_updates, @@ -251,10 +250,6 @@ module Cask @caveats end - def accessibility_access(accessibility_access = nil) - set_unique_stanza(:accessibility_access, accessibility_access.nil?) { accessibility_access } - end - def auto_updates(auto_updates = nil) set_unique_stanza(:auto_updates, auto_updates.nil?) { auto_updates } end diff --git a/Library/Homebrew/cask/installer.rb b/Library/Homebrew/cask/installer.rb index 176a8fe57e..6bed3edc12 100644 --- a/Library/Homebrew/cask/installer.rb +++ b/Library/Homebrew/cask/installer.rb @@ -94,7 +94,6 @@ module Cask opoo "macOS's Gatekeeper has been disabled for this Cask" unless quarantine? stage install_artifacts - enable_accessibility_access unless @cask.tap&.private? ::Utils::Analytics.report_event("cask_install", @cask.token) @@ -365,67 +364,6 @@ module Cask self.class.print_caveats(@cask) end - # TODO: logically could be in a separate class - def enable_accessibility_access - return unless @cask.accessibility_access - - ohai "Enabling accessibility access" - if MacOS.version <= :mountain_lion - @command.run!( - "/usr/bin/touch", - args: [MacOS.pre_mavericks_accessibility_dotfile], - sudo: true, - ) - elsif MacOS.version <= :yosemite - @command.run!( - "/usr/bin/sqlite3", - args: [ - MacOS.tcc_db, - "INSERT OR REPLACE INTO access " \ - "VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL);", - ], - sudo: true, - ) - elsif MacOS.version <= :el_capitan - @command.run!( - "/usr/bin/sqlite3", - args: [ - MacOS.tcc_db, - "INSERT OR REPLACE INTO access " \ - "VALUES('kTCCServiceAccessibility','#{bundle_identifier}',0,1,1,NULL,NULL);", - ], - sudo: true, - ) - else - opoo <<~EOS - Accessibility access cannot be enabled automatically on this version of macOS. - See System Preferences to enable it manually. - EOS - end - rescue => e - purge_versioned_files - raise e - end - - def disable_accessibility_access - return unless @cask.accessibility_access - - if MacOS.version >= :mavericks && MacOS.version <= :el_capitan - ohai "Disabling accessibility access" - @command.run!("/usr/bin/sqlite3", - args: [ - MacOS.tcc_db, - "DELETE FROM access WHERE client='#{bundle_identifier}';", - ], - sudo: true) - else - opoo <<~EOS - Accessibility access cannot be disabled automatically on this version of macOS. - See System Preferences to disable it manually. - EOS - end - end - def save_caskfile old_savedir = @cask.metadata_timestamped_path @@ -438,7 +376,6 @@ module Cask def uninstall oh1 "Uninstalling Cask #{Formatter.identifier(@cask)}" - disable_accessibility_access uninstall_artifacts(clear: true) purge_versioned_files purge_caskroom_path if force? @@ -447,7 +384,6 @@ module Cask def start_upgrade oh1 "Starting upgrade for Cask #{Formatter.identifier(@cask)}" - disable_accessibility_access uninstall_artifacts backup end @@ -471,7 +407,6 @@ module Cask opoo "Reverting upgrade for Cask #{@cask}" restore_backup install_artifacts - enable_accessibility_access end def finalize_upgrade diff --git a/Library/Homebrew/compat/cask/dsl.rb b/Library/Homebrew/compat/cask/dsl.rb index dbfe42ffb9..114b6d83bc 100644 --- a/Library/Homebrew/compat/cask/dsl.rb +++ b/Library/Homebrew/compat/cask/dsl.rb @@ -8,6 +8,10 @@ module Cask def license(*) odisabled "the `license` stanza" end + + def accessibility_access(*) + odeprecated "the `accessibility_access` stanza" + end end prepend Compat diff --git a/Library/Homebrew/test/cask/accessibility_spec.rb b/Library/Homebrew/test/cask/accessibility_spec.rb deleted file mode 100644 index e8b0df2820..0000000000 --- a/Library/Homebrew/test/cask/accessibility_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -# TODO: this test should be named after the corresponding class, once -# that class is abstracted from installer.rb. -describe "Accessibility Access", :cask do - let(:cask) { Cask::CaskLoader.load(cask_path("with-accessibility-access")) } - let(:fake_system_command) { class_double(SystemCommand) } - let(:installer) { Cask::Installer.new(cask, command: fake_system_command) } - - before do - allow(MacOS).to receive(:version).and_return(MacOS::Version.new(macos_version)) - allow(installer).to receive(:bundle_identifier).and_return("com.example.BasicCask") - end - - context "on MacOS 10.8 and below" do - let(:macos_version) { "10.8" } - - it "can enable accessibility access in macOS releases prior to Mavericks" do - expect(fake_system_command).to receive(:run!).with( - "/usr/bin/touch", - args: [MacOS.pre_mavericks_accessibility_dotfile], - sudo: true, - ) - - installer.enable_accessibility_access - end - - it "warns about disabling accessibility access on old macOS releases" do - expect { - installer.disable_accessibility_access - }.to output( - /Warning: Accessibility access cannot be disabled automatically on this version of macOS\./, - ).to_stderr - end - end - - context "on MacOS 10.9" do - let(:macos_version) { "10.9" } - - it "can enable accessibility access" do - expect(fake_system_command).to receive(:run!).with( - "/usr/bin/sqlite3", - args: [ - MacOS.tcc_db, - "INSERT OR REPLACE INTO access VALUES('kTCCServiceAccessibility','com.example.BasicCask',0,1,1,NULL);", - ], - sudo: true, - ) - - installer.enable_accessibility_access - end - - it "can disable accessibility access" do - expect(fake_system_command).to receive(:run!).with( - "/usr/bin/sqlite3", - args: [MacOS.tcc_db, "DELETE FROM access WHERE client='com.example.BasicCask';"], - sudo: true, - ) - - installer.disable_accessibility_access - end - end - - context "on MacOS 10.12 and above" do - let(:macos_version) { "10.12" } - - it "warns about enabling accessibility access on new macOS releases" do - expect { - expect { - installer.enable_accessibility_access - }.to output.to_stdout - }.to output( - /Warning: Accessibility access cannot be enabled automatically on this version of macOS\./, - ).to_stderr - end - - it "warns about disabling accessibility access on new macOS releases" do - expect { - installer.disable_accessibility_access - }.to output( - /Warning: Accessibility access cannot be disabled automatically on this version of macOS\./, - ).to_stderr - end - end -end diff --git a/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb b/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb deleted file mode 100644 index b0517badef..0000000000 --- a/Library/Homebrew/test/support/fixtures/cask/Casks/with-accessibility-access.rb +++ /dev/null @@ -1,11 +0,0 @@ -cask 'with-accessibility-access' do - version '1.2.3' - sha256 '8c62a2b791cf5f0da6066a0a4b6e85f62949cd60975da062df44adf887f4370b' - - url 'https://example.com/TestCask.dmg' - homepage 'https://example.com/' - - accessibility_access true - - app 'TestCask.app' -end