【macOS】macOS重置应用程序隐私权限(TCC.db)

✨macOS应用程序隐私权限

当前macOS版本:12.4

由于 macOS 13 对设置界面进行了较大修改,本文目前确认适用于macOS 12


查看应用程序权限

打开 设置 -> 安全性与隐私 -> 隐私

许多软件都需要授予辅助功能权限


修改应用程序权限

部分分类权限支持直接修改

点击🔒

解锁后可通过 + - 管理相应的应用程序权限


但是部分分类权限并没有 + -

无法在设置直接修改应用程序权限

此时需要借助tccutil命令行工具


✨macOS TCC

TCC(透明度、同意和控制)是 macOS 中的一种机制,通常从隐私角度限制和控制应用程序对某些功能的访问。这可以包括定位服务、联系人、照片、麦克风、相机、可访问性、全盘访问等等。TCC 是随 OSX Mavericks 一起引入的,并且自那以后经历了许多变化以扩大它的控制范围。TCC 似乎也存在并在 iOS 上提供相同的功能,但在这篇文章中,我们将只关注 macOS 上的 TCC。


TCC 是一种最终用户保护功能,当您尝试在没有用户交互的情况下以自动方式配置机器时,往往会妨碍您。RainforestQA 服务的一部分是我们在保持最新的新 VM 中运行所有测试,为此,我们希望尽可能多地自动化 VM 构建过程,并且我们不想照看构建弹出对话框时单击“允许”的过程。相反,我们宁愿有一种可靠的方式来操纵 TCC 以编程方式授予访问权限,而无需人工干预。TCC 没有很好的文档记录,您可以在其中找到的信息分散在网络上,具有不同程度的完整性。


从用户的角度来看,当应用程序想要访问受 TCC 保护的功能之一时,他们会看到 TCC 正在发挥作用。发生这种情况时,系统会提示用户一个对话框,询问他们是否要允许访问。然后将该响应存储在 TCC 数据库中。


更多介绍可参考:

https://www.rainforestqa.com/blog/macos-tcc-db-deep-dive


✨tccutil

使用man tccutil即可查看tccutil命令手册

tccutil(1)                   General Commands Manual                  tccutil(1)

NAME
     tccutil – manage the privacy database

SYNOPSIS
     tccutil command service [bundle_id]

DESCRIPTION
     The tccutil command manages the privacy database, which stores decisions
     the user has made about whether apps may access personal data.

     One command is currently supported:

     reset    Reset all decisions for the specified service, causing apps to
              prompt again the next time they access the service. If a bundle
              identifier is specified, the service will be reset for that bundle
              only.

EXAMPLES
     To reset all decisions about whether apps may access the address book:

           tccutil reset AddressBook
           tccutil reset All com.apple.Terminal

或者可使用 Onyx

在 实用工具 -> 手册中查阅到tccutil使用说明

或者直接使用搜索引擎

tccutil(1)                   General Commands Manual                  tccutil(1)

NAME
     tccutil - manage the privacy database

SYNOPSIS
     tccutil command service [bundle_id]

DESCRIPTION
     The tccutil command manages the privacy database, which stores decisions
     the user has made about whether apps may access personal data.

     One command is currently supported:

     reset    Reset all decisions for the specified service, causing apps to
              prompt again the next time they access the service. If a bundle
              identifier is specified, the service will be reset for that bundle
              only.

EXAMPLES
     To reset all decisions about whether apps may access the address book:

           tccutil reset AddressBook
           tccutil reset All com.apple.Terminal

Darwin                            April 3, 2012                           Darwin

✨重置特定应用程序所有权限

tccutil reset service [bundleIdentifier]

要重置特定应用程序

我们先要获取到 bundleIdentifier

mdls -name kMDItemCFBundleIdentifier -r /Applications/${Example.app}

-r 后的具体Application可以直接从Finder直接拖入Terminal

之后运行如下命令可以重置该应用程序所有权限

tccutil reset All ${bundleIdentifier}

例如如下命令可以重置 DaisyDisk 所申请的所有权限(包括上述无法在设置重置的权限)

