summaryrefslogtreecommitdiff
path: root/ssh-keygen.c
diff options
context:
space:
mode:
authorDamien Miller <djm@mindrot.org>2006-03-26 13:48:01 +1100
committerDamien Miller <djm@mindrot.org>2006-03-26 13:48:01 +1100
commitcb314828eb11b3827a096d9b4abcd8d229764a46 (patch)
tree1b570f011d7b35f9f5102905dc70bd9c3a030304 /ssh-keygen.c
parent2dbbf8e9fc058cab975a9bcda21465d34465c92e (diff)
- OpenBSD CVS Sync
- jakob@cvs.openbsd.org 2006/03/15 08:46:44 [ssh-keygen.c] if no key file are given when printing the DNS host record, use the host key file(s) as default. ok djm@
Diffstat (limited to 'ssh-keygen.c')
-rw-r--r--ssh-keygen.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/ssh-keygen.c b/ssh-keygen.c
index c527252b9..126556466 100644
--- a/ssh-keygen.c
+++ b/ssh-keygen.c
@@ -858,30 +858,32 @@ do_change_passphrase(struct passwd *pw)
858/* 858/*
859 * Print the SSHFP RR. 859 * Print the SSHFP RR.
860 */ 860 */
861static void 861static int
862do_print_resource_record(struct passwd *pw, char *hname) 862do_print_resource_record(struct passwd *pw, char *fname, char *hname)
863{ 863{
864 Key *public; 864 Key *public;
865 char *comment = NULL; 865 char *comment = NULL;
866 struct stat st; 866 struct stat st;
867 867
868 if (!have_identity) 868 if (fname == NULL)
869 ask_filename(pw, "Enter file in which the key is"); 869 ask_filename(pw, "Enter file in which the key is");
870 if (stat(identity_file, &st) < 0) { 870 if (stat(fname, &st) < 0) {
871 perror(identity_file); 871 if (errno == ENOENT)
872 return 0;
873 perror(fname);
872 exit(1); 874 exit(1);
873 } 875 }
874 public = key_load_public(identity_file, &comment); 876 public = key_load_public(fname, &comment);
875 if (public != NULL) { 877 if (public != NULL) {
876 export_dns_rr(hname, public, stdout, print_generic); 878 export_dns_rr(hname, public, stdout, print_generic);
877 key_free(public); 879 key_free(public);
878 xfree(comment); 880 xfree(comment);
879 exit(0); 881 return 1;
880 } 882 }
881 if (comment) 883 if (comment)
882 xfree(comment); 884 xfree(comment);
883 885
884 printf("failed to read v2 public key from %s.\n", identity_file); 886 printf("failed to read v2 public key from %s.\n", fname);
885 exit(1); 887 exit(1);
886} 888}
887 889
@@ -1224,7 +1226,27 @@ main(int ac, char **av)
1224 if (print_public) 1226 if (print_public)
1225 do_print_public(pw); 1227 do_print_public(pw);
1226 if (rr_hostname != NULL) { 1228 if (rr_hostname != NULL) {
1227 do_print_resource_record(pw, rr_hostname); 1229 unsigned int n = 0;
1230
1231 if (have_identity) {
1232 n = do_print_resource_record(pw,
1233 identity_file, rr_hostname);
1234 if (n == 0) {
1235 perror(identity_file);
1236 exit(1);
1237 }
1238 exit(0);
1239 } else {
1240
1241 n += do_print_resource_record(pw,
1242 _PATH_HOST_RSA_KEY_FILE, rr_hostname);
1243 n += do_print_resource_record(pw,
1244 _PATH_HOST_DSA_KEY_FILE, rr_hostname);
1245
1246 if (n == 0)
1247 fatal("no keys found.");
1248 exit(0);
1249 }
1228 } 1250 }
1229 if (reader_id != NULL) { 1251 if (reader_id != NULL) {
1230#ifdef SMARTCARD 1252#ifdef SMARTCARD