Version 1
This commit is contained in:
commit
6c60addfae
5
.gitignore
vendored
Normal file
5
.gitignore
vendored
Normal file
|
@ -0,0 +1,5 @@
|
|||
.*sw?
|
||||
*~
|
||||
|
||||
*.pyc
|
||||
|
30
ssh-wrapper.py
Executable file
30
ssh-wrapper.py
Executable file
|
@ -0,0 +1,30 @@
|
|||
#!/usr/bin/env python
|
||||
|
||||
import os
|
||||
import re
|
||||
import shlex
|
||||
import subprocess
|
||||
import sys
|
||||
|
||||
allowed = [
|
||||
r'^/usr/bin/lsb_release\s+-d$',
|
||||
r'^/usr/lib/nagios/plugins/check_disk -w \d+% -c \d+% -p /[/a-z]*$',
|
||||
r'^/usr/lib/nagios/plugins/check_load -w \d+(,\d+,\d+)? -c \d+(,\d+,\d+)?$',
|
||||
r'^/usr/lib/nagios/plugins/check_mysql -u [a-z]+ -p [0-9a-zA-Z]+',
|
||||
r'^/usr/lib/nagios/plugins/check_mysql_health --user(name)?=[a-z]+ --pass(word)?=[0-9a-zA-Z]+ --mode=[a-z-]+$',
|
||||
]
|
||||
|
||||
#cmdline = ' '.join(sys.argv[1:])
|
||||
cmdline = os.getenv('SSH_ORIGINAL_COMMAND')
|
||||
|
||||
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)
|
||||
|
||||
print '%s: No command found!' % sys.argv[0]
|
||||
sys.exit(3)
|
||||
|
Loading…
Reference in a new issue