0

我在系统偏好设置中使用了一个 prefpane(带有授权锁)。我需要让我的偏好写入/Library/Preferences。但是,每当我尝试将首选项同步到时,即使我的锁已解锁kCFPreferencesAnyUser,它也会失败。kCFPreferencesCurrentHost有没有办法在/Library/Preferences不创建帮助应用程序的情况下写入我的偏好?我想避免这种情况,因为它是多余的。

请注意,修改“任何用户”首选项需要 root 权限(或 Mac OS X v10.6 之前的管理员权限)—请参阅授权服务编程指南。

我阅读了授权服务编程指南,它甚至没有提到偏好。

4

1 回答 1

1

CFPreferences uses your process's euid to determine what "current user" means. You could possibly set your euid to 0, but that's really not recommended because it means your whole program is now a possible source of privilege escalation attacks if it contains a vulnerability, rather than just a tiny purpose-specific helper. That's bad for your users, and by extension bad for you.

Also, XPC and seteuid() don't always play nice, and CFPreferences uses XPC. Switching from euid 0 to non-0 should work, I believe, but I wouldn't count on the other direction working.

于 2013-01-21T07:20:53.880 回答