GUACAMOLE-630: Automatically send current color scheme and font to users joining SSH, telnet, and Kubernetes connections.
diff --git a/src/protocols/kubernetes/argv.c b/src/protocols/kubernetes/argv.c
index e46bb2f..c37595d 100644
--- a/src/protocols/kubernetes/argv.c
+++ b/src/protocols/kubernetes/argv.c
@@ -199,3 +199,26 @@
}
+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 da9e11b..1a23df1 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 7c22c42..bd84f6c 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 @@
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 a2fdd20..e7f6d8f 100644
--- a/src/protocols/kubernetes/user.c
+++ b/src/protocols/kubernetes/user.c
@@ -74,6 +74,7 @@
/* 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 0a4e670..d9ce1e7 100644
--- a/src/protocols/ssh/argv.c
+++ b/src/protocols/ssh/argv.c
@@ -204,3 +204,26 @@
}
+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 88cf8e9..c7b8559 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 8a18cf4..456c214 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 @@
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 97ed87c..ccf2447 100644
--- a/src/protocols/ssh/user.c
+++ b/src/protocols/ssh/user.c
@@ -74,6 +74,7 @@
/* 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 5edf060..37564a6 100644
--- a/src/protocols/telnet/argv.c
+++ b/src/protocols/telnet/argv.c
@@ -200,3 +200,26 @@
}
+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 aa13dda..4bbf869 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 17abd68..e100fae 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 @@
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 44ef9b5..08cfc6f 100644
--- a/src/protocols/telnet/user.c
+++ b/src/protocols/telnet/user.c
@@ -73,6 +73,7 @@
/* 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);
}