diff --git a/src/protocols/kubernetes/argv.c b/src/protocols/kubernetes/argv.c index e46bb2fd..c37595de 100644 --- a/src/protocols/kubernetes/argv.c +++ b/src/protocols/kubernetes/argv.c @@ -199,3 +199,26 @@ int guac_kubernetes_argv_handler(guac_user* user, guac_stream* stream, } +void* guac_kubernetes_send_current_argv(guac_user* user, void* data) { + + guac_kubernetes_client* kubernetes_client = (guac_kubernetes_client*) data; + guac_terminal* terminal = kubernetes_client->term; + + /* Send current color scheme */ + guac_user_stream_argv(user, user->socket, "text/plain", "color-scheme", + terminal->color_scheme); + + /* Send current font name */ + guac_user_stream_argv(user, user->socket, "text/plain", "font-name", + terminal->font_name); + + /* Send current font size */ + char font_size[64]; + sprintf(font_size, "%i", terminal->font_size); + guac_user_stream_argv(user, user->socket, "text/plain", "font-size", + font_size); + + return NULL; + +} + diff --git a/src/protocols/kubernetes/argv.h b/src/protocols/kubernetes/argv.h index da9e11b7..1a23df13 100644 --- a/src/protocols/kubernetes/argv.h +++ b/src/protocols/kubernetes/argv.h @@ -37,5 +37,26 @@ */ guac_user_argv_handler guac_kubernetes_argv_handler; +/** + * Sends the current values of all non-sensitive parameters which may be set + * while the connection is running to the given user. Note that the user + * receiving these values will not necessarily be able to set new values + * themselves if their connection is read-only. This function is provided for + * convenience, as it is can be used as the callback for + * guac_client_foreach_user() or guac_client_for_owner(). + * + * @param user + * The user that should receive the values of all non-sensitive parameters + * which may be set while the connection is running. + * + * @param data + * The guac_kubernetes_client instance associated with the current + * connection. + * + * @return + * Always NULL. + */ +void* guac_kubernetes_send_current_argv(guac_user* user, void* data); + #endif diff --git a/src/protocols/kubernetes/kubernetes.c b/src/protocols/kubernetes/kubernetes.c index 7c22c420..bd84f6ce 100644 --- a/src/protocols/kubernetes/kubernetes.c +++ b/src/protocols/kubernetes/kubernetes.c @@ -18,6 +18,8 @@ */ #include "config.h" + +#include "argv.h" #include "client.h" #include "common/recording.h" #include "io.h" @@ -249,6 +251,10 @@ void* guac_kubernetes_client_thread(void* data) { goto fail; } + /* Send current values of exposed arguments to owner only */ + guac_client_for_owner(client, guac_kubernetes_send_current_argv, + kubernetes_client); + /* Set up typescript, if requested */ if (settings->typescript_path != NULL) { guac_terminal_create_typescript(kubernetes_client->term, diff --git a/src/protocols/kubernetes/user.c b/src/protocols/kubernetes/user.c index a2fdd200..e7f6d8f9 100644 --- a/src/protocols/kubernetes/user.c +++ b/src/protocols/kubernetes/user.c @@ -74,6 +74,7 @@ int guac_kubernetes_user_join_handler(guac_user* user, int argc, char** argv) { /* If not owner, synchronize with current display */ else { guac_terminal_dup(kubernetes_client->term, user, user->socket); + guac_kubernetes_send_current_argv(user, kubernetes_client); guac_socket_flush(user->socket); } diff --git a/src/protocols/ssh/argv.c b/src/protocols/ssh/argv.c index 0a4e6705..d9ce1e75 100644 --- a/src/protocols/ssh/argv.c +++ b/src/protocols/ssh/argv.c @@ -204,3 +204,26 @@ int guac_ssh_argv_handler(guac_user* user, guac_stream* stream, } +void* guac_ssh_send_current_argv(guac_user* user, void* data) { + + guac_ssh_client* ssh_client = (guac_ssh_client*) data; + guac_terminal* terminal = ssh_client->term; + + /* Send current color scheme */ + guac_user_stream_argv(user, user->socket, "text/plain", "color-scheme", + terminal->color_scheme); + + /* Send current font name */ + guac_user_stream_argv(user, user->socket, "text/plain", "font-name", + terminal->font_name); + + /* Send current font size */ + char font_size[64]; + sprintf(font_size, "%i", terminal->font_size); + guac_user_stream_argv(user, user->socket, "text/plain", "font-size", + font_size); + + return NULL; + +} + diff --git a/src/protocols/ssh/argv.h b/src/protocols/ssh/argv.h index 88cf8e97..c7b8559b 100644 --- a/src/protocols/ssh/argv.h +++ b/src/protocols/ssh/argv.h @@ -37,5 +37,25 @@ */ guac_user_argv_handler guac_ssh_argv_handler; +/** + * Sends the current values of all non-sensitive parameters which may be set + * while the connection is running to the given user. Note that the user + * receiving these values will not necessarily be able to set new values + * themselves if their connection is read-only. This function is provided for + * convenience, as it is can be used as the callback for + * guac_client_foreach_user() or guac_client_for_owner(). + * + * @param user + * The user that should receive the values of all non-sensitive parameters + * which may be set while the connection is running. + * + * @param data + * The guac_ssh_client instance associated with the current connection. + * + * @return + * Always NULL. + */ +void* guac_ssh_send_current_argv(guac_user* user, void* data); + #endif diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 8a18cf4d..456c2140 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -19,6 +19,7 @@ #include "config.h" +#include "argv.h" #include "common/recording.h" #include "common-ssh/sftp.h" #include "common-ssh/ssh.h" @@ -233,6 +234,9 @@ void* ssh_client_thread(void* data) { return NULL; } + /* Send current values of exposed arguments to owner only */ + guac_client_for_owner(client, guac_ssh_send_current_argv, ssh_client); + /* Set up typescript, if requested */ if (settings->typescript_path != NULL) { guac_terminal_create_typescript(ssh_client->term, diff --git a/src/protocols/ssh/user.c b/src/protocols/ssh/user.c index 97ed87c6..ccf2447c 100644 --- a/src/protocols/ssh/user.c +++ b/src/protocols/ssh/user.c @@ -74,6 +74,7 @@ int guac_ssh_user_join_handler(guac_user* user, int argc, char** argv) { /* If not owner, synchronize with current display */ else { guac_terminal_dup(ssh_client->term, user, user->socket); + guac_ssh_send_current_argv(user, ssh_client); guac_socket_flush(user->socket); } diff --git a/src/protocols/telnet/argv.c b/src/protocols/telnet/argv.c index 5edf060a..37564a60 100644 --- a/src/protocols/telnet/argv.c +++ b/src/protocols/telnet/argv.c @@ -200,3 +200,26 @@ int guac_telnet_argv_handler(guac_user* user, guac_stream* stream, } +void* guac_telnet_send_current_argv(guac_user* user, void* data) { + + guac_telnet_client* telnet_client = (guac_telnet_client*) data; + guac_terminal* terminal = telnet_client->term; + + /* Send current color scheme */ + guac_user_stream_argv(user, user->socket, "text/plain", "color-scheme", + terminal->color_scheme); + + /* Send current font name */ + guac_user_stream_argv(user, user->socket, "text/plain", "font-name", + terminal->font_name); + + /* Send current font size */ + char font_size[64]; + sprintf(font_size, "%i", terminal->font_size); + guac_user_stream_argv(user, user->socket, "text/plain", "font-size", + font_size); + + return NULL; + +} + diff --git a/src/protocols/telnet/argv.h b/src/protocols/telnet/argv.h index aa13dda9..4bbf8696 100644 --- a/src/protocols/telnet/argv.h +++ b/src/protocols/telnet/argv.h @@ -37,5 +37,25 @@ */ guac_user_argv_handler guac_telnet_argv_handler; +/** + * Sends the current values of all non-sensitive parameters which may be set + * while the connection is running to the given user. Note that the user + * receiving these values will not necessarily be able to set new values + * themselves if their connection is read-only. This function is provided for + * convenience, as it is can be used as the callback for + * guac_client_foreach_user() or guac_client_for_owner(). + * + * @param user + * The user that should receive the values of all non-sensitive parameters + * which may be set while the connection is running. + * + * @param data + * The guac_telnet_client instance associated with the current connection. + * + * @return + * Always NULL. + */ +void* guac_telnet_send_current_argv(guac_user* user, void* data); + #endif diff --git a/src/protocols/telnet/telnet.c b/src/protocols/telnet/telnet.c index 17abd681..e100fae9 100644 --- a/src/protocols/telnet/telnet.c +++ b/src/protocols/telnet/telnet.c @@ -18,6 +18,8 @@ */ #include "config.h" + +#include "argv.h" #include "common/recording.h" #include "telnet.h" #include "terminal/terminal.h" @@ -580,6 +582,10 @@ void* guac_telnet_client_thread(void* data) { return NULL; } + /* Send current values of exposed arguments to owner only */ + guac_client_for_owner(client, guac_telnet_send_current_argv, + telnet_client); + /* Set up typescript, if requested */ if (settings->typescript_path != NULL) { guac_terminal_create_typescript(telnet_client->term, diff --git a/src/protocols/telnet/user.c b/src/protocols/telnet/user.c index 44ef9b5e..08cfc6fe 100644 --- a/src/protocols/telnet/user.c +++ b/src/protocols/telnet/user.c @@ -73,6 +73,7 @@ int guac_telnet_user_join_handler(guac_user* user, int argc, char** argv) { /* If not owner, synchronize with current display */ else { guac_terminal_dup(telnet_client->term, user, user->socket); + guac_telnet_send_current_argv(user, telnet_client); guac_socket_flush(user->socket); }