version 1.461, 2022/12/04 23:50:49 |
version 1.463, 2023/02/28 08:45:24 |
|
|
unlink(tmp); |
unlink(tmp); |
fatal("fdopen: %s", strerror(oerrno)); |
fatal("fdopen: %s", strerror(oerrno)); |
} |
} |
fchmod(fd, sb.st_mode & 0644); |
(void)fchmod(fd, sb.st_mode & 0644); |
inplace = 1; |
inplace = 1; |
} |
} |
/* XXX support identity_file == "-" for stdin */ |
/* XXX support identity_file == "-" for stdin */ |
|
|
*/ |
*/ |
static int |
static int |
do_print_resource_record(struct passwd *pw, char *fname, char *hname, |
do_print_resource_record(struct passwd *pw, char *fname, char *hname, |
int print_generic) |
int print_generic, char * const *opts, size_t nopts) |
{ |
{ |
struct sshkey *public; |
struct sshkey *public; |
char *comment = NULL; |
char *comment = NULL; |
struct stat st; |
struct stat st; |
int r; |
int r, hash = -1; |
|
size_t i; |
|
|
|
for (i = 0; i < nopts; i++) { |
|
if (strncasecmp(opts[i], "hashalg=", 8) == 0) { |
|
if ((hash = ssh_digest_alg_by_name(opts[i] + 8)) == -1) |
|
fatal("Unsupported hash algorithm"); |
|
} else { |
|
error("Invalid option \"%s\"", opts[i]); |
|
return SSH_ERR_INVALID_ARGUMENT; |
|
} |
|
} |
if (fname == NULL) |
if (fname == NULL) |
fatal_f("no filename"); |
fatal_f("no filename"); |
if (stat(fname, &st) == -1) { |
if (stat(fname, &st) == -1) { |
|
|
} |
} |
if ((r = sshkey_load_public(fname, &public, &comment)) != 0) |
if ((r = sshkey_load_public(fname, &public, &comment)) != 0) |
fatal_r(r, "Failed to read v2 public key from \"%s\"", fname); |
fatal_r(r, "Failed to read v2 public key from \"%s\"", fname); |
export_dns_rr(hname, public, stdout, print_generic); |
export_dns_rr(hname, public, stdout, print_generic, hash); |
sshkey_free(public); |
sshkey_free(public); |
free(comment); |
free(comment); |
return 1; |
return 1; |
|
|
|
|
if (have_identity) { |
if (have_identity) { |
n = do_print_resource_record(pw, identity_file, |
n = do_print_resource_record(pw, identity_file, |
rr_hostname, print_generic); |
rr_hostname, print_generic, opts, nopts); |
if (n == 0) |
if (n == 0) |
fatal("%s: %s", identity_file, strerror(errno)); |
fatal("%s: %s", identity_file, strerror(errno)); |
exit(0); |
exit(0); |
|
|
|
|
n += do_print_resource_record(pw, |
n += do_print_resource_record(pw, |
_PATH_HOST_RSA_KEY_FILE, rr_hostname, |
_PATH_HOST_RSA_KEY_FILE, rr_hostname, |
print_generic); |
print_generic, opts, nopts); |
n += do_print_resource_record(pw, |
n += do_print_resource_record(pw, |
_PATH_HOST_DSA_KEY_FILE, rr_hostname, |
_PATH_HOST_DSA_KEY_FILE, rr_hostname, |
print_generic); |
print_generic, opts, nopts); |
n += do_print_resource_record(pw, |
n += do_print_resource_record(pw, |
_PATH_HOST_ECDSA_KEY_FILE, rr_hostname, |
_PATH_HOST_ECDSA_KEY_FILE, rr_hostname, |
print_generic); |
print_generic, opts, nopts); |
n += do_print_resource_record(pw, |
n += do_print_resource_record(pw, |
_PATH_HOST_ED25519_KEY_FILE, rr_hostname, |
_PATH_HOST_ED25519_KEY_FILE, rr_hostname, |
print_generic); |
print_generic, opts, nopts); |
n += do_print_resource_record(pw, |
n += do_print_resource_record(pw, |
_PATH_HOST_XMSS_KEY_FILE, rr_hostname, |
_PATH_HOST_XMSS_KEY_FILE, rr_hostname, |
print_generic); |
print_generic, opts, nopts); |
if (n == 0) |
if (n == 0) |
fatal("no keys found."); |
fatal("no keys found."); |
exit(0); |
exit(0); |