From ade942b6d651c51a0e2e7edea0fe7f76cc0275e2 Mon Sep 17 00:00:00 2001 From: Michael Buckley Date: Sat, 14 Dec 2013 21:57:55 -0800 Subject: [PATCH] Add authorize and deauthorize commands to frank CLI, to grant and revoke access to the OS X accessibility API for Mac apps --- gem/lib/frank-cucumber/cli.rb | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/gem/lib/frank-cucumber/cli.rb b/gem/lib/frank-cucumber/cli.rb index 02d7928..2d67dfb 100644 --- a/gem/lib/frank-cucumber/cli.rb +++ b/gem/lib/frank-cucumber/cli.rb @@ -222,6 +222,18 @@ def console end end + desc "authorize", "Permanently authorize your frankified app, and all apps with the same bundle identifier, to use the Mac accessibility API on 10.9 or later. Requires administrator privileges." + def authorize + bundle_id = get_mac_bundle_id + run %Q|sudo sqlite3 /Library/Application\\ Support/com.apple.TCC/TCC.db "INSERT or REPLACE INTO access values ('kTCCServiceAccessibility', '#{bundle_id}', 0, 1, 0, NULL);"| + end + + desc "deauthorize", "Remove authorization for your frankified app, and all apps with the same bundle identifier, to use the Mac accessibility API on 10.9 or later. Requires administrator privileges." + def deauthorize + bundle_id = get_mac_bundle_id + run %Q|sudo sqlite3 /Library/Application\\ Support/com.apple.TCC/TCC.db "DELETE FROM access WHERE client = '#{bundle_id}'"| + end + private def product_name @@ -285,6 +297,10 @@ def gather_plugins end end + def get_mac_bundle_id + bundle_id = `/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' Frank/frankified_build/Frankified.app/Contents/Info.plist`.chomp + end + end end