diff --git a/gui-daemon/xside.c b/gui-daemon/xside.c index 99282356..22ef3d20 100644 --- a/gui-daemon/xside.c +++ b/gui-daemon/xside.c @@ -1274,6 +1274,38 @@ static void handle_clipboard_data(Ghandles * g, unsigned int untrusted_len) save_clipboard_file_xevent_timestamp(g->clipboard_xevent_time); metadata.successful = true; save_clipboard_metadata(&metadata); + + if (g->clipboard_timeout > 0) { + switch (fork()) { + case -1: + perror("fork"); + exit(1); + case 0: + struct stat st0, st1; + if (lstat(QUBES_CLIPBOARD_FILENAME, &st0) == -1) { + perror("Can not get clipboard data file status"); + exit(1); + } + sleep(g->clipboard_timeout); + if (lstat(QUBES_CLIPBOARD_FILENAME, &st1) == -1) { + perror("Can not get clipboard data file status"); + exit(1); + } + if (st0.st_mtime == st1.st_mtime) { + inter_appviewer_lock(g, 1); + old_umask = umask(0007); + metadata.copy_action = false; + clear_clipboard(&metadata); + umask(old_umask); + inter_appviewer_lock(g, 0); + if (g->log_level > 1) + fprintf(stderr, "Clipboard cleared after %d seconds\n", + g->clipboard_timeout); + } + _exit(1); + } + } + error: umask(old_umask); inter_appviewer_lock(g, 0); @@ -4346,6 +4378,7 @@ static void load_default_config_values(Ghandles * g) g->paste_seq_mask = ControlMask | ShiftMask; g->paste_seq_key = XK_v; g->clipboard_buffer_size = DEFAULT_CLIPBOARD_BUFFER_SIZE; + g->clipboard_timeout = 0; g->allow_fullscreen = 0; g->override_redirect_protection = 1; g->startup_timeout = 45; @@ -4430,6 +4463,11 @@ static void parse_vm_config(Ghandles * g, config_setting_t * group) } } + if ((setting = + config_setting_get_member(group, "clipboard_timeout"))) { + g->clipboard_timeout = config_setting_get_int(setting); + } + if ((setting = config_setting_get_member(group, "allow_utf8_titles"))) { g->allow_utf8_titles = config_setting_get_bool(setting); diff --git a/gui-daemon/xside.h b/gui-daemon/xside.h index a0ad00db..f740a0e7 100644 --- a/gui-daemon/xside.h +++ b/gui-daemon/xside.h @@ -220,6 +220,7 @@ struct _global_handles { KeySym paste_seq_key; /* key for secure-paste key sequence */ unsigned int clipboard_buffer_size; /* maximum clipboard size limit */ int qrexec_clipboard; /* 0: use GUI protocol to fetch/put clipboard, 1: use qrexec */ + int clipboard_timeout; /* x: clear global clipboard after x seconds, 0: do not clear */ int use_kdialog; /* use kdialog for prompts (default on KDE) or zenity (default on non-KDE) */ int prefix_titles; /* prefix windows titles with VM name (for WM without support for _QUBES_VMNAME property) */ enum trayicon_mode trayicon_mode; /* trayicon coloring mode */