diff --git a/pageant.c b/pageant.c index e3928cdec..2bb1c8f55 100644 --- a/pageant.c +++ b/pageant.c @@ -1747,6 +1747,42 @@ int pageant_delete_key(struct pageant_pubkey *key, char **retstr) 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 *ret = snew(struct pageant_pubkey); diff --git a/pageant.h b/pageant.h index 451fe7e59..6e29f40c1 100644 --- a/pageant.h +++ b/pageant.h @@ -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, char **retstr); int pageant_delete_key(struct pageant_pubkey *key, char **retstr); +int pageant_delete_all_keys(char **retstr); diff --git a/unix/uxpgnt.c b/unix/uxpgnt.c index 4a46b657d..c9036eedb 100644 --- a/unix/uxpgnt.c +++ b/unix/uxpgnt.c @@ -593,8 +593,11 @@ void run_client(void) } break; case KEYACT_CLIENT_DEL_ALL: - fprintf(stderr, "NYI\n"); - errors = TRUE; + if (pageant_delete_all_keys(&retstr) == PAGEANT_ACTION_FAILURE) { + fprintf(stderr, "pageant: deleting all keys: %s\n", retstr); + sfree(retstr); + errors = TRUE; + } break; default: assert(0 && "Invalid client action found");