version 1.271, 2015/04/27 01:52:30 |
version 1.272, 2015/05/21 12:01:19 |
|
|
known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx) |
known_hosts_find_delete(struct hostkey_foreach_line *l, void *_ctx) |
{ |
{ |
struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx; |
struct known_hosts_ctx *ctx = (struct known_hosts_ctx *)_ctx; |
|
enum sshkey_fp_rep rep; |
|
int fptype; |
|
char *fp; |
|
|
|
fptype = print_bubblebabble ? SSH_DIGEST_SHA1 : fingerprint_hash; |
|
rep = print_bubblebabble ? SSH_FP_BUBBLEBABBLE : SSH_FP_DEFAULT; |
|
|
if (l->status == HKF_STATUS_MATCHED) { |
if (l->status == HKF_STATUS_MATCHED) { |
if (delete_host) { |
if (delete_host) { |
if (l->marker != MRK_NONE) { |
if (l->marker != MRK_NONE) { |
|
|
} |
} |
if (hash_hosts) |
if (hash_hosts) |
known_hosts_hash(l, ctx); |
known_hosts_hash(l, ctx); |
else |
else if (print_fingerprint) { |
|
fp = sshkey_fingerprint(l->key, fptype, rep); |
|
printf("%s %s %s %s\n", ctx->host, |
|
sshkey_type(l->key), fp, l->comment); |
|
free(fp); |
|
} else |
fprintf(ctx->out, "%s\n", l->line); |
fprintf(ctx->out, "%s\n", l->line); |
return 0; |
return 0; |
} |
} |
|
|
char *cp, tmp[PATH_MAX], old[PATH_MAX]; |
char *cp, tmp[PATH_MAX], old[PATH_MAX]; |
int r, fd, oerrno, inplace = 0; |
int r, fd, oerrno, inplace = 0; |
struct known_hosts_ctx ctx; |
struct known_hosts_ctx ctx; |
|
u_int foreach_options; |
|
|
if (!have_identity) { |
if (!have_identity) { |
cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid); |
cp = tilde_expand_filename(_PATH_SSH_USER_HOSTFILE, pw->pw_uid); |
|
|
} |
} |
|
|
/* XXX support identity_file == "-" for stdin */ |
/* XXX support identity_file == "-" for stdin */ |
|
foreach_options = find_host ? HKF_WANT_MATCH : 0; |
|
foreach_options |= print_fingerprint ? HKF_WANT_PARSE_KEY : 0; |
if ((r = hostkeys_foreach(identity_file, |
if ((r = hostkeys_foreach(identity_file, |
hash_hosts ? known_hosts_hash : known_hosts_find_delete, &ctx, |
hash_hosts ? known_hosts_hash : known_hosts_find_delete, &ctx, |
name, NULL, find_host ? HKF_WANT_MATCH : 0)) != 0) |
name, NULL, foreach_options)) != 0) |
fatal("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r)); |
fatal("%s: hostkeys_foreach failed: %s", __func__, ssh_err(r)); |
|
|
if (inplace) |
if (inplace) |