|
Lines 90-99
clear_pass(void)
Link Here
|
| 90 |
} |
90 |
} |
| 91 |
|
91 |
|
| 92 |
static int |
92 |
static int |
| 93 |
delete_file(AuthenticationConnection *ac, const char *filename) |
93 |
delete_file(AuthenticationConnection *ac, const char *filename, int key_only) |
| 94 |
{ |
94 |
{ |
| 95 |
Key *public; |
95 |
Key *public = NULL, *cert = NULL; |
| 96 |
char *comment = NULL; |
96 |
char *certpath = NULL, *comment = NULL; |
| 97 |
int ret = -1; |
97 |
int ret = -1; |
| 98 |
|
98 |
|
| 99 |
public = key_load_public(filename, &comment); |
99 |
public = key_load_public(filename, &comment); |
|
Lines 107-114
delete_file(AuthenticationConnection *ac, const char *filename)
Link Here
|
| 107 |
} else |
107 |
} else |
| 108 |
fprintf(stderr, "Could not remove identity: %s\n", filename); |
108 |
fprintf(stderr, "Could not remove identity: %s\n", filename); |
| 109 |
|
109 |
|
| 110 |
key_free(public); |
110 |
if (key_only) |
| 111 |
xfree(comment); |
111 |
goto out; |
|
|
112 |
|
| 113 |
/* Now try to delete the corresponding certificate too */ |
| 114 |
xasprintf(&certpath, "%s-cert.pub", filename); |
| 115 |
if ((cert = key_load_public(certpath, &comment)) == NULL) |
| 116 |
goto out; |
| 117 |
if (!key_equal_public(cert, public)) |
| 118 |
fatal("Certificate %s does not match private key %s", |
| 119 |
certpath, filename); |
| 120 |
|
| 121 |
if (ssh_remove_identity(ac, cert)) { |
| 122 |
fprintf(stderr, "Identity removed: %s (%s)\n", certpath, |
| 123 |
comment); |
| 124 |
ret = 0; |
| 125 |
} else |
| 126 |
fprintf(stderr, "Could not remove identity: %s\n", certpath); |
| 127 |
|
| 128 |
out: |
| 129 |
if (cert != NULL) |
| 130 |
key_free(cert); |
| 131 |
if (public != NULL) |
| 132 |
key_free(public); |
| 133 |
free(certpath); |
| 134 |
free(comment); |
| 112 |
|
135 |
|
| 113 |
return ret; |
136 |
return ret; |
| 114 |
} |
137 |
} |
|
Lines 348-354
static int
Link Here
|
| 348 |
do_file(AuthenticationConnection *ac, int deleting, int key_only, char *file) |
371 |
do_file(AuthenticationConnection *ac, int deleting, int key_only, char *file) |
| 349 |
{ |
372 |
{ |
| 350 |
if (deleting) { |
373 |
if (deleting) { |
| 351 |
if (delete_file(ac, file) == -1) |
374 |
if (delete_file(ac, file, key_only) == -1) |
| 352 |
return -1; |
375 |
return -1; |
| 353 |
} else { |
376 |
} else { |
| 354 |
if (add_file(ac, file, key_only) == -1) |
377 |
if (add_file(ac, file, key_only) == -1) |