diff --git a/gateone/applications/terminal/app_terminal.py b/gateone/applications/terminal/app_terminal.py index 7c003f34..afaa2a30 100644 --- a/gateone/applications/terminal/app_terminal.py +++ b/gateone/applications/terminal/app_terminal.py @@ -483,6 +483,12 @@ def authenticate(self): # Get our user-specific settings/policies for quick reference self.policy = applicable_policies( 'terminal', self.current_user, self.ws.prefs) + # NOTE: If you want to be able to check policies on-the-fly without + # requiring the user reload the page when a change is made make sure + # call applicable_policies() on your own using self.ws.prefs every time + # you want to check them. This will ensure it's always up-to-date. + # NOTE: applicable_policies() is memoized so calling it over and over + # again shouldn't slow anything down. # Start by determining if the user can even login to the terminal app if 'allow' in self.policy: if not self.policy['allow']: @@ -859,6 +865,7 @@ def new_multiplex(self, import termio policies = applicable_policies( 'terminal', self.current_user, self.ws.prefs) + shell_command = policies.get('shell_command', None) user_dir = self.settings['user_dir'] try: user = self.current_user['upn'] @@ -907,6 +914,8 @@ def new_multiplex(self, additional_metadata=additional_log_metadata, encoding=encoding ) + if shell_command: + m.shell_command = shell_command if self.plugin_new_multiplex_hooks: for func in self.plugin_new_multiplex_hooks: func(self, m) diff --git a/gateone/gateone.py b/gateone/gateone.py index 017a29ec..7d2d0702 100755 --- a/gateone/gateone.py +++ b/gateone/gateone.py @@ -10,7 +10,7 @@ __version_info__ = (1, 2, 0) __license__ = "AGPLv3 or Proprietary (see LICENSE.txt)" __author__ = 'Dan McDougall ' -__commit__ = "20130921180952" # Gets replaced by git (holds the date/time) +__commit__ = "20130921184738" # Gets replaced by git (holds the date/time) # NOTE: Docstring includes reStructuredText markup for use with Sphinx. __doc__ = '''\ diff --git a/gateone/static/gateone.js b/gateone/static/gateone.js index 87e29b74..b440e7a6 100644 --- a/gateone/static/gateone.js +++ b/gateone/static/gateone.js @@ -87,7 +87,7 @@ The base object for all Gate One modules/plugins. */ GateOne.__name__ = "GateOne"; GateOne.__version__ = "1.2"; -GateOne.__commit__ = "20130921180952"; +GateOne.__commit__ = "20130921184738"; GateOne.__repr__ = function () { return "[" + this.__name__ + " " + this.__version__ + "]"; }; diff --git a/termio/termio.py b/termio/termio.py index 6b5334f0..1e25a23b 100644 --- a/termio/termio.py +++ b/termio/termio.py @@ -1183,6 +1183,7 @@ def __init__(self, *args, **kwargs): from tornado import ioloop self.terminating = False self.sent_sigint = False + self.shell_command = ['/bin/sh', '-c'] self.env = {} self.io_loop = ioloop.IOLoop.instance() # Monitors child for activity #self.io_loop.set_blocking_signal_threshold(2, self._blocked_io_handler) @@ -1331,7 +1332,10 @@ def spawn(self, # setting the title when the command first runs). # 2) Ensures we capture all output from the fd before it gets # closed. - cmd = ['/bin/sh', '-c', self.cmd + '; sleep .1'] + if not isinstance(self.shell_command, list): + import shlex + self.shell_command = shlex.split(self.shell_command) + cmd = self.shell_command + [self.cmd + '; sleep .1'] os.dup2(stderr, stdout) # Copy stderr to stdout (equivalent to 2>&1) os.execvpe(cmd[0], cmd, env) os._exit(0)