macOS 12.4 – launchd服务无法访问用户目录中的文件

huangapple go评论81阅读模式
英文:

macOS 12.4 - launchd service unable to access files in users directory

问题

升级到 macOS 12.4 后,我们的 Golang 应用程序在 macOS 上作为服务运行时无法读取用户主目录中的文件,即使该文件对所有用户都可读。该服务以 root 用户身份运行,但仍然出现以下错误:

if error := viper.ReadInConfig(); error != nil {
   // error: open /Users/adnan/Downloads/test371/config.yml: operation not permitted
}

如果我尝试以 sudo ./myserverapp 的方式运行该应用程序,它可以正常工作并能够读取文件,但作为服务运行时却失败。

英文:

After upgrading to macOS 12.4 our Golang app which runs as a service on macOS is unable to read files in the user's home directory. Even when the file is readable for all the users. The service runs as root and we still get the following error:

if error := viper.ReadInConfig(); error != nil {
   // error: open /Users/adnan/Downloads/test371/config.yml: operation not permitted
}

If I try running the app as sudo ./myserverapp it works fine and is able to read the file but fails when run as a service.

答案1

得分: 1

给二进制文件授予“完全磁盘访问权限”后,它就可以正常工作了。有没有其他的替代方法?要求每个客户都这样做似乎有些问题。

英文:

It worked after giving "Full Disk Access" to the binary. Is there any alternative for this? Asking each of our customers to do that seems problematic.

huangapple
  • 本文由 发表于 2022年8月28日 19:39:16
  • 转载请务必保留本文链接:https://go.coder-hub.com/73518342.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定