简体   繁体   English

更改smjobbless对话框的文本kAuthorizationEnvironmentPrompt

[英]Change text of smjobbless dialog kAuthorizationEnvironmentPrompt

SMJobBless has a dialog prompt that tells the user it is installing a helper tool and to type password to proceed. SMJobBless有一个对话框提示,告诉用户正在安装帮助工具并键入密码以继续。 I would like to change the text. 我想更改文本。

Instead of changing the text, the following code puts my custom text at the beginning and still displays the default text. 下面的代码没有更改文本,而是将我的自定义文本放在开头,并且仍显示默认文本。 What am I missing or doing wrong? 我想念什么或做错什么?

// 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);`

使用kAuthorizationRightExecute代替kSMRightBlessPrivilegedHelper将获得仅要求输入密码的短文本。并使用kAuthorizationEnvironmentPrompt,因为环境可以在提示的开头添加其他文本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM