Commit 2257da6c authored by Daniel Brötzmann's avatar Daniel Brötzmann Committed by Philipp Hörist

CommandSystem: Add setting to disable execution of commands by default

parent 911aaa1f
...@@ -37,9 +37,14 @@ from os.path import expanduser ...@@ -37,9 +37,14 @@ from os.path import expanduser
from gi.repository import GLib from gi.repository import GLib
from gajim.common import app
from gajim.common.i18n import _ from gajim.common.i18n import _
from gajim.command_system.framework import CommandContainer, command, doc from gajim.command_system.framework import CommandContainer
from gajim.command_system.implementation.hosts import ChatCommands, PrivateChatCommands, GroupChatCommands from gajim.command_system.framework import command
from gajim.command_system.framework import doc
from gajim.command_system.implementation.hosts import ChatCommands
from gajim.command_system.implementation.hosts import PrivateChatCommands
from gajim.command_system.implementation.hosts import GroupChatCommands
class Execute(CommandContainer): class Execute(CommandContainer):
...@@ -57,10 +62,18 @@ class Execute(CommandContainer): ...@@ -57,10 +62,18 @@ class Execute(CommandContainer):
@classmethod @classmethod
def spawn(cls, processor, expression): def spawn(cls, processor, expression):
pipes = dict(stdout=PIPE, stderr=PIPE) command_system_execute = app.config.get('command_system_execute')
directory = expanduser(cls.DIRECTORY) if command_system_execute:
popen = Popen(expression, shell=True, cwd=directory, **pipes) pipes = dict(stdout=PIPE, stderr=PIPE)
cls.monitor(processor, popen) directory = expanduser(cls.DIRECTORY)
popen = Popen(expression, shell=True, cwd=directory, **pipes)
cls.monitor(processor, popen)
_('Command disabled. This command can be enabled by '
'setting \'command_system_execute\' to True in ACE '
'(Advanced Configuration Editor).'))
@classmethod @classmethod
def monitor(cls, processor, popen): def monitor(cls, processor, popen):
...@@ -288,6 +288,7 @@ class Config: ...@@ -288,6 +288,7 @@ class Config:
'muclumbus_api_http_uri': [opt_str, ''], 'muclumbus_api_http_uri': [opt_str, ''],
'muclumbus_api_pref': [opt_str, 'http', _('API Preferences. Possible values: \'http\', \'iq\'')], 'muclumbus_api_pref': [opt_str, 'http', _('API Preferences. Possible values: \'http\', \'iq\'')],
'auto_copy': [opt_bool, True, _('Selecting text will copy it to the clipboard')], 'auto_copy': [opt_bool, True, _('Selecting text will copy it to the clipboard')],
'command_system_execute': [opt_bool, False, _('If enabled, Gajim will execute commands (/show, /sh, /execute, /exec).')],
}, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]] }, {}) # type: Tuple[Dict[str, List[Any]], Dict[Any, Any]]
__options_per_key = { __options_per_key = {
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment