Version 3
This commit is contained in:
parent
51d9b33ef0
commit
eef01a1064
|
@ -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)
|
||||
|
||||
|
|
Loading…
Reference in a new issue