mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-07-01 19:42:48 -05:00
Polish up passphrase prompts for key decryption.
Now Windows Pageant has two clearly distinct dialog boxes for requesting a key passphrase: one to use synchronously when the user has just used the 'Add Key' GUI action, and one to use asynchronously in response to an agent client's attempt to use a key that was loaded encrypted. Also fixed the wording in the asynchronous box: there were two copies of the 'enter passphrase' instruction, one from the dialog definition in pageant.rc file and one from the cross-platform pageant.c. Now pageant.c doesn't format a whole user-facing message any more: it leaves that to the platform front end to do it the way it wants. I've also added a call to SetForegroundWindow, to try to get the passphrase prompt into the foreground. In my experience this doesn't actually get it the keyboard focus, which I think is deliberate on Windows's part and there's nothing I can do about it. But at least the user should _see_ that the prompt is there, so they can focus it themself.
This commit is contained in:
@ -103,24 +103,34 @@ static int make_pipe_to_askpass(const char *msg)
|
||||
}
|
||||
|
||||
static bool uxpgnt_ask_passphrase(
|
||||
PageantListenerClient *plc, PageantClientDialogId *dlgid, const char *msg)
|
||||
PageantListenerClient *plc, PageantClientDialogId *dlgid,
|
||||
const char *comment)
|
||||
{
|
||||
struct uxpgnt_client *upc = container_of(plc, struct uxpgnt_client, plc);
|
||||
|
||||
assert(!upc->dlgid); /* Pageant core should be serialising requests */
|
||||
|
||||
char *msg = dupprintf(
|
||||
"A client of Pageant wants to use the following encrypted key:\n"
|
||||
"%s\n"
|
||||
"If you intended this, enter the passphrase to decrypt the key.",
|
||||
comment);
|
||||
|
||||
switch (upc->prompt_type) {
|
||||
case RTPROMPT_UNAVAILABLE:
|
||||
sfree(msg);
|
||||
return false;
|
||||
|
||||
case RTPROMPT_GUI:
|
||||
upc->passphrase_fd = make_pipe_to_askpass(msg);
|
||||
sfree(msg);
|
||||
if (upc->passphrase_fd < 0)
|
||||
return false; /* something went wrong */
|
||||
break;
|
||||
|
||||
case RTPROMPT_DEBUG:
|
||||
fprintf(upc->logfp, "pageant passphrase request: %s\n", msg);
|
||||
sfree(msg);
|
||||
break;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user