Skip to content

Commit e579d4d

Browse files
committed
add new flag
1 parent e775052 commit e579d4d

12 files changed

Lines changed: 108 additions & 0 deletions

File tree

src/protocols/rdp/rdp.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -940,6 +940,14 @@ void* guac_rdp_client_thread(void* data) {
940940
settings->recording_include_keys,
941941
settings->recording_write_existing,
942942
settings->recording_include_clipboard);
943+
944+
/* If recording is required but failed, abort the connection */
945+
if (rdp_client->recording == NULL && settings->require_recording) {
946+
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
947+
"Session recording is required but could not be created. "
948+
"Aborting connection.");
949+
return NULL;
950+
}
943951
}
944952

945953
/* Continue handling connections until error or client disconnect */

src/protocols/rdp/settings.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -128,6 +128,7 @@ const char* GUAC_RDP_CLIENT_ARGS[] = {
128128
"recording-include-clipboard",
129129
"create-recording-path",
130130
"recording-write-existing",
131+
"require-recording",
131132
"resize-method",
132133
"enable-audio-input",
133134
"enable-touch",
@@ -604,6 +605,12 @@ enum RDP_ARGS_IDX {
604605
*/
605606
IDX_RECORDING_WRITE_EXISTING,
606607

608+
/**
609+
* Whether recording is required. If set to "true", the connection will
610+
* be closed if the recording cannot be created for any reason.
611+
*/
612+
IDX_REQUIRE_RECORDING,
613+
607614
/**
608615
* The method to use to apply screen size changes requested by the user.
609616
* Valid values are blank, "display-update", and "reconnect".
@@ -1232,6 +1239,11 @@ guac_rdp_settings* guac_rdp_parse_args(guac_user* user,
12321239
guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,
12331240
IDX_RECORDING_WRITE_EXISTING, 0);
12341241

1242+
/* Parse require recording flag */
1243+
settings->require_recording =
1244+
guac_user_parse_args_boolean(user, GUAC_RDP_CLIENT_ARGS, argv,
1245+
IDX_REQUIRE_RECORDING, 0);
1246+
12351247
/* No resize method */
12361248
if (strcmp(argv[IDX_RESIZE_METHOD], "") == 0) {
12371249
guac_user_log(user, GUAC_LOG_INFO, "Resize method: none");

src/protocols/rdp/settings.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,13 @@ typedef struct guac_rdp_settings {
605605
*/
606606
int recording_write_existing;
607607

608+
/**
609+
* Non-zero if the connection should be closed when a recording cannot be
610+
* created. Zero by default, meaning the connection will proceed even if
611+
* recording fails.
612+
*/
613+
int require_recording;
614+
608615
/**
609616
* The method to apply when the user's display changes size.
610617
*/

src/protocols/ssh/settings.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,7 @@ const char* GUAC_SSH_CLIENT_ARGS[] = {
7070
"recording-include-clipboard",
7171
"create-recording-path",
7272
"recording-write-existing",
73+
"require-recording",
7374
"read-only",
7475
"server-alive-interval",
7576
"backspace",
@@ -277,6 +278,12 @@ enum SSH_ARGS_IDX {
277278
*/
278279
IDX_RECORDING_WRITE_EXISTING,
279280

281+
/**
282+
* Whether recording is required. If set to "true", the connection will
283+
* be closed if the recording cannot be created for any reason.
284+
*/
285+
IDX_REQUIRE_RECORDING,
286+
280287
/**
281288
* "true" if this connection should be read-only (user input should be
282289
* dropped), "false" or blank otherwise.
@@ -562,6 +569,11 @@ guac_ssh_settings* guac_ssh_parse_args(guac_user* user,
562569
guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
563570
IDX_RECORDING_WRITE_EXISTING, false);
564571

572+
/* Parse require recording flag */
573+
settings->require_recording =
574+
guac_user_parse_args_boolean(user, GUAC_SSH_CLIENT_ARGS, argv,
575+
IDX_REQUIRE_RECORDING, false);
576+
565577
/* Parse server alive interval */
566578
settings->server_alive_interval =
567579
guac_user_parse_args_int(user, GUAC_SSH_CLIENT_ARGS, argv,

src/protocols/ssh/settings.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -288,6 +288,13 @@ typedef struct guac_ssh_settings {
288288
*/
289289
bool recording_write_existing;
290290

291+
/**
292+
* Non-zero if the connection should be closed when a recording cannot be
293+
* created. Zero by default, meaning the connection will proceed even if
294+
* recording fails.
295+
*/
296+
bool require_recording;
297+
291298
/**
292299
* The number of seconds between sending server alive messages.
293300
*/

src/protocols/ssh/ssh.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,14 @@ void* ssh_client_thread(void* data) {
294294
settings->recording_include_keys,
295295
settings->recording_write_existing,
296296
settings->recording_include_clipboard);
297+
298+
/* If recording is required but failed, abort the connection */
299+
if (ssh_client->recording == NULL && settings->require_recording) {
300+
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
301+
"Session recording is required but could not be created. "
302+
"Aborting connection.");
303+
return NULL;
304+
}
297305
}
298306

299307
/* Create terminal options with required parameters */

src/protocols/telnet/settings.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,7 @@ const char* GUAC_TELNET_CLIENT_ARGS[] = {
6161
"recording-include-clipboard",
6262
"create-recording-path",
6363
"recording-write-existing",
64+
"require-recording",
6465
"read-only",
6566
"backspace",
6667
"func-keys-and-keypad",
@@ -223,6 +224,12 @@ enum TELNET_ARGS_IDX {
223224
*/
224225
IDX_RECORDING_WRITE_EXISTING,
225226

227+
/**
228+
* Whether recording is required. If set to "true", the connection will
229+
* be closed if the recording cannot be created for any reason.
230+
*/
231+
IDX_REQUIRE_RECORDING,
232+
226233
/**
227234
* "true" if this connection should be read-only (user input should be
228235
* dropped), "false" or blank otherwise.
@@ -542,6 +549,11 @@ guac_telnet_settings* guac_telnet_parse_args(guac_user* user,
542549
guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv,
543550
IDX_RECORDING_WRITE_EXISTING, false);
544551

552+
/* Parse require recording flag */
553+
settings->require_recording =
554+
guac_user_parse_args_boolean(user, GUAC_TELNET_CLIENT_ARGS, argv,
555+
IDX_REQUIRE_RECORDING, false);
556+
545557
/* Parse backspace key code */
546558
settings->backspace =
547559
guac_user_parse_args_int(user, GUAC_TELNET_CLIENT_ARGS, argv,

src/protocols/telnet/settings.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -264,6 +264,13 @@ typedef struct guac_telnet_settings {
264264
*/
265265
bool recording_write_existing;
266266

267+
/**
268+
* Non-zero if the connection should be closed when a recording cannot be
269+
* created. Zero by default, meaning the connection will proceed even if
270+
* recording fails.
271+
*/
272+
bool require_recording;
273+
267274
/**
268275
* The ASCII code, as an integer, that the telnet client will use when the
269276
* backspace key is pressed. By default, this is 127, ASCII delete, if

src/protocols/telnet/telnet.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,14 @@ void* guac_telnet_client_thread(void* data) {
550550
settings->recording_include_keys,
551551
settings->recording_write_existing,
552552
settings->recording_include_clipboard);
553+
554+
/* If recording is required but failed, abort the connection */
555+
if (telnet_client->recording == NULL && settings->require_recording) {
556+
guac_client_abort(client, GUAC_PROTOCOL_STATUS_SERVER_ERROR,
557+
"Session recording is required but could not be created. "
558+
"Aborting connection.");
559+
return NULL;
560+
}
553561
}
554562

555563
/* Create terminal options with required parameters */

src/protocols/vnc/settings.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ const char* GUAC_VNC_CLIENT_ARGS[] = {
9292
"recording-include-clipboard",
9393
"create-recording-path",
9494
"recording-write-existing",
95+
"require-recording",
9596
"clipboard-buffer-size",
9697
"disable-copy",
9798
"disable-paste",
@@ -378,6 +379,12 @@ enum VNC_ARGS_IDX {
378379
*/
379380
IDX_RECORDING_WRITE_EXISTING,
380381

382+
/**
383+
* Whether recording is required. If set to "true", the connection will
384+
* be closed if the recording cannot be created for any reason.
385+
*/
386+
IDX_REQUIRE_RECORDING,
387+
381388
/**
382389
* The maximum number of bytes to allow within the clipboard.
383390
*/
@@ -704,6 +711,11 @@ guac_vnc_settings* guac_vnc_parse_args(guac_user* user,
704711
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
705712
IDX_RECORDING_WRITE_EXISTING, false);
706713

714+
/* Parse require recording flag */
715+
settings->require_recording =
716+
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,
717+
IDX_REQUIRE_RECORDING, false);
718+
707719
/* Parse clipboard copy disable flag */
708720
settings->disable_copy =
709721
guac_user_parse_args_boolean(user, GUAC_VNC_CLIENT_ARGS, argv,

0 commit comments

Comments
 (0)