View | Details | Raw Unified | Return to bug 2561 | Differences between
and this patch

Collapse All | Expand All

(-)a/authfile.c (-1 / +2 lines)
Lines 200-206 sshkey_load_private_type(int type, const char *filename, const char *passphrase, Link Here
200
{
200
{
201
	int fd, r;
201
	int fd, r;
202
202
203
	*keyp = NULL;
203
	if (keyp != NULL)
204
		*keyp = NULL;
204
	if (commentp != NULL)
205
	if (commentp != NULL)
205
		*commentp = NULL;
206
		*commentp = NULL;
206
207
(-)a/ssh-keygen.c (-8 / +26 lines)
Lines 979-991 do_gen_all_hostkeys(struct passwd *pw) Link Here
979
#ifdef WITH_SSH1
979
#ifdef WITH_SSH1
980
		{ "rsa1", "RSA1", _PATH_HOST_KEY_FILE },
980
		{ "rsa1", "RSA1", _PATH_HOST_KEY_FILE },
981
#endif /* WITH_SSH1 */
981
#endif /* WITH_SSH1 */
982
		{ "rsa", "RSA" ,_PATH_HOST_RSA_KEY_FILE },
982
		{ "rsa", "RSA" , _PATH_HOST_RSA_KEY_FILE },
983
		{ "dsa", "DSA", _PATH_HOST_DSA_KEY_FILE },
983
		{ "dsa", "DSA", _PATH_HOST_DSA_KEY_FILE },
984
#ifdef OPENSSL_HAS_ECC
984
#ifdef OPENSSL_HAS_ECC
985
		{ "ecdsa", "ECDSA",_PATH_HOST_ECDSA_KEY_FILE },
985
		{ "ecdsa", "ECDSA", _PATH_HOST_ECDSA_KEY_FILE },
986
#endif /* OPENSSL_HAS_ECC */
986
#endif /* OPENSSL_HAS_ECC */
987
#endif /* WITH_OPENSSL */
987
#endif /* WITH_OPENSSL */
988
		{ "ed25519", "ED25519",_PATH_HOST_ED25519_KEY_FILE },
988
		{ "ed25519", "ED25519", _PATH_HOST_ED25519_KEY_FILE },
989
		{ NULL, NULL, NULL }
989
		{ NULL, NULL, NULL }
990
	};
990
	};
991
991
Lines 993-1005 do_gen_all_hostkeys(struct passwd *pw) Link Here
993
	struct stat st;
993
	struct stat st;
994
	struct sshkey *private, *public;
994
	struct sshkey *private, *public;
995
	char comment[1024];
995
	char comment[1024];
996
	int i, type, fd, r;
996
	int prv_fail, i, type, fd, r;
997
	FILE *f;
997
	FILE *f;
998
998
999
	for (i = 0; key_types[i].key_type; i++) {
999
	for (i = 0; key_types[i].key_type; i++) {
1000
		if (stat(key_types[i].path, &st) == 0)
1000
		type = sshkey_type_from_name(key_types[i].key_type);
1001
			continue;
1001
		if (stat(key_types[i].path, &st) == 0) {
1002
		if (errno != ENOENT) {
1002
			/* Check for valid public key */
1003
			prv_fail = 0;
1004
			if ((r = sshkey_load_public(key_types[i].path,
1005
			    NULL, NULL)) == 0) {
1006
				if ((r = sshkey_load_private_type(type,
1007
				    key_types[i].path, NULL, NULL, NULL,
1008
				    NULL)) == 0)
1009
					continue;
1010
			}
1011
			if (r == SSH_ERR_SYSTEM_ERROR) {
1012
				error("Unable to load %s key %s: %s",
1013
				    prv_fail ? "private" : "public",
1014
				    key_types[i].path, ssh_err(r));
1015
				first = 0;
1016
				continue;
1017
			}
1018
			debug("%s: load %s %s: %s", __func__,
1019
			    prv_fail ? "private" : "public",
1020
			    key_types[i].path, ssh_err(r));
1021
		} else if (errno != ENOENT) {
1003
			error("Could not stat %s: %s", key_types[i].path,
1022
			error("Could not stat %s: %s", key_types[i].path,
1004
			    strerror(errno));
1023
			    strerror(errno));
1005
			first = 0;
1024
			first = 0;
Lines 1012-1018 do_gen_all_hostkeys(struct passwd *pw) Link Here
1012
		}
1031
		}
1013
		printf("%s ", key_types[i].key_type_display);
1032
		printf("%s ", key_types[i].key_type_display);
1014
		fflush(stdout);
1033
		fflush(stdout);
1015
		type = sshkey_type_from_name(key_types[i].key_type);
1016
		strlcpy(identity_file, key_types[i].path, sizeof(identity_file));
1034
		strlcpy(identity_file, key_types[i].path, sizeof(identity_file));
1017
		bits = 0;
1035
		bits = 0;
1018
		type_bits_valid(type, NULL, &bits);
1036
		type_bits_valid(type, NULL, &bits);
(-)a/sshkey.c (-7 / +14 lines)
Lines 3657-3663 sshkey_parse_private_rsa1(struct sshbuf *blob, const char *passphrase, Link Here
3657
	const struct sshcipher *cipher;
3657
	const struct sshcipher *cipher;
3658
	struct sshkey *prv = NULL;
3658
	struct sshkey *prv = NULL;
3659
3659
3660
	*keyp = NULL;
3660
	if (keyp != NULL)
3661
		*keyp = NULL;
3661
	if (commentp != NULL)
3662
	if (commentp != NULL)
3662
		*commentp = NULL;
3663
		*commentp = NULL;
3663
3664
Lines 3743-3750 sshkey_parse_private_rsa1(struct sshbuf *blob, const char *passphrase, Link Here
3743
		goto out;
3744
		goto out;
3744
	}
3745
	}
3745
	r = 0;
3746
	r = 0;
3746
	*keyp = prv;
3747
	if (keyp != NULL) {
3747
	prv = NULL;
3748
		*keyp = prv;
3749
		prv = NULL;
3750
	}
3748
	if (commentp != NULL) {
3751
	if (commentp != NULL) {
3749
		*commentp = comment;
3752
		*commentp = comment;
3750
		comment = NULL;
3753
		comment = NULL;
Lines 3769-3775 sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, Link Here
3769
	BIO *bio = NULL;
3772
	BIO *bio = NULL;
3770
	int r;
3773
	int r;
3771
3774
3772
	*keyp = NULL;
3775
	if (keyp != NULL)
3776
		*keyp = NULL;
3773
3777
3774
	if ((bio = BIO_new(BIO_s_mem())) == NULL || sshbuf_len(blob) > INT_MAX)
3778
	if ((bio = BIO_new(BIO_s_mem())) == NULL || sshbuf_len(blob) > INT_MAX)
3775
		return SSH_ERR_ALLOC_FAIL;
3779
		return SSH_ERR_ALLOC_FAIL;
Lines 3838-3845 sshkey_parse_private_pem_fileblob(struct sshbuf *blob, int type, Link Here
3838
		goto out;
3842
		goto out;
3839
	}
3843
	}
3840
	r = 0;
3844
	r = 0;
3841
	*keyp = prv;
3845
	if (keyp != NULL) {
3842
	prv = NULL;
3846
		*keyp = prv;
3847
		prv = NULL;
3848
	}
3843
 out:
3849
 out:
3844
	BIO_free(bio);
3850
	BIO_free(bio);
3845
	if (pk != NULL)
3851
	if (pk != NULL)
Lines 3853-3859 int Link Here
3853
sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type,
3859
sshkey_parse_private_fileblob_type(struct sshbuf *blob, int type,
3854
    const char *passphrase, struct sshkey **keyp, char **commentp)
3860
    const char *passphrase, struct sshkey **keyp, char **commentp)
3855
{
3861
{
3856
	*keyp = NULL;
3862
	if (keyp != NULL)
3863
		*keyp = NULL;
3857
	if (commentp != NULL)
3864
	if (commentp != NULL)
3858
		*commentp = NULL;
3865
		*commentp = NULL;
3859
3866

Return to bug 2561