diff --git a/src/protocols/rdp/client.c b/src/protocols/rdp/client.c index afe06164..7ba86224 100644 --- a/src/protocols/rdp/client.c +++ b/src/protocols/rdp/client.c @@ -115,6 +115,7 @@ const char* GUAC_CLIENT_ARGS[] = { "remote-app-dir", "remote-app-args", "static-channels", + "client-name", NULL }; @@ -144,6 +145,7 @@ enum RDP_ARGS_IDX { IDX_REMOTE_APP_DIR, IDX_REMOTE_APP_ARGS, IDX_STATIC_CHANNELS, + IDX_CLIENT_NAME, RDP_ARGS_COUNT }; @@ -666,6 +668,11 @@ int guac_client_init(guac_client* client, int argc, char** argv) { if (argv[IDX_PASSWORD][0] != '\0') settings->password = strdup(argv[IDX_PASSWORD]); + /* Client name */ + settings->client_name = NULL; + if (argv[IDX_CLIENT_NAME][0] != '\0') + settings->client_name = strdup(argv[IDX_CLIENT_NAME]); + /* Initial program */ settings->initial_program = NULL; if (argv[IDX_INITIAL_PROGRAM][0] != '\0') diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index 1fd2d411..24064779 100644 --- a/src/protocols/rdp/rdp_settings.c +++ b/src/protocols/rdp/rdp_settings.c @@ -33,6 +33,7 @@ #endif #include +#include int guac_rdp_get_width(freerdp* rdp) { #ifdef LEGACY_RDPSETTINGS @@ -98,6 +99,17 @@ void guac_rdp_push_settings(guac_rdp_settings* guac_settings, freerdp* rdp) { rdp_settings->KeyboardLayout = guac_settings->server_layout->freerdp_keyboard_layout; #endif + /* Client name */ + if (guac_settings->client_name != NULL) { +#ifdef LEGACY_RDPSETTINGS + strncpy(rdp_settings->client_hostname, guac_settings->client_name, + RDP_CLIENT_HOSTNAME_SIZE - 1); +#else + strncpy(rdp_settings->ClientHostname, guac_settings->client_name, + RDP_CLIENT_HOSTNAME_SIZE - 1); +#endif + } + /* Console */ #ifdef LEGACY_RDPSETTINGS rdp_settings->console_session = guac_settings->console; diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h index 191243a2..be664801 100644 --- a/src/protocols/rdp/rdp_settings.h +++ b/src/protocols/rdp/rdp_settings.h @@ -30,6 +30,12 @@ #include +/** + * The maximum number of bytes in the client hostname claimed during + * connection. + */ +#define RDP_CLIENT_HOSTNAME_SIZE 32 + /** * The default RDP port. */ @@ -169,6 +175,12 @@ typedef struct guac_rdp_settings { */ char* initial_program; + /** + * The name of the client to submit to the RDP server upon connection, or + * NULL if the name is not specified. + */ + char* client_name; + /** * The type of security to use for the connection. */