➜  ~ mdls -name kMDItemCFBundleIdentifier -r /Applications/DaisyDisk.app
com.daisydiskapp.DaisyDiskStandAlone%
➜  ~ tccutil reset All com.daisydiskapp.DaisyDiskStandAlone
Successfully reset All approval status for com.daisydiskapp.DaisyDiskStandAlone
➜  ~


✨重置特定权限

运行如下命令可展示可修改的权限条目

也许不完全正确 没有找到相应的官方文档


适用于 Catalina

strings /System/Library/PrivateFrameworks/TCC.framework/TCC | fgrep kTCCService | fgrep -v ' ' | sed -e s/kTCCService// | sort

适用于 Monterey

strings /System/Library/PrivateFrameworks/TCC.framework/Support/tccd | fgrep kTCCService | fgrep -v ' ' | sed -e s/kTCCService// | sort

在 macOS 12.4 上返回如下条目

➜  ~ strings /System/Library/PrivateFrameworks/TCC.framework/Support/tccd | fgrep kTCCService | fgrep -v ' ' | sed -e s/kTCCService// | sort

Accessibility
AddressBook
All
AlwaysAllowedService.AppleEvents
AppleEvents
BluetoothAlways
BluetoothPeripheral
BluetoothWhileInUse
Calendar
Calls
Camera
ContactsFull
ContactsLimited
DeveloperTool
ExposureNotification
ExposureNotificationRegion
FaceID
Facebook
FallDetection
FileProviderDomain
FileProviderPresence
FocusStatus
GameCenterFriends
KeyboardNetwork
LinkedIn
ListenEvent
Liverpool
MSO
MediaLibrary
Microphone
Motion
NearbyInteraction
Photos
PhotosAdd
PostEvent
Prototype3Rights
Prototype4Rights
Reminders
ScreenCapture
SensorKitAmbientLightSensor
SensorKitBedSensing
SensorKitBedSensingWriting
SensorKitDeviceUsage
SensorKitElevation
SensorKitFacialMetrics
SensorKitForegroundAppCategory
SensorKitKeyboardMetrics
SensorKitLocationMetrics
SensorKitMessageUsage
SensorKitMotion
SensorKitMotionHeartRate
SensorKitOdometer
SensorKitPedometer
SensorKitPhoneUsage
SensorKitSoundDetection
SensorKitSpeechMetrics
SensorKitStrideCalibration
SensorKitWatchAmbientLightSensor
SensorKitWatchFallStats
SensorKitWatchForegroundAppCategory
SensorKitWatchHeartRate
SensorKitWatchMotion
SensorKitWatchOnWristState
SensorKitWatchPedometer
SensorKitWatchSpeechMetrics
ShareKit
SinaWeibo
Siri
SpeechRecognition
SystemPolicyAllFiles
SystemPolicyDesktopFolder
SystemPolicyDeveloperFiles
SystemPolicyDocumentsFolder
SystemPolicyDownloadsFolder
SystemPolicyNetworkVolumes
SystemPolicyRemovableVolumes
SystemPolicySysAdminFiles
TencentWeibo
Twitter
Ubiquity
UserAvailability
UserTracking
WebKitIntelligentTrackingPrevention
Willow

可用如上替换tccutil reset All ${bundleIdentifier}命令中的“All”


例如使用如下命令可以重置隐私权限中的 “自动化”

tccutil reset AppleEvents

但是有些条目看起来似乎不像是某特定权限

也许不太靠谱

因此请谨慎使用


✨重置所有应用程序的所有权限

谨慎使用!

谨慎使用!

谨慎使用!

tccutil reset All

✨参考及引用

https://www.rainforestqa.com/blog/macos-tcc-db-deep-dive

https://apple.stackexchange.com/questions/377531/removing-randomwhere-malwareleadingsignsearch-from-security-privacy-fu/

https://recoursive.com/2020/03/03/reset_macos_privacy_permissions/


⭐转载请注明出处

本文作者:双份浓缩馥芮白

原文链接:https://www.cnblogs.com/Flat-White/p/16448648.html

版权所有,如需转载请注明出处。

posted @ 2022-07-05 21:12  双份浓缩馥芮白  阅读(3977)  评论(0编辑  收藏  举报