diff --git a/ssh-wrapper.py b/ssh-wrapper.py index 0c52dd1..8aea125 100755 --- a/ssh-wrapper.py +++ b/ssh-wrapper.py @@ -16,15 +16,23 @@ allowed = [ ] cmdline = os.getenv('SSH_ORIGINAL_COMMAND') +if not cmdline: + print 'This is just a wrapper, no command specified!' + sys.exit(3) for maybe in allowed: if re.match(maybe, cmdline): cmdline = shlex.split(cmdline) - cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE) - print cmd.communicate()[0].rstrip() - sys.exit(cmd.returncode) + try: + cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE) + except Exception, exc: + print 'Could not execute plugin ("%s"): %s' % (' '.join(cmdline), exc) + sys.exit(3) + else: + print cmd.communicate()[0].rstrip() + sys.exit(cmd.returncode) -print '%s: No command found!' % sys.argv[0] +print '%s: No allowed command found!' % sys.argv[0] sys.exit(3)