GUAC-493: Coding style changes.
This commit is contained in:
parent
e543d9eeb5
commit
46faa7ab85
@ -95,16 +95,19 @@ static void __kbd_callback(const char *name, int name_len,
|
|||||||
int num_prompts,
|
int num_prompts,
|
||||||
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
const LIBSSH2_USERAUTH_KBDINT_PROMPT *prompts,
|
||||||
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
LIBSSH2_USERAUTH_KBDINT_RESPONSE *responses,
|
||||||
void **abstract)
|
void **abstract) {
|
||||||
{
|
|
||||||
guac_client *client = (guac_client *) *abstract;
|
guac_client* client = (guac_client*) *abstract;
|
||||||
ssh_guac_client_data *client_data = (ssh_guac_client_data *) client->data;
|
ssh_guac_client_data* client_data = (ssh_guac_client_data*) client->data;
|
||||||
|
|
||||||
if (num_prompts == 1) {
|
if (num_prompts == 1) {
|
||||||
responses[0].text = strdup(client_data->password);
|
responses[0].text = strdup(client_data->password);
|
||||||
responses[0].length = strlen(client_data->password);
|
responses[0].length = strlen(client_data->password);
|
||||||
}
|
}
|
||||||
}
|
else
|
||||||
|
guac_client_log_info(client, "Unsupported number of keyboard-interactive prompts: %i", num_prompts);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
static LIBSSH2_SESSION* __guac_ssh_create_session(guac_client* client,
|
static LIBSSH2_SESSION* __guac_ssh_create_session(guac_client* client,
|
||||||
int* socket_fd) {
|
int* socket_fd) {
|
||||||
@ -204,13 +207,14 @@ static LIBSSH2_SESSION* __guac_ssh_create_session(guac_client* client,
|
|||||||
|
|
||||||
/* Get list of suported authentication methods */
|
/* Get list of suported authentication methods */
|
||||||
user_authlist = libssh2_userauth_list(session, client_data->username, strlen(client_data->username));
|
user_authlist = libssh2_userauth_list(session, client_data->username, strlen(client_data->username));
|
||||||
guac_client_log_info (client, "Supported authentications: %s", user_authlist);
|
guac_client_log_info(client, "Supported authentication methods: %s", user_authlist);
|
||||||
|
|
||||||
/* Authenticate with key if available */
|
/* Authenticate with key if available */
|
||||||
if (client_data->key != NULL) {
|
if (client_data->key != NULL) {
|
||||||
|
|
||||||
/* Check if public key auth is suported on the server */
|
/* Check if public key auth is suported on the server */
|
||||||
if (strstr(user_authlist, "publickey") == NULL) {
|
if (strstr(user_authlist, "publickey") == NULL) {
|
||||||
guac_client_abort (client, GUAC_PROTOCOL_STATUS_CLIENT_UNAUTHORIZED,
|
guac_client_abort(client, GUAC_PROTOCOL_STATUS_CLIENT_UNAUTHORIZED,
|
||||||
"Public key authentication not suported");
|
"Public key authentication not suported");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
@ -233,16 +237,19 @@ static LIBSSH2_SESSION* __guac_ssh_create_session(guac_client* client,
|
|||||||
if (strstr(user_authlist, "password") != NULL) {
|
if (strstr(user_authlist, "password") != NULL) {
|
||||||
guac_client_log_info(client, "Using password authentication method");
|
guac_client_log_info(client, "Using password authentication method");
|
||||||
retval = libssh2_userauth_password(session, client_data->username, client_data->password);
|
retval = libssh2_userauth_password(session, client_data->username, client_data->password);
|
||||||
} else if (strstr(user_authlist, "keyboard-interactive") != NULL) {
|
}
|
||||||
|
else if (strstr(user_authlist, "keyboard-interactive") != NULL) {
|
||||||
guac_client_log_info(client, "Using keyboard-interactive authentication method");
|
guac_client_log_info(client, "Using keyboard-interactive authentication method");
|
||||||
retval = libssh2_userauth_keyboard_interactive(session, client_data->username, &__kbd_callback);
|
retval = libssh2_userauth_keyboard_interactive(session, client_data->username, &__kbd_callback);
|
||||||
} else {
|
}
|
||||||
|
else {
|
||||||
guac_client_abort(client, GUAC_PROTOCOL_STATUS_CLIENT_BAD_TYPE, "No known authentication methods");
|
guac_client_abort(client, GUAC_PROTOCOL_STATUS_CLIENT_BAD_TYPE, "No known authentication methods");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (retval == 0)
|
if (retval == 0)
|
||||||
return session;
|
return session;
|
||||||
|
|
||||||
else {
|
else {
|
||||||
char* error_message;
|
char* error_message;
|
||||||
libssh2_session_last_error(session, &error_message, NULL, 0);
|
libssh2_session_last_error(session, &error_message, NULL, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user