0

SMJobBless 有一个对话框提示,告诉用户它正在安装帮助工具并输入密码以继续。我想更改文本。

以下代码没有更改文本,而是将我的自定义文本放在开头并仍显示默认文本。我错过了什么或做错了什么?

// Creating auth item to bless helper tool and install framework
AuthorizationItem authItem = {kSMRightBlessPrivilegedHelper, 0, NULL, 0};

// Creating a set of authorization rights
AuthorizationRights authRights = {1, &authItem};

NSString *promptText = @"Customized Text. Privilege?\n\n";

AuthorizationItem dialogConfiguration[1] = { kAuthorizationEnvironmentPrompt, [promptText length], (char *) [promptText UTF8String], 0 };

AuthorizationEnvironment authorizationEnvironment = { 0 };
authorizationEnvironment.items = dialogConfiguration;
authorizationEnvironment.count = 1;

// Specifying authorization options for authorization
AuthorizationFlags flags = kAuthorizationFlagDefaults | kAuthorizationFlagInteractionAllowed | kAuthorizationFlagExtendRights;

// Open dialog and prompt user for password
OSStatus status = AuthorizationCreate(&authRights, &authorizationEnvironment, flags, authRef);`
4

1 回答 1

1

使用 kAuthorizationRightExecute 而不是 kSMRightBlessPrivilegedHelper 会得到一个短文本,它只要求输入密码。使用 kAuthorizationEnvironmentPrompt 作为环境可以在提示的开头添加额外的文本。

于 2014-01-16T08:45:50.510 回答