[Security] Fix not being able to change the authorization prompt (#3612)
When asking for user credentials it was not possible to change the default authorization prompt message so the application name is used by default. When running an application with Mono this will be mono-sgen64 or mono-sgen32. The prompt is now added to the environment authorization item set passed to AuthorizationCreate. It was being passed as part of the rights item set. This allows a custom message to be set in the authorization dialog.
This commit is contained in:
Родитель
de15337f61
Коммит
78e966d7ee
|
@ -172,17 +172,16 @@ namespace Security {
|
|||
unsafe {
|
||||
if (parameters != null){
|
||||
ppars = &pars;
|
||||
pars.ptrToAuthorization = (AuthorizationItem *) Marshal.AllocHGlobal (sizeof (AuthorizationItem) * 3);
|
||||
pars.ptrToAuthorization = (AuthorizationItem *) Marshal.AllocHGlobal (sizeof (AuthorizationItem) * 2);
|
||||
if (parameters.PathToSystemPrivilegeTool != null)
|
||||
EncodeString (ref pars.ptrToAuthorization [pars.count++], "system.privilege.admin", parameters.PathToSystemPrivilegeTool);
|
||||
if (parameters.Prompt != null)
|
||||
EncodeString (ref pars.ptrToAuthorization [pars.count++], "prompt", parameters.Prompt);
|
||||
if (parameters.IconPath != null)
|
||||
EncodeString (ref pars.ptrToAuthorization [pars.count++], "prompt", parameters.IconPath);
|
||||
}
|
||||
if (environment != null){
|
||||
if (environment != null || (parameters != null && parameters.Prompt != null)){
|
||||
penv = &env;
|
||||
env.ptrToAuthorization = (AuthorizationItem *) Marshal.AllocHGlobal (sizeof (AuthorizationItem) * 3);
|
||||
env.ptrToAuthorization = (AuthorizationItem *) Marshal.AllocHGlobal (sizeof (AuthorizationItem) * 4);
|
||||
if (environment != null){
|
||||
if (environment.Username != null)
|
||||
EncodeString (ref env.ptrToAuthorization [env.count++], "username", environment.Username);
|
||||
if (environment.Password != null)
|
||||
|
@ -190,6 +189,11 @@ namespace Security {
|
|||
if (environment.AddToSharedCredentialPool)
|
||||
EncodeString (ref env.ptrToAuthorization [env.count++], "shared", null);
|
||||
}
|
||||
if (parameters != null){
|
||||
if (parameters.Prompt != null)
|
||||
EncodeString (ref env.ptrToAuthorization [env.count++], "prompt", parameters.Prompt);
|
||||
}
|
||||
}
|
||||
code = AuthorizationCreate (ppars, penv, flags, out auth);
|
||||
if (code != 0)
|
||||
return null;
|
||||
|
|
Загрузка…
Ссылка в новой задаче