diff --git a/src/protocols/rdp/user.c b/src/protocols/rdp/user.c index ef13205f..638f2d11 100644 --- a/src/protocols/rdp/user.c +++ b/src/protocols/rdp/user.c @@ -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; } diff --git a/src/protocols/ssh/user.c b/src/protocols/ssh/user.c index 4a224a0b..cd62ad38 100644 --- a/src/protocols/ssh/user.c +++ b/src/protocols/ssh/user.c @@ -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; } diff --git a/src/protocols/telnet/user.c b/src/protocols/telnet/user.c index 427112b6..8df697f4 100644 --- a/src/protocols/telnet/user.c +++ b/src/protocols/telnet/user.c @@ -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; } diff --git a/src/protocols/vnc/user.c b/src/protocols/vnc/user.c index 53423a11..75dff0d6 100644 --- a/src/protocols/vnc/user.c +++ b/src/protocols/vnc/user.c @@ -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; }