[TCC]ユーザーTCC.dbの値の操作(削除)
ユーザー環境のtcc.db
"$HOME/Library/Application Support/com.apple.TCC/TCC.db"
設定された値を削除して
アプリケーションのセキュリティ設定を初期化する
※あくまでもユーザー環境のみ
ダウンロード - deleteusertccaccess.scpt.zip
#!/usr/bin/env osascript
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
#
#選択したアプリケーションの
#ユーザーTCCdbの値を削除します。
#
#
# com.cocolog-nifty.quicktimer.icefloe
----+----1----+----2----+-----3----+----4----+----5----+----6----+----7
use AppleScript version "2.8"
use framework "Foundation"
use scripting additions
property strUTI : ""
set aliasFile to (choose file with prompt "アプリケーションを選択してください" default location (path to applications folder from user domain) of type {"com.apple.application-bundle"} with invisibles without multiple selections allowed and showing package contents) as alias
tell application "Finder"
set objInfo to info for aliasFile
set strUTI to bundle identifier of objInfo as text
set thisAppPath to alias of objInfo
set strAppName to name of objInfo as text
end tell
set strAppName to doReplace(strAppName, ".app", "")
tell application "Finder"
try
tell application id "" & strUTI & "" to quit
tell application thisAppPath to quit
on error
try
do shell script "killall \"" & strAppName & "\""
end try
end try
end tell
set aliasHOME to (path to home folder from user domain) as alias
set strHOME to POSIX path of aliasHOME as text
set strUserTCC to "" & strHOME & "Library/Application Support/com.apple.TCC/TCC.db" as text
set listUserTCCcolumn to {"kTCCServiceSystemPolicyDocumentsFolder", "kTCCServiceSystemPolicyDownloadsFolder", "kTCCServiceSystemPolicyDesktopFolder", "kTCCServiceSystemPolicyNetworkVolumes", "kTCCServiceSystemPolicyRemovableVolumes", "kTCCServiceFileProviderDomain", "kTCCServiceMediaLibrary", "kTCCServicePhotosAdd", "kTCCServicePhotos", "kTCCServiceAppleEvents", "kTCCServiceFocusStatus", "kTCCServiceUserAvailability", "kTCCServiceListenEvent", "kTCCServiceSpeechRecognition", "kTCCServiceBluetoothAlways", "kTCCServiceCamera", "kTCCServiceUbiquity", "kTCCServiceLiverpool", "kTCCServiceReminders", "kTCCServiceCalendar", "kTCCServiceAddressBook", "kTCCServiceMicrophone"}
set numCntTCCcolumn to (count of listUserTCCcolumn) as number
##まずは個別の項目を削除してから
repeat with strUserTCCcolumnName in listUserTCCcolumn
set strCommandText to "/usr/bin/sqlite3 \"" & strUserTCC & "\" \"DELETE FROM access WHERE client = '" & strUTI & "' AND service = '" & strUserTCCcolumnName & "';\""
do shell script strCommandText
set strTccutilResetName to doReplace(strUserTCCcolumnName, "kTCCService", "")
set strCommandText to "/usr/bin/tccutil reset " & strTccutilResetName & " " & strUTI & ""
do shell script strCommandText
end repeat
##まとめて全部消す
set strCommandText to "/usr/bin/sqlite3 \"" & strUserTCC & "\" \"DELETE FROM access WHERE client = '" & strUTI & "';\""
do shell script strCommandText
return
to doReplace(theText, orgStr, newStr)
set oldDelim to AppleScript's text item delimiters
set AppleScript's text item delimiters to orgStr
set tmpList to every text item of theText
set AppleScript's text item delimiters to newStr
set tmpStr to tmpList as text
set AppleScript's text item delimiters to oldDelim
return tmpStr
end doReplace
| 固定リンク
「TCC」カテゴリの記事
- [TCC]サービス名を指定してTCCをリセットする(2023.06.05)
- [TCC]位置情報 locationd とLiverpoolからアプリケーションを指定して削除(2023.06.05)
- [sqlite3]モード (output mode)その1 ファイルに書き出す(2023.06.01)
- [sqlite3]モード (output mode)その2(2023.06.01)
- [TCC]kTCCService(OS13.4)(2023.06.01)