From 46c33ddaf402843a3546eb0ae8e6ac4b62da525f Mon Sep 17 00:00:00 2001 From: Jaroslaw Osmanski Date: Tue, 26 Feb 2019 11:36:32 +0100 Subject: [PATCH] Read sesman config in clipboard --- sesman/chansrv/clipboard.c | 41 +++++++++++++++++++++++--------------- sesman/chansrv/config.c | 1 + sesman/config.c | 8 ++++---- sesman/config.h | 5 +++-- 4 files changed, 33 insertions(+), 22 deletions(-) create mode 100644 sesman/chansrv/config.c diff --git a/sesman/chansrv/clipboard.c b/sesman/chansrv/clipboard.c index ae2e34ca..1d6357da 100644 --- a/sesman/chansrv/clipboard.c +++ b/sesman/chansrv/clipboard.c @@ -230,7 +230,7 @@ static char g_bmp_image_header[] = extern int g_cliprdr_chan_id; /* in chansrv.c */ -struct config_sesman g_cfg /* config.h */ +struct config_sesman *g_cfg; /* config.h */ extern Display *g_display; /* in xcommon.c */ extern int g_x_socket; /* in xcommon.c */ @@ -381,16 +381,24 @@ clipboard_init(void) return 0; } - if (0 != config_read(&g_cfg)) - { - g_printf("clipboard: error reading config. quitting.\n"); - return 1; - } + /* reading config */ + g_cfg = g_new0(struct config_sesman, 1); - log_debug("clipboard_init: outbound clipboard restricted -> " + g_cfg.sec.restrict_oubound_clipboard) - //one-way clipboard - g_outbound_clipboard_restricted = g_cfg.sec.restrict_oubound_clipboard; + if (0 == g_cfg) + { + g_printf("error creating config: quitting.\n"); + g_deinit(); + g_exit(1); + } + if (0 != config_read(g_cfg)) + { + log_error("clipboard: error reading config. quitting."); + return 1; + } + + //one-way clipboard + g_outbound_clipboard_restricted = g_cfg->sec.restrict_outbound_clipboard; xfuse_init(); xcommon_init(); @@ -2513,13 +2521,14 @@ clipboard_xevent(void *xevent) switch (lxevent->type) { case SelectionNotify: - if (g_outbound_clipboard_restricted == 0) { - log_debug("clipboard_xevent: clipboard SelectionNotify event on xorg.") - clipboard_event_selection_notify(lxevent); - } else { - log_debug("clipboard_xevent: clipboard restricted, ignoring xorg event.") - return 1; - } + if (g_outbound_clipboard_restricted == 0) + { + clipboard_event_selection_notify(lxevent); + } + else + { + return 1; + } break; case SelectionRequest: clipboard_event_selection_request(lxevent); diff --git a/sesman/chansrv/config.c b/sesman/chansrv/config.c new file mode 100644 index 00000000..82a7fbd5 --- /dev/null +++ b/sesman/chansrv/config.c @@ -0,0 +1 @@ +#include "../config.c" \ No newline at end of file diff --git a/sesman/config.c b/sesman/config.c index 4f58f866..a42bb47f 100644 --- a/sesman/config.c +++ b/sesman/config.c @@ -235,7 +235,7 @@ config_read_security(int file, struct config_security *sc, sc->login_retry = 3; sc->ts_users_enable = 0; sc->ts_admins_enable = 0; - sc->restrict_oubound_clipboard = 0; + sc->restrict_outbound_clipboard = 0; file_read_section(file, SESMAN_CFG_SECURITY, param_n, param_v); @@ -274,10 +274,10 @@ config_read_security(int file, struct config_security *sc, { sc->ts_always_group_check = g_text2bool((char *)list_get_item(param_v, i)); } - + if (0 == g_strcasecmp(buf, SESMAN_CFG_RESTRICT_CLIPBOARD)) { - sc->restrict_oubound_clipboard = g_text2bool((char *)list_get_item(param_v, i)); + sc->restrict_outbound_clipboard = g_text2bool((char *)list_get_item(param_v, i)); } @@ -505,7 +505,7 @@ config_dump(struct config_sesman *config) g_writeln(" AllowRootLogin: %d", sc->allow_root); g_writeln(" MaxLoginRetry: %d", sc->login_retry); g_writeln(" AlwaysGroupCheck: %d", sc->ts_always_group_check); - g_printf("\tRestrictOutboundClipboard: %i\r\n", sc->restrict_oubound_clipboard); + g_writeln(" RestrictOutboundClipboard: %d", sc->restrict_outbound_clipboard); g_printf( " TSUsersGroup: "); if (sc->ts_users_enable) diff --git a/sesman/config.h b/sesman/config.h index 1ba224c9..b8e8bc76 100644 --- a/sesman/config.h +++ b/sesman/config.h @@ -60,6 +60,7 @@ #define SESMAN_CFG_SEC_USR_GROUP "TerminalServerUsers" #define SESMAN_CFG_SEC_ADM_GROUP "TerminalServerAdmins" #define SESMAN_CFG_SEC_ALWAYSGROUPCHECK "AlwaysGroupCheck" +#define SESMAN_CFG_RESTRICT_CLIPBOARD "RestrictOutboundClipboard" #define SESMAN_CFG_SESSIONS "Sessions" #define SESMAN_CFG_SESS_MAX "MaxSessions" @@ -127,10 +128,10 @@ struct config_security */ int ts_always_group_check; /** - * @var restrict_oubound_clipboard + * @var restrict_outbound_clipboard * @brief if the clipboard should be enforced restricted. If true only allow client -> server, not vice versa. */ - int restrict_oubound_clipboard; + int restrict_outbound_clipboard; }; /**