Fix strange error message in sample authentication
Этот коммит содержится в:
родитель
c92f54102e
Коммит
46b2b99f63
@ -64,6 +64,10 @@ int authenticate_kbdint(ssh_session session){
|
|||||||
return err;
|
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 authenticate_console(ssh_session session){
|
||||||
int rc;
|
int rc;
|
||||||
int method;
|
int method;
|
||||||
@ -73,7 +77,7 @@ int authenticate_console(ssh_session session){
|
|||||||
// Try to authenticate
|
// Try to authenticate
|
||||||
rc = ssh_userauth_none(session, NULL);
|
rc = ssh_userauth_none(session, NULL);
|
||||||
if (rc == SSH_AUTH_ERROR) {
|
if (rc == SSH_AUTH_ERROR) {
|
||||||
perror("Authentication failed.");
|
error(session);
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -84,7 +88,7 @@ int authenticate_console(ssh_session session){
|
|||||||
if (method & SSH_AUTH_METHOD_PUBLICKEY) {
|
if (method & SSH_AUTH_METHOD_PUBLICKEY) {
|
||||||
rc = ssh_userauth_autopubkey(session, NULL);
|
rc = ssh_userauth_autopubkey(session, NULL);
|
||||||
if (rc == SSH_AUTH_ERROR) {
|
if (rc == SSH_AUTH_ERROR) {
|
||||||
perror("Authentication failed.");
|
error(session);
|
||||||
return rc;
|
return rc;
|
||||||
} else if (rc == SSH_AUTH_SUCCESS) {
|
} else if (rc == SSH_AUTH_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
@ -95,7 +99,7 @@ int authenticate_console(ssh_session session){
|
|||||||
if (method & SSH_AUTH_METHOD_INTERACTIVE) {
|
if (method & SSH_AUTH_METHOD_INTERACTIVE) {
|
||||||
rc = authenticate_kbdint(session);
|
rc = authenticate_kbdint(session);
|
||||||
if (rc == SSH_AUTH_ERROR) {
|
if (rc == SSH_AUTH_ERROR) {
|
||||||
perror("Authentication failed.");
|
error(session);
|
||||||
return rc;
|
return rc;
|
||||||
} else if (rc == SSH_AUTH_SUCCESS) {
|
} else if (rc == SSH_AUTH_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
@ -107,7 +111,7 @@ int authenticate_console(ssh_session session){
|
|||||||
if (method & SSH_AUTH_METHOD_PASSWORD) {
|
if (method & SSH_AUTH_METHOD_PASSWORD) {
|
||||||
rc = ssh_userauth_password(session, NULL, password);
|
rc = ssh_userauth_password(session, NULL, password);
|
||||||
if (rc == SSH_AUTH_ERROR) {
|
if (rc == SSH_AUTH_ERROR) {
|
||||||
perror("Authentication failed.");
|
error(session);
|
||||||
return rc;
|
return rc;
|
||||||
} else if (rc == SSH_AUTH_SUCCESS) {
|
} else if (rc == SSH_AUTH_SUCCESS) {
|
||||||
break;
|
break;
|
||||||
|
Загрузка…
x
Ссылка в новой задаче
Block a user