GUAC-1172: Properly store/free filesystem object.

This commit is contained in:
Michael Jumper 2015-07-01 10:43:20 -07:00
parent 0bbc958373
commit 42c36f5b84
5 changed files with 12 additions and 4 deletions

View File

@ -162,6 +162,7 @@ int guac_client_init(guac_client* client, int argc, char** argv) {
client_data->enable_sftp = strcmp(argv[IDX_ENABLE_SFTP], "true") == 0;
client_data->sftp_session = NULL;
client_data->sftp_ssh_session = NULL;
client_data->sftp_filesystem = NULL;
strcpy(client_data->sftp_upload_path, ".");
#ifdef ENABLE_SSH_AGENT

View File

@ -132,7 +132,7 @@ typedef struct ssh_guac_client_data {
/**
* The filesystem object exposed for the SFTP session.
*/
guac_object* filesystem;
guac_object* sftp_filesystem;
/**
* The path files will be sent to, if uploaded directly via a "file"

View File

@ -101,15 +101,20 @@ int ssh_guac_client_free_handler(guac_client* client) {
/* Free channels */
libssh2_channel_free(guac_client_data->term_channel);
/* Clean up SFTP */
/* Shutdown SFTP session, if any */
if (guac_client_data->sftp_session)
libssh2_sftp_shutdown(guac_client_data->sftp_session);
/* Disconnect SSH session corresponding to the SFTP session */
if (guac_client_data->sftp_ssh_session) {
libssh2_session_disconnect(guac_client_data->sftp_ssh_session, "Bye");
libssh2_session_free(guac_client_data->sftp_ssh_session);
}
/* Clean up the SFTP filesystem object */
if (guac_client_data->sftp_filesystem)
guac_client_free_object(client, guac_client_data->sftp_filesystem);
/* Free session */
if (guac_client_data->session != NULL)
libssh2_session_free(guac_client_data->session);

View File

@ -108,7 +108,9 @@ guac_stream* guac_sftp_download_file(guac_client* client, char* filename);
void guac_sftp_set_upload_path(guac_client* client, char* path);
/**
* Exposes access to SFTP via a filesystem object, returning that object.
* Exposes access to SFTP via a filesystem object, returning that object. The
* object returned must eventually be explicitly freed through a call to
* guac_client_free_object().
*
* @param client
* The Guacamole client to expose the filesystem to.

View File

@ -477,7 +477,7 @@ void* ssh_client_thread(void* data) {
client->file_handler = guac_sftp_file_handler;
/* Expose filesystem */
guac_sftp_expose_filesystem(client);
client_data->sftp_filesystem = guac_sftp_expose_filesystem(client);
guac_client_log(client, GUAC_LOG_DEBUG, "SFTP session initialized");