Properly cleanup SSH sessions.
This commit is contained in:
parent
763ed37179
commit
cf8ec8dbc2
@ -49,6 +49,8 @@
|
|||||||
#include <guacamole/client.h>
|
#include <guacamole/client.h>
|
||||||
#include <guacamole/error.h>
|
#include <guacamole/error.h>
|
||||||
|
|
||||||
|
#include <libssh/libssh.h>
|
||||||
|
|
||||||
#include "guac_handlers.h"
|
#include "guac_handlers.h"
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
@ -383,10 +385,20 @@ int ssh_guac_client_free_handler(guac_client* client) {
|
|||||||
|
|
||||||
ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data;
|
ssh_guac_client_data* guac_client_data = (ssh_guac_client_data*) client->data;
|
||||||
|
|
||||||
|
/* Close SSH channel */
|
||||||
|
ssh_channel_close(guac_client_data->term_channel);
|
||||||
|
ssh_channel_send_eof(guac_client_data->term_channel);
|
||||||
|
|
||||||
/* Free terminal */
|
/* Free terminal */
|
||||||
guac_terminal_free(guac_client_data->term);
|
guac_terminal_free(guac_client_data->term);
|
||||||
pthread_join(guac_client_data->client_thread, NULL);
|
pthread_join(guac_client_data->client_thread, NULL);
|
||||||
|
|
||||||
|
/* Free channels */
|
||||||
|
ssh_channel_free(guac_client_data->term_channel);
|
||||||
|
|
||||||
|
/* Free session */
|
||||||
|
ssh_free(guac_client_data->session);
|
||||||
|
|
||||||
/* Free clipboard data */
|
/* Free clipboard data */
|
||||||
free(guac_client_data->clipboard_data);
|
free(guac_client_data->clipboard_data);
|
||||||
|
|
||||||
|
@ -44,6 +44,8 @@
|
|||||||
#include <guacamole/protocol.h>
|
#include <guacamole/protocol.h>
|
||||||
#include <guacamole/socket.h>
|
#include <guacamole/socket.h>
|
||||||
|
|
||||||
|
#include <libssh/libssh.h>
|
||||||
|
|
||||||
#include "client.h"
|
#include "client.h"
|
||||||
#include "common.h"
|
#include "common.h"
|
||||||
|
|
||||||
@ -223,18 +225,15 @@ void* ssh_client_thread(void* data) {
|
|||||||
if ((bytes_read = channel_read(client_data->term_channel, buffer, sizeof(buffer), 0)) == SSH_AGAIN)
|
if ((bytes_read = channel_read(client_data->term_channel, buffer, sizeof(buffer), 0)) == SSH_AGAIN)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (bytes_read > 0)
|
/* Attempt to write data received. Exit on failure. */
|
||||||
guac_terminal_write_all(stdout_fd, buffer, bytes_read);
|
if (bytes_read > 0) {
|
||||||
|
int written = guac_terminal_write_all(stdout_fd, buffer, bytes_read);
|
||||||
|
if (written < 0)
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Notify on error */
|
|
||||||
if (bytes_read < 0) {
|
|
||||||
guac_protocol_send_error(socket, "Error reading data.");
|
|
||||||
guac_socket_flush(socket);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Wait for input thread to die */
|
/* Wait for input thread to die */
|
||||||
pthread_join(input_thread, NULL);
|
pthread_join(input_thread, NULL);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user