簡體   English   中英

如何使用SMJobBless功能在Mac上的/ Library / Fonts文件夾中寫入

[英]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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM