diff --git a/src/protocols/rdp/rdp.c b/src/protocols/rdp/rdp.c index 47ec75c3..9dea54b5 100644 --- a/src/protocols/rdp/rdp.c +++ b/src/protocols/rdp/rdp.c @@ -25,6 +25,7 @@ #include "client.h" #include "guac_cursor.h" #include "guac_display.h" +#include "guac_recording.h" #include "rdp.h" #include "rdp_bitmap.h" #include "rdp_cliprdr.h" @@ -699,6 +700,14 @@ void* guac_rdp_client_thread(void* data) { /* Init random number generator */ srandom(time(NULL)); + /* Set up screen recording, if requested */ + if (settings->recording_path != NULL) { + guac_common_recording_create(client, + settings->recording_path, + settings->recording_name, + settings->create_recording_path); + } + /* Create display */ rdp_client->display = guac_common_display_alloc(client, rdp_client->settings->width, diff --git a/src/protocols/rdp/rdp_settings.c b/src/protocols/rdp/rdp_settings.c index 2159e8c2..0e90f4dc 100644 --- a/src/protocols/rdp/rdp_settings.c +++ b/src/protocols/rdp/rdp_settings.c @@ -89,6 +89,10 @@ const char* GUAC_RDP_CLIENT_ARGS[] = { "sftp-directory", #endif + "recording-path", + "recording-name", + "create-recording-path", + NULL }; @@ -352,6 +356,10 @@ enum RDP_ARGS_IDX { #endif + IDX_RECORDING_PATH, + IDX_RECORDING_NAME, + IDX_CREATE_RECORDING_PATH, + RDP_ARGS_COUNT }; @@ -673,6 +681,21 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user, IDX_SFTP_DIRECTORY, NULL); #endif + /* Read recording path */ + settings->recording_path = + guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv, + IDX_RECORDING_PATH, NULL); + + /* Read recording name */ + settings->recording_name = + guac_user_parse_args_string(user, GUAC_RDP_CLIENT_ARGS, argv, + IDX_RECORDING_NAME, GUAC_RDP_DEFAULT_RECORDING_NAME); + + /* Parse path creation flag */ + settings->create_recording_path = + guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv, + IDX_CREATE_RECORDING_PATH, 0); + /* Success */ return settings; @@ -688,6 +711,8 @@ void guac_rdp_settings_free(guac_rdp_settings* settings) { free(settings->initial_program); free(settings->password); free(settings->preconnection_blob); + free(settings->recording_name); + free(settings->recording_path); free(settings->remote_app); free(settings->remote_app_args); free(settings->remote_app_dir); diff --git a/src/protocols/rdp/rdp_settings.h b/src/protocols/rdp/rdp_settings.h index 1c197a04..f4c979ab 100644 --- a/src/protocols/rdp/rdp_settings.h +++ b/src/protocols/rdp/rdp_settings.h @@ -56,6 +56,11 @@ */ #define RDP_DEFAULT_DEPTH 16 +/** + * The filename to use for the screen recording, if not specified. + */ +#define GUAC_RDP_DEFAULT_RECORDING_NAME "recording" + /** * All supported combinations of security types. */ @@ -328,6 +333,23 @@ typedef struct guac_rdp_settings { char* sftp_directory; #endif + /** + * The path in which the screen recording should be saved, if enabled. If + * no screen recording should be saved, this will be NULL. + */ + char* recording_path; + + /** + * The filename to use for the screen recording, if enabled. + */ + char* recording_name; + + /** + * Whether the screen recording path should be automatically created if it + * does not already exist. + */ + int create_recording_path; + } guac_rdp_settings; /** diff --git a/src/protocols/ssh/settings.c b/src/protocols/ssh/settings.c index c3f95b94..eb001837 100644 --- a/src/protocols/ssh/settings.c +++ b/src/protocols/ssh/settings.c @@ -50,6 +50,9 @@ const char* GUAC_SSH_CLIENT_ARGS[] = { "typescript-path", "typescript-name", "create-typescript-path", + "recording-path", + "recording-name", + "create-recording-path", NULL }; @@ -140,6 +143,24 @@ enum SSH_ARGS_IDX { */ IDX_CREATE_TYPESCRIPT_PATH, + /** + * The full absolute path to the directory in which screen recordings + * should be written. + */ + IDX_RECORDING_PATH, + + /** + * The name that should be given to screen recording which are written in + * the given path. + */ + IDX_RECORDING_NAME, + + /** + * Whether the specified screen recording path should automatically be + * created if it does not yet exist. + */ + IDX_CREATE_RECORDING_PATH, + SSH_ARGS_COUNT }; @@ -234,6 +255,21 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user, guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv, IDX_CREATE_TYPESCRIPT_PATH, false); + /* Read recording path */ + settings->recording_path = + guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, + IDX_RECORDING_PATH, NULL); + + /* Read recording name */ + settings->recording_name = + guac_user_parse_args_string(user, GUAC_SSH_CLIENT_ARGS, argv, + IDX_RECORDING_NAME, GUAC_SSH_DEFAULT_RECORDING_NAME); + + /* Parse path creation flag */ + settings->create_recording_path = + guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv, + IDX_CREATE_RECORDING_PATH, false); + /* Parsing was successful */ return settings; @@ -262,6 +298,10 @@ void guac_ssh_settings_free(guac_ssh_settings* settings) { free(settings->typescript_name); free(settings->typescript_path); + /* Free screen recording settings */ + free(settings->recording_name); + free(settings->recording_path); + /* Free overall structure */ free(settings); diff --git a/src/protocols/ssh/settings.h b/src/protocols/ssh/settings.h index 9ab2d4ac..9950051c 100644 --- a/src/protocols/ssh/settings.h +++ b/src/protocols/ssh/settings.h @@ -51,6 +51,11 @@ */ #define GUAC_SSH_DEFAULT_TYPESCRIPT_NAME "typescript" +/** + * The filename to use for the screen recording, if not specified. + */ +#define GUAC_SSH_DEFAULT_RECORDING_NAME "recording" + /** * Settings for the SSH connection. The values for this structure are parsed * from the arguments given during the Guacamole protocol handshake using the @@ -157,6 +162,23 @@ typedef struct guac_ssh_settings { */ bool create_typescript_path; + /** + * The path in which the screen recording should be saved, if enabled. If + * no screen recording should be saved, this will be NULL. + */ + char* recording_path; + + /** + * The filename to use for the screen recording, if enabled. + */ + char* recording_name; + + /** + * Whether the screen recording path should be automatically created if it + * does not already exist. + */ + bool create_recording_path; + } guac_ssh_settings; /** diff --git a/src/protocols/ssh/ssh.c b/src/protocols/ssh/ssh.c index 6b539656..a78b784e 100644 --- a/src/protocols/ssh/ssh.c +++ b/src/protocols/ssh/ssh.c @@ -22,6 +22,7 @@ #include "config.h" +#include "guac_recording.h" #include "guac_sftp.h" #include "guac_ssh.h" #include "settings.h" @@ -183,6 +184,14 @@ void* ssh_client_thread(void* data) { if (guac_common_ssh_init(client)) return NULL; + /* Set up screen recording, if requested */ + if (settings->recording_path != NULL) { + guac_common_recording_create(client, + settings->recording_path, + settings->recording_name, + settings->create_recording_path); + } + /* Create terminal */ ssh_client->term = guac_terminal_create(client, settings->font_name, settings->font_size, diff --git a/src/protocols/vnc/settings.c b/src/protocols/vnc/settings.c index e4b467f3..ffff5623 100644 --- a/src/protocols/vnc/settings.c +++ b/src/protocols/vnc/settings.c @@ -71,6 +71,10 @@ const char* GUAC_VNC_CLIENT_ARGS[] = { "sftp-directory", #endif + "recording-path", + "recording-name", + "create-recording-path", + NULL }; @@ -228,6 +232,10 @@ enum VNC_ARGS_IDX { IDX_SFTP_DIRECTORY, #endif + IDX_RECORDING_PATH, + IDX_RECORDING_NAME, + IDX_CREATE_RECORDING_PATH, + VNC_ARGS_COUNT }; @@ -378,6 +386,20 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user, IDX_SFTP_DIRECTORY, NULL); #endif + /* Read recording path */ + settings->recording_path = + guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_RECORDING_PATH, NULL); + + /* Read recording name */ + settings->recording_name = + guac_user_parse_args_string(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_RECORDING_NAME, GUAC_VNC_DEFAULT_RECORDING_NAME); + + /* Parse path creation flag */ + settings->create_recording_path = + guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv, + IDX_CREATE_RECORDING_PATH, false); return settings; @@ -389,6 +411,8 @@ void guac_vnc_settings_free(guac_vnc_settings* settings) { free(settings->clipboard_encoding); free(settings->encodings); free(settings->hostname); + free(settings->recording_name); + free(settings->recording_path); #ifdef ENABLE_VNC_REPEATER /* Free VNC repeater settings */ diff --git a/src/protocols/vnc/settings.h b/src/protocols/vnc/settings.h index da4f3d2f..9f1b2f23 100644 --- a/src/protocols/vnc/settings.h +++ b/src/protocols/vnc/settings.h @@ -28,6 +28,11 @@ #include +/** + * The filename to use for the screen recording, if not specified. + */ +#define GUAC_VNC_DEFAULT_RECORDING_NAME "recording" + /** * VNC-specific client data. */ @@ -173,6 +178,23 @@ typedef struct guac_vnc_settings { char* sftp_directory; #endif + /** + * The path in which the screen recording should be saved, if enabled. If + * no screen recording should be saved, this will be NULL. + */ + char* recording_path; + + /** + * The filename to use for the screen recording, if enabled. + */ + char* recording_name; + + /** + * Whether the screen recording path should be automatically created if it + * does not already exist. + */ + bool create_recording_path; + } guac_vnc_settings; /** diff --git a/src/protocols/vnc/vnc.c b/src/protocols/vnc/vnc.c index 2467f430..da689527 100644 --- a/src/protocols/vnc/vnc.c +++ b/src/protocols/vnc/vnc.c @@ -30,6 +30,7 @@ #include "guac_clipboard.h" #include "guac_cursor.h" #include "guac_display.h" +#include "guac_recording.h" #include "log.h" #include "settings.h" #include "vnc.h" @@ -317,6 +318,14 @@ void* guac_vnc_client_thread(void* data) { /* Set remaining client data */ vnc_client->rfb_client = rfb_client; + /* Set up screen recording, if requested */ + if (settings->recording_path != NULL) { + guac_common_recording_create(client, + settings->recording_path, + settings->recording_name, + settings->create_recording_path); + } + /* Send name */ guac_protocol_send_name(client->socket, rfb_client->desktopName);