From 567cc5984abc6b1380f8a807a0a8f197bb8a3b93 Mon Sep 17 00:00:00 2001 From: Andreas Schneider Date: Thu, 30 Apr 2009 13:58:20 +0000 Subject: Improve the autopubkey authentication. git-svn-id: svn+ssh://svn.berlios.de/svnroot/repos/libssh/trunk@658 7dcaeef0-15fb-0310-b436-a5af3365683c --- libssh/auth.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) (limited to 'libssh/auth.c') diff --git a/libssh/auth.c b/libssh/auth.c index ea251347..235ec231 100644 --- a/libssh/auth.c +++ b/libssh/auth.c @@ -738,7 +738,7 @@ int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) { char *privkeyfile = NULL; char *id = NULL; size_t size; - unsigned int count = 0; + unsigned int i = 0; int type = 0; int rc; @@ -834,8 +834,15 @@ int ssh_userauth_autopubkey(SSH_SESSION *session, const char *passphrase) { keytab[size - 1].public = id; } - while ((pubkey = publickey_from_next_file(session, keytab, size, - &privkeyfile, &type, &count))) { + for (i = 0, pubkey = try_publickey_from_file(session, keytab[i], + &privkeyfile, &type); + i < size; + pubkey = try_publickey_from_file(session, keytab[++i], + &privkeyfile, &type)) { + if (pubkey == NULL) { + continue; + } + rc = ssh_userauth_offer_pubkey(session, NULL, type, pubkey); if (rc == SSH_AUTH_ERROR){ if (id != NULL) { -- cgit