小编Sah*_*ini的帖子

如何为我的 OSX 应用程序添加 Root 权限?

我以 root 用户身份创建了一个应用程序,它运行良好(在 root 用户中)。当我与标准用户尝试相同的应用程序时,它没有解决。然后我知道我需要 root 权限才能运行应用程序。我谷歌了几天,但没有得到它。我已经阅读了一些问题和苹果文档。哪个是-

https://developer.apple.com/library/mac/documentation/Security/Conceptual/authorization_concepts/01introduction/introduction.html

如何将我的应用程序设置为始终以 root OSX 身份运行

如何以编程方式获得root权限?

如何在root权限下运行应用程序?

但我仍然没有得到任何东西。我要知道的另一件事是我需要创建一个新项目才能获得 root 权限,对吗?任何你能告诉我的对我有帮助的都请去做。每一个建议都是最受欢迎的。

现在我正在尝试这个-

- (BOOL) runProcessAsAdministrator:(NSString*)scriptPath
                     withArguments:(NSArray *)arguments
                            output:(NSString **)output
                   errorDescription:(NSString **)errorDescription {

    NSString * allArgs = [arguments componentsJoinedByString:@" "];
    NSString * fullScript = [NSString stringWithFormat:@"'%@' %@",  scriptPath, allArgs];

    NSDictionary *errorInfo = [NSDictionary new];
    NSString *script =  [NSString stringWithFormat:@"do shell script \"%@\" with administrator privileges", fullScript];

    NSAppleScript *appleScript = [[NSAppleScript new] initWithSource:script];
    NSAppleEventDescriptor * eventResult = [appleScript executeAndReturnError:&errorInfo];

// Check errorInfo
    if (! eventResult)
    { …
Run Code Online (Sandbox Code Playgroud)

macos privileges objective-c root

5
推荐指数
1
解决办法
3326
查看次数

标签 统计

macos ×1

objective-c ×1

privileges ×1

root ×1