英文:
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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论