summaryrefslogtreecommitdiff
path: root/usr.bin
diff options
context:
space:
mode:
authorMarkus Friedl <markus@cvs.openbsd.org>2001-05-28 10:08:56 +0000
committerMarkus Friedl <markus@cvs.openbsd.org>2001-05-28 10:08:56 +0000
commitb81b67229fbe364c8acd34a7cdae55ce003d2d62 (patch)
tree68ebd74c610431b101d18867a5b507a0e0a18d90 /usr.bin
parent102cb65b3e2b4858fe89d331607c0cc0e5969aa5 (diff)
key_load_private: set comment to filename for PEM keys
Diffstat (limited to 'usr.bin')
-rw-r--r--usr.bin/ssh/authfile.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/usr.bin/ssh/authfile.c b/usr.bin/ssh/authfile.c
index d292d5b9fd9..519e4d21cec 100644
--- a/usr.bin/ssh/authfile.c
+++ b/usr.bin/ssh/authfile.c
@@ -36,7 +36,7 @@
*/
#include "includes.h"
-RCSID("$OpenBSD: authfile.c,v 1.33 2001/05/16 20:51:57 markus Exp $");
+RCSID("$OpenBSD: authfile.c,v 1.34 2001/05/28 10:08:55 markus Exp $");
#include <openssl/err.h>
#include <openssl/evp.h>
@@ -540,7 +540,7 @@ Key *
key_load_private(const char *filename, const char *passphrase,
char **commentp)
{
- Key *pub;
+ Key *pub, *prv;
int fd;
fd = open(filename, O_RDONLY);
@@ -555,14 +555,17 @@ key_load_private(const char *filename, const char *passphrase,
lseek(fd, (off_t) 0, SEEK_SET); /* rewind */
if (pub == NULL) {
/* closes fd */
- return key_load_private_pem(fd, KEY_UNSPEC, passphrase,
- commentp);
+ prv = key_load_private_pem(fd, KEY_UNSPEC, passphrase, NULL);
+ /* use the filename as a comment for PEM */
+ if (commentp && prv)
+ commentp = xstrdup(filename);
} else {
/* it's a SSH v1 key if the public key part is readable */
key_free(pub);
/* closes fd */
- return key_load_private_rsa1(fd, filename, passphrase, NULL);
+ prv = key_load_private_rsa1(fd, filename, passphrase, NULL);
}
+ return prv;
}
int