SMJobBless - 有关何时要求管理员密码的文档
我似乎找不到任何相关文档,所以希望有人可以确认我在 Apple 示例中看到的行为 SMJobBless 代码。
我的印象是,如果它检测到需要安装新版本的帮助工具,它只会要求输入管理员密码。
然而,这种印象显然是错误的。
我在 10.6 下看到的行为是,如果我第一次启动该应用程序,它会要求输入密码。如果我几乎立即启动,它就不会。但是,如果我等待足够长的时间,它会再次要求输入密码。在这整个过程中,辅助工具并没有改变。
任何人都可以指出将其定义为正确行为的文档吗?
I cannot seem to locate any documentation on this, so hopefully someone can confirm the behavior I am seeing with Apple's sample SMJobBless code.
I was under the impression that it would only ask for an admin password if it detected a that a new version of the helper tool needed to be installed.
However, this impression is apparently incorrect.
The behavior I am seeing under 10.6 is that if I launch the app for the first time, it will ask for the password. If I launch almost immediately, it won't. However, if I wait a long enough time, it will ask for the password again. During all of this, the helper tool does not change.
Can anyone point to documentation that defines this as the correct behavior?
如果有人感兴趣,这(可能)被证明是一个错误并且已经被提交。 rdar://10280469
目前系统的工作方式是,无论SMJobBless功能是否需要安装帮助工具,每次都会要求输入管理员密码。该错误(可能)是,如果不需要安装帮助工具(例如,它已经安装并且与应用程序包中的版本相同),则不应发出管理员密码请求。
因此,这意味着需要在调用 SMJobBless 之前确定是否需要安装辅助工具,并且只有在已知需要安装辅助工具时才应调用 SMJobBless。
就我而言,我只需要检查是否安装了该工具(SMJobCopyDictionary 处理此问题),如果安装了该工具,则检查其版本是否比我的应用程序包中的工具版本旧。
下面是一些(不完整)代码,用于检查该工具是否已安装以及版本是什么。
还有另一种方法可以对帮助工具进行版本检查,即帮助工具接收对其版本的请求并发送回版本回复。就我个人而言,我喜欢下面的方法,但想提一下这个替代方案,因为在某些情况下它可能是最佳路径。
If anyone is interested, this (probably) turned out to be a bug and one has been filed. rdar://10280469
The way the system currently works is that it will ask for an admin password every time regardless of whether or not the SMJobBless function needs to install the helper tool or not. The bug is (probably) that a admin password request should not be made if the helper tool does not need to be installed (for example, it is already installed and has the same version as the one in the app bundle).
So, what this means is that the determination of whether or not the helper tool needs to be installed needs to be made before a call to SMJobBless and SMJobBless should only be called if it is already known the helper tool needs to be installed.
In my case, I only need to check whether the tool is installed (SMJobCopyDictionary handles this) and, if the tool is installed, whether or not it's version is older then the version of the tool in my app bundle.
Some (incomplete) code to check whether the tool is installed and what the versions are is below.
There is another alternative to do a version check of the helper tool which is for the helper tool to receive a request for it's version and for it to send a version reply back. Personally, I like the method below, but wanted to mention this alternative as it may be the best path in some situations.