diff options
author | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-12-13 19:53:32 +0100 |
---|---|---|
committer | Aris Adamantiadis <aris@0xbadc0de.be> | 2009-12-13 19:53:32 +0100 |
commit | 46b2b99f6330c97478d1fcbf85e1ce8ff6c5d6d3 (patch) | |
tree | 2f2eff7e33368bcf9cd01ff4cf6b7fb1f39933d1 /examples/authentication.c | |
parent | c92f54102eebe024c8975a96947b35a5300be5d4 (diff) | |
download | libssh-46b2b99f6330c97478d1fcbf85e1ce8ff6c5d6d3.tar.gz libssh-46b2b99f6330c97478d1fcbf85e1ce8ff6c5d6d3.tar.xz libssh-46b2b99f6330c97478d1fcbf85e1ce8ff6c5d6d3.zip |
Fix strange error message in sample authentication
Diffstat (limited to 'examples/authentication.c')
-rw-r--r-- | examples/authentication.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/examples/authentication.c b/examples/authentication.c index 29b83eaa..988ed91f 100644 --- a/examples/authentication.c +++ b/examples/authentication.c @@ -64,6 +64,10 @@ int authenticate_kbdint(ssh_session session){ return err; } +static void error(ssh_session session){ + fprintf(stderr,"Authentication failed: %s\n",ssh_get_error(session)); +} + int authenticate_console(ssh_session session){ int rc; int method; @@ -73,7 +77,7 @@ int authenticate_console(ssh_session session){ // Try to authenticate rc = ssh_userauth_none(session, NULL); if (rc == SSH_AUTH_ERROR) { - perror("Authentication failed."); + error(session); return rc; } @@ -84,7 +88,7 @@ int authenticate_console(ssh_session session){ if (method & SSH_AUTH_METHOD_PUBLICKEY) { rc = ssh_userauth_autopubkey(session, NULL); if (rc == SSH_AUTH_ERROR) { - perror("Authentication failed."); + error(session); return rc; } else if (rc == SSH_AUTH_SUCCESS) { break; @@ -95,7 +99,7 @@ int authenticate_console(ssh_session session){ if (method & SSH_AUTH_METHOD_INTERACTIVE) { rc = authenticate_kbdint(session); if (rc == SSH_AUTH_ERROR) { - perror("Authentication failed."); + error(session); return rc; } else if (rc == SSH_AUTH_SUCCESS) { break; @@ -107,7 +111,7 @@ int authenticate_console(ssh_session session){ if (method & SSH_AUTH_METHOD_PASSWORD) { rc = ssh_userauth_password(session, NULL, password); if (rc == SSH_AUTH_ERROR) { - perror("Authentication failed."); + error(session); return rc; } else if (rc == SSH_AUTH_SUCCESS) { break; |