GUACAMOLE-5: Store connection parameters at user level. Maintain reference to owner's connection parameters at client level.

This commit is contained in:
Michael Jumper 2016-07-24 21:34:21 -07:00
parent 425f7baa2b
commit 0641ccf601
4 changed files with 92 additions and 40 deletions

View File

@ -44,19 +44,25 @@ int guac_rdp_user_join_handler(guac_user* user, int argc, char** argv) {
guac_rdp_client* rdp_client = (guac_rdp_client*) user->client->data;
/* Parse provided arguments */
guac_rdp_settings* settings = guac_rdp_parse_args(user,
argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store settings at user level */
user->data = settings;
/* Connect via RDP if owner */
if (user->owner) {
/* Parse arguments into client */
guac_rdp_settings* settings = rdp_client->settings =
guac_rdp_parse_args(user, argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store owner's settings at client level */
rdp_client->settings = settings;
/* Start client thread */
if (pthread_create(&rdp_client->client_thread, NULL,
@ -131,8 +137,15 @@ int guac_rdp_user_leave_handler(guac_user* user) {
guac_rdp_client* rdp_client = (guac_rdp_client*) user->client->data;
/* Update shared cursor state */
guac_common_cursor_remove_user(rdp_client->display->cursor, user);
/* Free settings if not owner (owner settings will be freed with client) */
if (!user->owner) {
guac_rdp_settings* settings = (guac_rdp_settings*) user->data;
guac_rdp_settings_free(settings);
}
return 0;
}

View File

@ -39,19 +39,25 @@ int guac_ssh_user_join_handler(guac_user* user, int argc, char** argv) {
guac_client* client = user->client;
guac_ssh_client* ssh_client = (guac_ssh_client*) client->data;
/* Parse provided arguments */
guac_ssh_settings* settings = guac_ssh_parse_args(user,
argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store settings at user level */
user->data = settings;
/* Connect via SSH if owner */
if (user->owner) {
/* Parse arguments into client */
guac_ssh_settings* settings = ssh_client->settings =
guac_ssh_parse_args(user, argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store owner's settings at client level */
ssh_client->settings = settings;
/* Start client thread */
if (pthread_create(&(ssh_client->client_thread), NULL,
@ -86,8 +92,15 @@ int guac_ssh_user_leave_handler(guac_user* user) {
guac_ssh_client* ssh_client = (guac_ssh_client*) user->client->data;
/* Update shared cursor state */
guac_common_cursor_remove_user(ssh_client->term->cursor, user);
/* Free settings if not owner (owner settings will be freed with client) */
if (!user->owner) {
guac_ssh_settings* settings = (guac_ssh_settings*) user->data;
guac_ssh_settings_free(settings);
}
return 0;
}

View File

@ -38,19 +38,25 @@ int guac_telnet_user_join_handler(guac_user* user, int argc, char** argv) {
guac_client* client = user->client;
guac_telnet_client* telnet_client = (guac_telnet_client*) client->data;
/* Parse provided arguments */
guac_telnet_settings* settings = guac_telnet_parse_args(user,
argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store settings at user level */
user->data = settings;
/* Connect via telnet if owner */
if (user->owner) {
/* Parse arguments into client */
guac_telnet_settings* settings = telnet_client->settings =
guac_telnet_parse_args(user, argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store owner's settings at client level */
telnet_client->settings = settings;
/* Start client thread */
if (pthread_create(&(telnet_client->client_thread), NULL,
@ -83,8 +89,15 @@ int guac_telnet_user_leave_handler(guac_user* user) {
guac_telnet_client* telnet_client =
(guac_telnet_client*) user->client->data;
/* Update shared cursor state */
guac_common_cursor_remove_user(telnet_client->term->cursor, user);
/* Free settings if not owner (owner settings will be freed with client) */
if (!user->owner) {
guac_telnet_settings* settings = (guac_telnet_settings*) user->data;
guac_telnet_settings_free(settings);
}
return 0;
}

View File

@ -41,19 +41,25 @@ int guac_vnc_user_join_handler(guac_user* user, int argc, char** argv) {
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
/* Parse provided arguments */
guac_vnc_settings* settings = guac_vnc_parse_args(user,
argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store settings at user level */
user->data = settings;
/* Connect via VNC if owner */
if (user->owner) {
/* Parse arguments into client */
guac_vnc_settings* settings = vnc_client->settings =
guac_vnc_parse_args(user, argc, (const char**) argv);
/* Fail if settings cannot be parsed */
if (settings == NULL) {
guac_user_log(user, GUAC_LOG_INFO,
"Badly formatted client arguments.");
return 1;
}
/* Store owner's settings at client level */
vnc_client->settings = settings;
/* Start client thread */
if (pthread_create(&vnc_client->client_thread, NULL, guac_vnc_client_thread, user->client)) {
@ -101,8 +107,15 @@ int guac_vnc_user_leave_handler(guac_user* user) {
guac_vnc_client* vnc_client = (guac_vnc_client*) user->client->data;
/* Update shared cursor state */
guac_common_cursor_remove_user(vnc_client->display->cursor, user);
/* Free settings if not owner (owner settings will be freed with client) */
if (!user->owner) {
guac_vnc_settings* settings = (guac_vnc_settings*) user->data;
guac_vnc_settings_free(settings);
}
return 0;
}