[英]How Write on /Library/Fonts folder on Mac with SMJobBless function
我尝试使用SMJobBless函数进行身份验证,因为我的应用程序可以在/ Library / Fonts上写但不能正常工作,
if (![self blessHelperWithLabel:@"com.apple.bsd.SMJobBlessHelper" error:&error]) {
NSLog(@"Something went wrong! %@ / %d", [error domain], (int) [error code]);
} else {
//Access to this point.
/* At this point, the job is available. However, this is a very
* simple sample, and there is no IPC infrastructure set up to
* make it launch-on-demand. You would normally achieve this by
* using XPC (via a MachServices dictionary in your launchd.plist).
*/
NSLog(@"Job is available!");
bool result = false;
result = [[NSFileManager defaultManager] isWritableFileAtPath:@"/Library/Fonts"];
[self->_textField setHidden:false];
}
我的应用程序打印“作业可用”,但是当我检查授权机构在/ Library / Fonts上书写时,结果为false
请告诉我原因并解决。
SMJobBless的想法是特权功能与主应用程序分离,并在帮助程序中运行。
因此,就示例代码而言,您只是在使用助手应用程序来测试身份验证,实际上,您应该执行特权任务,检查是否可以从助手应用程序写入路径,因为助手应用程序是提供特权访问。
然后,如果要写入fonts文件夹,则特权助手应用程序应该执行此操作,而不是主应用程序。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.