summaryrefslogtreecommitdiff
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
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@
-rw-r--r--ChangeLog9
-rw-r--r--ssh-keygen.c40
2 files changed, 39 insertions, 10 deletions
diff --git a/ChangeLog b/ChangeLog
index 3bc8c4bd3..0cde74e8e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,10 @@
120060326
2 - OpenBSD CVS Sync
3 - jakob@cvs.openbsd.org 2006/03/15 08:46:44
4 [ssh-keygen.c]
5 if no key file are given when printing the DNS host record, use the
6 host key file(s) as default. ok djm@
7
120060325 820060325
2 - OpenBSD CVS Sync 9 - OpenBSD CVS Sync
3 - djm@cvs.openbsd.org 2006/03/16 04:24:42 10 - djm@cvs.openbsd.org 2006/03/16 04:24:42
@@ -4254,4 +4261,4 @@
4254 - (djm) Trim deprecated options from INSTALL. Mention UsePAM 4261 - (djm) Trim deprecated options from INSTALL. Mention UsePAM
4255 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu 4262 - (djm) Fix quote handling in sftp; Patch from admorten AT umich.edu
4256 4263
4257$Id: ChangeLog,v 1.4241 2006/03/25 13:11:46 djm Exp $ 4264$Id: ChangeLog,v 1.4242 2006/03/26 02:48:01 djm Exp $
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