From e6b3fa64843851ff142d270df293c72ee3c5c0f5 Mon Sep 17 00:00:00 2001 From: Mark Jerde Date: Sun, 23 Jan 2022 21:43:23 -0600 Subject: [PATCH] Add script to adjust App Sandboxing settings --- configureAppSandboxing.sh | 44 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100755 configureAppSandboxing.sh diff --git a/configureAppSandboxing.sh b/configureAppSandboxing.sh new file mode 100755 index 0000000..0908a3f --- /dev/null +++ b/configureAppSandboxing.sh @@ -0,0 +1,44 @@ +#!/bin/bash + +appSandboxing=false +defineSandboxing=false + +if [ "$1" == "YES" ] +then + appSandboxing=true + defineSandboxing=false +elif [ "$1" == "NO" ] +then + appSandboxing=false + defineSandboxing=false +elif [ "$1" == "SANDBOXING" ] +then + appSandboxing=true + defineSandboxing=true +else + echo "Run with parameter YES or NO to enable or disable app sandboxing." + echo "Or with parameter SANDBOXING to enable or app sandboxing and define SANDBOXING" + echo " in the prefix header." + exit -1 +fi + +if [ "$defineSandboxing" == "true" ] +then + sed -i '' 's|^//\(#define SANDBOXING\) *$|\1|' Flycut_Prefix.pch + git add Flycut_Prefix.pch +else + sed -i '' 's|^\(#define SANDBOXING\) *$|//\1|' Flycut_Prefix.pch + git add Flycut_Prefix.pch +fi + +for key in com.apple.security.app-sandbox com.apple.security.files.user-selected.read-write +do + for entitlements in $(git grep -l -e ">$key<") + do + /usr/libexec/PlistBuddy -c "Set :$key $appSandboxing" "$entitlements" + git add "$entitlements" + done +done + +git commit -m "App Sandbox $(if [ "$appSandboxing" == "true" ] ; then echo "ON" ; else echo "OFF" ; fi)$(if [ "$defineSandboxing" == "true" ] ; then echo " with define" ; fi)" +