Version 3

This commit is contained in:
Sven Velt 2017-11-29 11:57:11 +01:00
parent 51d9b33ef0
commit eef01a1064

View file

@ -16,15 +16,23 @@ allowed = [
] ]
cmdline = os.getenv('SSH_ORIGINAL_COMMAND') 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: for maybe in allowed:
if re.match(maybe, cmdline): if re.match(maybe, cmdline):
cmdline = shlex.split(cmdline) cmdline = shlex.split(cmdline)
cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE) try:
print cmd.communicate()[0].rstrip() cmd = subprocess.Popen(cmdline, stdout=subprocess.PIPE)
sys.exit(cmd.returncode) 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) sys.exit(3)