Skip to content

Commit

Permalink
termio.py: Added a new attribute: `MultiplexPOSIXIOLoop.shell_command…
Browse files Browse the repository at this point in the history
…`. It controls what command is used to execute commands. By default it is, `["/bin/sh", "-c"]` but you can override it with a string or a list of your choosing *after* the Multiplex instance is created. so that'd be: `m = Multiplex('some_command.sh'); m.shell_command = '/bin/bash -c'`

app_terminal.py:  Added a new setting you can add to your 50terminal.conf to override the default "/bin/sh -c" command that's used to execute all terminal commands.  It modifies the `Multiplex.shell_command` described above.  You can use a string or a list in the `shell_command` setting (in 50terminal.conf).
  • Loading branch information
liftoff committed Sep 22, 2013
1 parent a0ff3ca commit 7af8de6
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 3 deletions.
9 changes: 9 additions & 0 deletions gateone/applications/terminal/app_terminal.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']:
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion gateone/gateone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
__version_info__ = (1, 2, 0)
__license__ = "AGPLv3 or Proprietary (see LICENSE.txt)"
__author__ = 'Dan McDougall <[email protected]>'
__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__ = '''\
Expand Down
2 changes: 1 addition & 1 deletion gateone/static/gateone.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 5 additions & 1 deletion termio/termio.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7af8de6

Please sign in to comment.