- djm@cvs.openbsd.org 2010/06/22 04:32:06

[ssh-keygen.c]
     standardise error messages when attempting to open private key
     files to include "progname: filename: error reason"
     bz#1783; ok dtucker@
This commit is contained in:
Damien Miller 2010-06-26 09:39:07 +10:00
parent ab6de35140
commit ba3420acd2
2 changed files with 70 additions and 69 deletions

View File

@ -31,6 +31,11 @@
AuthorizedKeysFile AuthorizedPrincipalsFile AuthorizedKeysFile AuthorizedPrincipalsFile
HostbasedUsesNameFromPacketOnly PermitTunnel HostbasedUsesNameFromPacketOnly PermitTunnel
bz#1764; feedback from imorgan AT nas.nasa.gov; ok dtucker@ bz#1764; feedback from imorgan AT nas.nasa.gov; ok dtucker@
- djm@cvs.openbsd.org 2010/06/22 04:32:06
[ssh-keygen.c]
standardise error messages when attempting to open private key
files to include "progname: filename: error reason"
bz#1783; ok dtucker@
20100622 20100622
- (djm) [loginrec.c] crank LINFO_NAMESIZE (username length) to 512 - (djm) [loginrec.c] crank LINFO_NAMESIZE (username length) to 512

View File

@ -1,4 +1,4 @@
/* $OpenBSD: ssh-keygen.c,v 1.190 2010/05/20 23:46:02 djm Exp $ */ /* $OpenBSD: ssh-keygen.c,v 1.191 2010/06/22 04:32:06 djm Exp $ */
/* /*
* Author: Tatu Ylonen <ylo@cs.hut.fi> * Author: Tatu Ylonen <ylo@cs.hut.fi>
* Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland * Copyright (c) 1994 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
@ -414,11 +414,8 @@ do_convert_from_ssh2(struct passwd *pw)
perror(identity_file); perror(identity_file);
exit(1); exit(1);
} }
fp = fopen(identity_file, "r"); if ((fp = fopen(identity_file, "r")) == NULL)
if (fp == NULL) { fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
perror(identity_file);
exit(1);
}
encoded[0] = '\0'; encoded[0] = '\0';
while ((blen = get_line(fp, line, sizeof(line))) != -1) { while ((blen = get_line(fp, line, sizeof(line))) != -1) {
if (line[blen - 1] == '\\') if (line[blen - 1] == '\\')
@ -561,8 +558,9 @@ do_fingerprint(struct passwd *pw)
comment = NULL; comment = NULL;
} }
f = fopen(identity_file, "r"); if ((f = fopen(identity_file, "r")) == NULL)
if (f != NULL) { fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
while (fgets(line, sizeof(line), f)) { while (fgets(line, sizeof(line), f)) {
if ((cp = strchr(line, '\n')) == NULL) { if ((cp = strchr(line, '\n')) == NULL) {
error("line %d too long: %.40s...", error("line %d too long: %.40s...",
@ -621,7 +619,7 @@ do_fingerprint(struct passwd *pw)
invalid = 0; invalid = 0;
} }
fclose(f); fclose(f);
}
if (invalid) { if (invalid) {
printf("%s is not a public key file.\n", identity_file); printf("%s is not a public key file.\n", identity_file);
exit(1); exit(1);
@ -676,7 +674,7 @@ do_known_hosts(struct passwd *pw, const char *name)
have_identity = 1; have_identity = 1;
} }
if ((in = fopen(identity_file, "r")) == NULL) if ((in = fopen(identity_file, "r")) == NULL)
fatal("fopen: %s", strerror(errno)); fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
/* /*
* Find hosts goes to stdout, hash and deletions happen in-place * Find hosts goes to stdout, hash and deletions happen in-place
@ -1423,10 +1421,8 @@ do_show_cert(struct passwd *pw)
if (!have_identity) if (!have_identity)
ask_filename(pw, "Enter file in which the key is"); ask_filename(pw, "Enter file in which the key is");
if (stat(identity_file, &st) < 0) { if (stat(identity_file, &st) < 0)
perror(identity_file); fatal("%s: %s: %s", __progname, identity_file, strerror(errno));
exit(1);
}
if ((key = key_load_public(identity_file, NULL)) == NULL) if ((key = key_load_public(identity_file, NULL)) == NULL)
fatal("%s is not a public key", identity_file); fatal("%s is not a public key", identity_file);
if (!key_is_cert(key)) if (!key_is_cert(key))