本文介绍了CFP对/Library/Preferences的引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在系统偏好设置"(具有授权锁)中使用了一块法兰.我需要获取我的首选项以写入/Library/Preferences.但是,每当我尝试将首选项同步到kCFPreferencesAnyUserkCFPreferencesCurrentHost时,即使我的锁未锁定,它也会失败.有什么方法可以在不创建帮助程序的情况下将我的首选项写入/Library/Preferences?我想避免这种情况,因为它是多余的.

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.

我阅读了授权服务编程指南,甚至没有提到首选项.

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

推荐答案

CFPreferences使用您进程的euid来确定当前用户"的含义.您可以将euid设置为0,但实际上不建议这样做,因为这意味着您的整个程序现在可能是特权升级攻击的来源,如果它包含漏洞,而不仅仅是一个针对特定目的的小漏洞帮手.那对您的用户不利,并且从根本上来说对您不利.

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.

此外,XPC和seteuid()并不总是很好玩,CFPreferences使用XPC.我相信,从euid 0切换到非0应该可以,但是我不会指望其他方向起作用.

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.

这篇关于CFP对/Library/Preferences的引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-27 03:15