GUAC-653: Restore file upload for SSH.

This commit is contained in:
Michael Jumper 2014-05-06 17:14:40 -07:00
parent 0acd219a88
commit 7c08593b83
4 changed files with 32 additions and 2 deletions

View File

@ -309,6 +309,10 @@ void* ssh_client_thread(void* data) {
/* Start SFTP session as well, if enabled */ /* Start SFTP session as well, if enabled */
if (client_data->enable_sftp) { if (client_data->enable_sftp) {
/* Init handlers for Guacamole-specific console codes */
client_data->term->upload_path_handler = guac_sftp_set_upload_path;
client_data->term->file_download_handler = guac_sftp_download_file;
/* Create SSH session specific for SFTP */ /* Create SSH session specific for SFTP */
guac_client_log_info(client, "Reconnecting for SFTP..."); guac_client_log_info(client, "Reconnecting for SFTP...");
client_data->sftp_ssh_session = __guac_ssh_create_session(client, NULL); client_data->sftp_ssh_session = __guac_ssh_create_session(client, NULL);

View File

@ -100,6 +100,8 @@ guac_terminal* guac_terminal_create(guac_client* client,
guac_terminal* term = malloc(sizeof(guac_terminal)); guac_terminal* term = malloc(sizeof(guac_terminal));
term->client = client; term->client = client;
term->upload_path_handler = NULL;
term->file_download_handler = NULL;
/* Init buffer */ /* Init buffer */
term->buffer = guac_terminal_buffer_alloc(1000, &default_char); term->buffer = guac_terminal_buffer_alloc(1000, &default_char);

View File

@ -61,6 +61,16 @@ typedef struct guac_terminal guac_terminal;
*/ */
typedef int guac_terminal_char_handler(guac_terminal* term, unsigned char c); typedef int guac_terminal_char_handler(guac_terminal* term, unsigned char c);
/**
* Handler for setting the destination path for file uploads.
*/
typedef void guac_terminal_upload_path_handler(guac_client* client, char* path);
/**
* Handler for creating an outbound file download stream for a specified file.
*/
typedef guac_stream* guac_terminal_file_download_handler(guac_client* client, char* filename);
/** /**
* Represents a terminal emulator which uses a given Guacamole client to * Represents a terminal emulator which uses a given Guacamole client to
* render itself. * render itself.
@ -72,6 +82,18 @@ struct guac_terminal {
*/ */
guac_client* client; guac_client* client;
/**
* Called whenever the necessary terminal codes are sent to change
* the path for future file uploads.
*/
guac_terminal_upload_path_handler* upload_path_handler;
/**
* Called whenever the necessary terminal codes are sent to initiate
* a download of a given remote file.
*/
guac_terminal_file_download_handler* file_download_handler;
/** /**
* Lock which restricts simultaneous access to this terminal via the root * Lock which restricts simultaneous access to this terminal via the root
* guac_terminal_* functions. * guac_terminal_* functions.

View File

@ -884,7 +884,8 @@ int guac_terminal_set_directory(guac_terminal* term, unsigned char c) {
if (c == 0x9C || c == 0x5C || c == 0x07) { if (c == 0x9C || c == 0x5C || c == 0x07) {
filename[length++] = '\0'; filename[length++] = '\0';
term->char_handler = guac_terminal_echo; term->char_handler = guac_terminal_echo;
/*guac_sftp_set_upload_path(term->client, filename);*/ if (term->upload_path_handler)
term->upload_path_handler(term->client, filename);
length = 0; length = 0;
} }
@ -905,7 +906,8 @@ int guac_terminal_download(guac_terminal* term, unsigned char c) {
if (c == 0x9C || c == 0x5C || c == 0x07) { if (c == 0x9C || c == 0x5C || c == 0x07) {
filename[length++] = '\0'; filename[length++] = '\0';
term->char_handler = guac_terminal_echo; term->char_handler = guac_terminal_echo;
/*guac_sftp_download_file(term->client, filename);*/ if (term->file_download_handler)
term->file_download_handler(term->client, filename);
length = 0; length = 0;
} }