diff options
Diffstat (limited to 'libssh/keyfiles.c')
-rw-r--r-- | libssh/keyfiles.c | 30 |
1 files changed, 10 insertions, 20 deletions
diff --git a/libssh/keyfiles.c b/libssh/keyfiles.c index 8f63729..79b3bfe 100644 --- a/libssh/keyfiles.c +++ b/libssh/keyfiles.c @@ -1157,8 +1157,6 @@ int ssh_try_publickey_from_file(ssh_session session, const char *keyfile, ssh_string try_publickey_from_file(ssh_session session, struct ssh_keys_struct keytab, char **privkeyfile, int *type) { - char *public; - char *private; const char *priv; const char *pub; char *new; @@ -1179,21 +1177,15 @@ ssh_string try_publickey_from_file(ssh_session session, struct ssh_keys_struct k } } - /* are them readable ? */ - public=dir_expand_dup(session,pub,1); - private=dir_expand_dup(session,priv,1); - //snprintf(public, sizeof(public), "%s/%s", session->sshdir, pub); - //snprintf(private, sizeof(private), "%s/%s", session->sshdir, priv); - - ssh_log(session, SSH_LOG_PACKET, "Trying to open publickey %s", public); - if (!ssh_file_readaccess_ok(public)) { - ssh_log(session, SSH_LOG_PACKET, "Failed to open publickey %s", public); + 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", private); - if (!ssh_file_readaccess_ok(private)) { - ssh_log(session, SSH_LOG_PACKET, "Failed to open privatekey %s", private); + 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; } @@ -1203,26 +1195,24 @@ ssh_string try_publickey_from_file(ssh_session session, struct ssh_keys_struct k * 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, public, type); + 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", - public, + pub, ssh_get_error(session)); goto error; } - new = realloc(*privkeyfile, strlen(private) + 1); + new = realloc(*privkeyfile, strlen(priv) + 1); if (new == NULL) { string_free(pubkey); goto error; } - strcpy(new, private); + strcpy(new, priv); *privkeyfile = new; error: - SAFE_FREE(public); - SAFE_FREE(private); return pubkey; } |