summaryrefslogtreecommitdiff
path: root/src/plugins/relay
diff options
context:
space:
mode:
authorSébastien Helleu <flashcode@flashtux.org>2019-02-28 20:24:25 +0100
committerSébastien Helleu <flashcode@flashtux.org>2019-02-28 20:24:25 +0100
commitd290de2cbab37e55234dadee96d54a4d94bd3149 (patch)
tree4846815609d9e65c3c4ddace3ffa4df4a23e1e3e /src/plugins/relay
parent80b980b2af71faa9a2d825c61a5d41d7ace0dc60 (diff)
downloadweechat-d290de2cbab37e55234dadee96d54a4d94bd3149.zip
relay: add option relay.weechat.commands (closes #928)
Diffstat (limited to 'src/plugins/relay')
-rw-r--r--src/plugins/relay/relay-config.c35
-rw-r--r--src/plugins/relay/relay-config.h2
-rw-r--r--src/plugins/relay/weechat/relay-weechat-protocol.c17
3 files changed, 53 insertions, 1 deletions
diff --git a/src/plugins/relay/relay-config.c b/src/plugins/relay/relay-config.c
index fdfbe5027..dccb025c5 100644
--- a/src/plugins/relay/relay-config.c
+++ b/src/plugins/relay/relay-config.c
@@ -75,6 +75,10 @@ struct t_config_option *relay_config_irc_backlog_since_last_message;
struct t_config_option *relay_config_irc_backlog_tags;
struct t_config_option *relay_config_irc_backlog_time_format;
+/* relay config, weechat section */
+
+struct t_config_option *relay_config_weechat_commands;
+
/* other */
regex_t *relay_config_regex_allowed_ips = NULL;
@@ -1003,6 +1007,37 @@ relay_config_init ()
NULL, 0, 0, "[%H:%M] ", NULL, 0,
NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
+ /* section weechat */
+ ptr_section = weechat_config_new_section (relay_config_file, "weechat",
+ 0, 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
+ if (!ptr_section)
+ {
+ weechat_config_free (relay_config_file);
+ relay_config_file = NULL;
+ return 0;
+ }
+
+ relay_config_weechat_commands = weechat_config_new_option (
+ relay_config_file, ptr_section,
+ "commands", "string",
+ N_("comma-separated list of commands allowed/denied when input "
+ "data (text or command) is received from a client; "
+ "\"*\" means any command, a name beginning with \"!\" is "
+ "a negative value to prevent a command from being executed, "
+ "wildcard \"*\" is allowed in names; by default all commands "
+ "are allowed except /exec, /upgrade and /quit (which could lead "
+ "to denial of service or remote code execution if the client is "
+ "not trusted)"),
+ NULL, 0, 0, "*,!exec,!upgrade,!quit", NULL, 0,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL,
+ NULL, NULL, NULL);
+
/* section port */
ptr_section = weechat_config_new_section (
relay_config_file, "port",
diff --git a/src/plugins/relay/relay-config.h b/src/plugins/relay/relay-config.h
index d05721d04..14fce3420 100644
--- a/src/plugins/relay/relay-config.h
+++ b/src/plugins/relay/relay-config.h
@@ -57,6 +57,8 @@ extern struct t_config_option *relay_config_irc_backlog_since_last_message;
extern struct t_config_option *relay_config_irc_backlog_tags;
extern struct t_config_option *relay_config_irc_backlog_time_format;
+extern struct t_config_option *relay_config_weechat_commands;
+
extern regex_t *relay_config_regex_allowed_ips;
extern regex_t *relay_config_regex_websocket_allowed_origins;
extern struct t_hashtable *relay_config_hashtable_irc_backlog_tags;
diff --git a/src/plugins/relay/weechat/relay-weechat-protocol.c b/src/plugins/relay/weechat/relay-weechat-protocol.c
index 9ea66947a..1cc94af24 100644
--- a/src/plugins/relay/weechat/relay-weechat-protocol.c
+++ b/src/plugins/relay/weechat/relay-weechat-protocol.c
@@ -404,6 +404,7 @@ relay_weechat_protocol_input_timer_cb (const void *pointer,
char **timer_args;
int i;
struct t_gui_buffer *ptr_buffer;
+ struct t_hashtable *options;
/* make C compiler happy */
(void) data;
@@ -418,7 +419,21 @@ relay_weechat_protocol_input_timer_cb (const void *pointer,
{
ptr_buffer = weechat_buffer_search ("==", timer_args[0]);
if (ptr_buffer)
- weechat_command (ptr_buffer, timer_args[1]);
+ {
+ options = weechat_hashtable_new (8,
+ WEECHAT_HASHTABLE_STRING,
+ WEECHAT_HASHTABLE_STRING,
+ NULL, NULL);
+ if (options)
+ {
+ weechat_hashtable_set (
+ options,
+ "commands",
+ weechat_config_string (relay_config_weechat_commands));
+ weechat_command_options (ptr_buffer, timer_args[1], options);
+ weechat_hashtable_free (options);
+ }
+ }
}
for (i = 0; i < 2; i++)