1
1

keyfiles: Remove try_publickey_from_file().

Этот коммит содержится в:
Andreas Schneider 2011-08-28 14:24:23 +02:00
родитель bce2c22e45
Коммит be660e801a
2 изменённых файлов: 0 добавлений и 86 удалений

Просмотреть файл

@ -26,8 +26,5 @@
ssh_private_key _privatekey_from_file(void *session, const char *filename,
int type);
ssh_string try_publickey_from_file(ssh_session session,
struct ssh_keys_struct keytab,
char **privkeyfile, int *type);
#endif /* KEYFILES_H_ */

Просмотреть файл

@ -1524,87 +1524,4 @@ ssh_signature pki_do_sign_sessionid(const ssh_key key,
#endif /* WITH_SERVER */
#endif /* HAVE_LIBGCRYPT */
/**
* @addtogroup libssh_auth
*
* @{
*/
/**
* @brief Try to read the public key from a given file.
*
* @param[in] session The ssh session to use.
*
* @param[in] keyfile The name of the private keyfile.
*
* @param[out] publickey A ssh_string to store the public key.
*
* @param[out] type A pointer to an integer to store the type.
*
* @return 0 on success, -1 on error or the private key doesn't
* exist, 1 if the public key doesn't exist.
*/
ssh_string try_publickey_from_file(ssh_session session, struct ssh_keys_struct keytab,
char **privkeyfile, int *type) {
const char *priv;
const char *pub;
char *new;
ssh_string pubkey=NULL;
pub = keytab.publickey;
if (pub == NULL) {
return NULL;
}
priv = keytab.privatekey;
if (priv == NULL) {
return NULL;
}
if (session->sshdir == NULL) {
if (ssh_options_apply(session) < 0) {
return NULL;
}
}
ssh_log(session, SSH_LOG_PACKET, "Trying to open publickey %s", pub);
if (!ssh_file_readaccess_ok(pub)) {
ssh_log(session, SSH_LOG_PACKET, "Failed to open publickey %s", pub);
goto error;
}
ssh_log(session, SSH_LOG_PACKET, "Trying to open privatekey %s", priv);
if (!ssh_file_readaccess_ok(priv)) {
ssh_log(session, SSH_LOG_PACKET, "Failed to open privatekey %s", priv);
goto error;
}
ssh_log(session, SSH_LOG_PACKET, "Success opening public and private key");
/*
* We are sure both the private and public key file is readable. We return
* the public as a string, and the private filename as an argument
*/
pubkey = publickey_from_file(session, pub, type);
if (pubkey == NULL) {
ssh_log(session, SSH_LOG_PACKET,
"Wasn't able to open public key file %s: %s",
pub,
ssh_get_error(session));
goto error;
}
new = realloc(*privkeyfile, strlen(priv) + 1);
if (new == NULL) {
ssh_string_free(pubkey);
goto error;
}
strcpy(new, priv);
*privkeyfile = new;
error:
return pubkey;
}
/** @} */
/* vim: set ts=4 sw=4 et cindent: */