Apple 脚本中的 Shell 脚本需要终端具有完全磁盘访问权限 - 但它已经具有完全磁盘访问权限

问题描述 投票:0回答:1

我正在制作一个 Apple Script 应用程序,它将更改我的时间机器备份配置。 Apple 脚本命令很简单:

set ThePath to quoted form of "/Users/AndrewDesktop/Documents/AppleScripts/Time Machine Control Scripts/Do Not Backup iTunes Library.sh"`
--do shell script "bash " & ThePath with administrator privileges

现在我的所有 shell 命令都已注释。即使如此,当我运行苹果脚本时,系统会提示我输入密码,然后出现错误:

error "bash: /Users/AndrewDesktop/Documents/AppleScripts/Time Machine Control Scripts/Do Not Backup iTunes Library.sh: Operation not permitted" number 126

由于所有 shell 命令都已注释,我不一定需要管理员权限。当我在没有管理员权限的情况下运行相同的 Apple 脚本命令时:

set ThePath to quoted form of "/Users/AndrewDesktop/Documents/AppleScripts/Time Machine Control Scripts/Do Not Backup iTunes Library.sh"
do shell script "bash " & ThePath

我没有收到错误。

我决定避免使用单独的 shell 文件,并尝试在苹果脚本中输入每个排除作为其自己的 do shell 脚本命令,如下所示:

do shell script "sudo tmutil addexclusion -v /Volumes/iTunes Library" with administrator privileges

但是即使这种蛮力方法也失败了,因为我遇到了令人发狂的错误:

error "tmutil: addexclusion requires Full Disk Access privileges.
To allow this operation, select Full Disk Access in the Privacy
tab of the Security & Privacy preference pane, and add Terminal
to the list of applications which are allowed Full Disk Access." number 80

终端已经具有完整的磁盘访问权限,脚本编辑器也是如此!即便如此,我还是禁用并重新启用了两个骰子的完整磁盘访问,并且没有骰子。

知道如何获得root权限来工作吗?

.sh 终端的 Ls -l 仅产生:

-rwx------@ 1

编辑: Red dance 这里有一个关于

with administrator privileges
和 sudo 的技术说明:TN2065。那里的注释似乎说,当使用具有管理员权限的苹果脚本时, sudo 是不必要的。但是更改我的 shell 脚本以删除 sudo 不起作用。

我只需要能够从需要 sudo 权限的苹果脚本运行 tmutil add/removeexclusion 。我该怎么做?

macos terminal applescript admin privileges
1个回答
0
投票

看来保存苹果脚本和shell脚本的文档文件夹都受到保护。当我将两个脚本移至 user/Andrew 时,错误就消失了。我不知道如何让它在文档文件夹中工作,但移到其他地方确实有效。

© www.soinside.com 2019 - 2024. All rights reserved.