version 1.133, 2019/07/15 13:16:29 |
version 1.134, 2019/08/05 11:50:33 |
|
|
return 0; |
return 0; |
} |
} |
|
|
/* XXX kill perm_ok now that we have SSH_ERR_KEY_BAD_PERMISSIONS? */ |
|
int |
int |
sshkey_load_private_type(int type, const char *filename, const char *passphrase, |
sshkey_load_private_type(int type, const char *filename, const char *passphrase, |
struct sshkey **keyp, char **commentp, int *perm_ok) |
struct sshkey **keyp, char **commentp) |
{ |
{ |
int fd, r; |
int fd, r; |
|
|
|
|
if (commentp != NULL) |
if (commentp != NULL) |
*commentp = NULL; |
*commentp = NULL; |
|
|
if ((fd = open(filename, O_RDONLY)) == -1) { |
if ((fd = open(filename, O_RDONLY)) == -1) |
if (perm_ok != NULL) |
|
*perm_ok = 0; |
|
return SSH_ERR_SYSTEM_ERROR; |
return SSH_ERR_SYSTEM_ERROR; |
} |
|
if (sshkey_perm_ok(fd, filename) != 0) { |
r = sshkey_perm_ok(fd, filename); |
if (perm_ok != NULL) |
if (r != 0) |
*perm_ok = 0; |
|
r = SSH_ERR_KEY_BAD_PERMISSIONS; |
|
goto out; |
goto out; |
} |
|
if (perm_ok != NULL) |
|
*perm_ok = 1; |
|
|
|
r = sshkey_load_private_type_fd(fd, type, passphrase, keyp, commentp); |
r = sshkey_load_private_type_fd(fd, type, passphrase, keyp, commentp); |
if (r == 0 && keyp && *keyp) |
if (r == 0 && keyp && *keyp) |
|
|
/* Load private key and certificate */ |
/* Load private key and certificate */ |
int |
int |
sshkey_load_private_cert(int type, const char *filename, const char *passphrase, |
sshkey_load_private_cert(int type, const char *filename, const char *passphrase, |
struct sshkey **keyp, int *perm_ok) |
struct sshkey **keyp) |
{ |
{ |
struct sshkey *key = NULL, *cert = NULL; |
struct sshkey *key = NULL, *cert = NULL; |
int r; |
int r; |
|
|
} |
} |
|
|
if ((r = sshkey_load_private_type(type, filename, |
if ((r = sshkey_load_private_type(type, filename, |
passphrase, &key, NULL, perm_ok)) != 0 || |
passphrase, &key, NULL)) != 0 || |
(r = sshkey_load_cert(filename, &cert)) != 0) |
(r = sshkey_load_cert(filename, &cert)) != 0) |
goto out; |
goto out; |
|
|