mirror of
https://git.tartarus.org/simon/putty.git
synced 2025-01-10 01:48:00 +00:00
Unix Pageant: support -D, to delete all keys.
This commit is contained in:
parent
e533097e15
commit
c6c23ed84b
36
pageant.c
36
pageant.c
@ -1747,6 +1747,42 @@ int pageant_delete_key(struct pageant_pubkey *key, char **retstr)
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int pageant_delete_all_keys(char **retstr)
|
||||||
|
{
|
||||||
|
unsigned char request[5], *response;
|
||||||
|
int reqlen, resplen, success, ret;
|
||||||
|
void *vresponse;
|
||||||
|
|
||||||
|
PUT_32BIT(request, 1);
|
||||||
|
request[4] = SSH2_AGENTC_REMOVE_ALL_IDENTITIES;
|
||||||
|
reqlen = 5;
|
||||||
|
ret = agent_query(request, reqlen, &vresponse, &resplen, NULL, NULL);
|
||||||
|
assert(ret == 1);
|
||||||
|
response = vresponse;
|
||||||
|
success = (resplen >= 4 && response[4] == SSH_AGENT_SUCCESS);
|
||||||
|
sfree(response);
|
||||||
|
if (!success) {
|
||||||
|
*retstr = dupstr("Agent failed to delete SSH-2 keys");
|
||||||
|
return PAGEANT_ACTION_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
PUT_32BIT(request, 1);
|
||||||
|
request[4] = SSH1_AGENTC_REMOVE_ALL_RSA_IDENTITIES;
|
||||||
|
reqlen = 5;
|
||||||
|
ret = agent_query(request, reqlen, &vresponse, &resplen, NULL, NULL);
|
||||||
|
assert(ret == 1);
|
||||||
|
response = vresponse;
|
||||||
|
success = (resplen >= 4 && response[4] == SSH_AGENT_SUCCESS);
|
||||||
|
sfree(response);
|
||||||
|
if (!success) {
|
||||||
|
*retstr = dupstr("Agent failed to delete SSH-1 keys");
|
||||||
|
return PAGEANT_ACTION_FAILURE;
|
||||||
|
}
|
||||||
|
|
||||||
|
*retstr = NULL;
|
||||||
|
return PAGEANT_ACTION_OK;
|
||||||
|
}
|
||||||
|
|
||||||
struct pageant_pubkey *pageant_pubkey_copy(struct pageant_pubkey *key)
|
struct pageant_pubkey *pageant_pubkey_copy(struct pageant_pubkey *key)
|
||||||
{
|
{
|
||||||
struct pageant_pubkey *ret = snew(struct pageant_pubkey);
|
struct pageant_pubkey *ret = snew(struct pageant_pubkey);
|
||||||
|
@ -140,3 +140,4 @@ typedef void (*pageant_key_enum_fn_t)(void *ctx,
|
|||||||
int pageant_enum_keys(pageant_key_enum_fn_t callback, void *callback_ctx,
|
int pageant_enum_keys(pageant_key_enum_fn_t callback, void *callback_ctx,
|
||||||
char **retstr);
|
char **retstr);
|
||||||
int pageant_delete_key(struct pageant_pubkey *key, char **retstr);
|
int pageant_delete_key(struct pageant_pubkey *key, char **retstr);
|
||||||
|
int pageant_delete_all_keys(char **retstr);
|
||||||
|
@ -593,8 +593,11 @@ void run_client(void)
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case KEYACT_CLIENT_DEL_ALL:
|
case KEYACT_CLIENT_DEL_ALL:
|
||||||
fprintf(stderr, "NYI\n");
|
if (pageant_delete_all_keys(&retstr) == PAGEANT_ACTION_FAILURE) {
|
||||||
errors = TRUE;
|
fprintf(stderr, "pageant: deleting all keys: %s\n", retstr);
|
||||||
|
sfree(retstr);
|
||||||
|
errors = TRUE;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
assert(0 && "Invalid client action found");
|
assert(0 && "Invalid client action found");
|
||||||
|
Loading…
Reference in New Issue
Block a user