From 6a340438f846ccd165350c7c6786cb4059014029 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Fri, 23 Aug 2024 15:21:19 +0200 Subject: [PATCH] coin: Add kTCCServiceScreenCapture permission to ssh/bootstrap-agent The screen capture permission might be useful for Qt Multimedia, and also allows us to do screen capturing of the state of the VM in case of test failures. For macOS 15 we need to work around the monthly nagging that an app has permission to capture the screen, otherwise this popup may interfere with test runs. Change-Id: I0398488c78b19a85ba527b780b264e0b915b6024 Reviewed-by: Ville-Pekka Karhu (cherry picked from commit 3a5f7bb8d834ad78cfe81b3484b7c22c4caab43d) Reviewed-by: Qt Cherry-pick Bot --- .../common/macos/set_tcc_permissions.sh | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/coin/provisioning/common/macos/set_tcc_permissions.sh b/coin/provisioning/common/macos/set_tcc_permissions.sh index 116263fa..fa9994d5 100755 --- a/coin/provisioning/common/macos/set_tcc_permissions.sh +++ b/coin/provisioning/common/macos/set_tcc_permissions.sh @@ -36,6 +36,11 @@ SERVICES+=("kTCCServiceMicrophone|$HOME") # Qt Connectivity tests need Bluetooth access SERVICES+=("kTCCServiceBluetoothAlways|$HOME") +# Qt Multimedia might need screen capture, and it can +# also be useful for capturing the state of the VM when +# a test fails. +SERVICES+=("kTCCServiceScreenCapture|/") + # ------ Implementation ------ function add_permission_for_client() { @@ -81,6 +86,21 @@ function add_permission_for_client() { 0 -- flags ); EOF + + if [[ "$service" == "kTCCServiceScreenCapture" ]]; then + # macOS 15 will nag the user every month about applications + # that are permitted to capture the screen. We don't want this + # popup to come in the way of tests, so we manually extend + # the permission. + replayd_dir="$HOME/Library/Group Containers/group.com.apple.replayd" + mkdir -p "$replayd_dir" + approvals_file="$replayd_dir/ScreenCaptureApprovals.plist" + if [[ ! -f $approvals_file ]]; then + plutil -create xml1 "$approvals_file" + fi + key=${executable//\./\\.} + plutil -replace "$key" -date "2100-01-01T00:00:00Z" "$approvals_file" + fi } # shellcheck disable=SC2043