CFPreferences to /Library/Preferences

可紊 提交于 2019-12-04 06:42:22

问题


I have a prefpane used in System Preferences (With the authorization lock). I need to get my preferences to write to /Library/Preferences. However, whenever I try to synchronize the prefs to kCFPreferencesAnyUser and kCFPreferencesCurrentHost it just fails out even if my lock is unlocked. Is there any way to write my preferences to /Library/Preferences without creating a helper application? I would want to avoid that because it's redundant.

Note that to modify “Any User” preferences requires root privileges (or Admin privileges prior to Mac OS X v10.6)—see Authorization Services Programming Guide.

I read the authorization services programming guide and it did not even mention preferences.


回答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.



来源:https://stackoverflow.com/questions/9454957/cfpreferences-to-library-preferences

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!