diff options
| author | Andreas Schneider <mail@cynapses.org> | 2010-05-11 02:08:29 +0200 |
|---|---|---|
| committer | Andreas Schneider <mail@cynapses.org> | 2010-05-11 09:52:06 +0200 |
| commit | 9d7fc9d50b895650f1ec301021b4a202a0fcb3cb (patch) | |
| tree | b3ace2422d959b40669021e1848f2973eba63422 /libssh/auth.c | |
| parent | b8bc3a658248692a3d4548fca54201f34713927c (diff) | |
Use the new expand functions.
This implements escape chars for IdentityFile in ssh_config and reads
the system ssh_config.
Diffstat (limited to 'libssh/auth.c')
| -rw-r--r-- | libssh/auth.c | 18 |
1 files changed, 1 insertions, 17 deletions
diff --git a/libssh/auth.c b/libssh/auth.c index b67d57d8..0098a401 100644 --- a/libssh/auth.c +++ b/libssh/auth.c @@ -864,16 +864,11 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { for (it = ssh_list_get_iterator(session->identity); it != NULL; it = it->next) { - char *privkey_file = NULL; + const char *privkey_file = it->data; int privkey_open = 0; privkey = NULL; - privkey_file = dir_expand_dup(session, it->data, 1); - if (privkey_file == NULL) { - continue; - } - ssh_log(session, SSH_LOG_PROTOCOL, "Trying to read privatekey %s", privkey_file); rc = ssh_try_publickey_from_file(session, privkey_file, &pubkey_string, &type); @@ -886,7 +881,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { ssh_log(session, SSH_LOG_RARE, "Reading private key %s failed (bad passphrase ?)", privkey_file); - SAFE_FREE(privkey_file); leave_function(); return SSH_AUTH_ERROR; } @@ -894,7 +888,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { pubkey = publickey_from_privatekey(privkey); if (pubkey == NULL) { - SAFE_FREE(privkey_file); privatekey_free(privkey); ssh_set_error_oom(session); leave_function(); @@ -905,7 +898,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { type = pubkey->type; publickey_free(pubkey); if (pubkey_string == NULL) { - SAFE_FREE(privkey_file); ssh_set_error_oom(session); leave_function(); return SSH_AUTH_ERROR; @@ -914,7 +906,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { len = strlen(privkey_file) + 5; publickey_file = malloc(len); if (publickey_file == NULL) { - SAFE_FREE(privkey_file); ssh_set_error_oom(session); leave_function(); return SSH_AUTH_ERROR; @@ -927,13 +918,11 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { } SAFE_FREE(publickey_file); } else if (rc < 0) { - SAFE_FREE(privkey_file); continue; } rc = ssh_userauth_offer_pubkey(session, NULL, type, pubkey_string); if (rc == SSH_AUTH_ERROR){ - SAFE_FREE(privkey_file); string_free(pubkey_string); ssh_log(session, SSH_LOG_RARE, "Publickey authentication error"); leave_function(); @@ -941,7 +930,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { } else { if (rc != SSH_AUTH_SUCCESS){ ssh_log(session, SSH_LOG_PROTOCOL, "Publickey refused by server"); - SAFE_FREE(privkey_file); string_free(pubkey_string); continue; } @@ -956,7 +944,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { ssh_log(session, SSH_LOG_RARE, "Reading private key %s failed (bad passphrase ?)", privkey_file); - SAFE_FREE(privkey_file); string_free(pubkey_string); continue; /* continue the loop with other pubkey */ } @@ -964,7 +951,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { rc = ssh_userauth_pubkey(session, NULL, pubkey_string, privkey); if (rc == SSH_AUTH_ERROR) { - SAFE_FREE(privkey_file); string_free(pubkey_string); privatekey_free(privkey); leave_function(); @@ -973,7 +959,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { if (rc != SSH_AUTH_SUCCESS){ ssh_log(session, SSH_LOG_FUNCTIONS, "The server accepted the public key but refused the signature"); - SAFE_FREE(privkey_file); string_free(pubkey_string); privatekey_free(privkey); continue; @@ -983,7 +968,6 @@ int ssh_userauth_autopubkey(ssh_session session, const char *passphrase) { /* auth success */ ssh_log(session, SSH_LOG_PROTOCOL, "Successfully authenticated using %s", privkey_file); - SAFE_FREE(privkey_file); string_free(pubkey_string); privatekey_free(privkey); |
