diff options
Diffstat (limited to 'contrib/restrict.pl')
-rwxr-xr-x | contrib/restrict.pl | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/contrib/restrict.pl b/contrib/restrict.pl new file mode 100755 index 0000000..75ea569 --- /dev/null +++ b/contrib/restrict.pl | |||
@@ -0,0 +1,26 @@ | |||
1 | #!/usr/bin/perl | ||
2 | |||
3 | eval 'exec /usr/bin/perl -S $0 ${1+"$@"}' | ||
4 | if 0; | ||
5 | |||
6 | # Set this to your local Nagios plugin path | ||
7 | my $pluginpath = "/usr/libexec/nagios/plugins/"; | ||
8 | |||
9 | # Put all the legal commands (i.e. the commands that are | ||
10 | # not Nagios checks but are allowed to be executed anyway) | ||
11 | # in the following associative array. | ||
12 | my %legal_cmds = ("nc" => "/usr/sbin/nc"); | ||
13 | |||
14 | # This will not work on OpenSSH | ||
15 | # It does work on ssh-1.2.27-1i | ||
16 | @arg = split ' ',$ENV{'SSH_ORIGINAL_COMMAND'}; | ||
17 | |||
18 | $arg[0] =~ s/.*\///; # strip leading path | ||
19 | $arg[0] =~ tr/-_.a-zA-Z0-9/X/c; # change atypical chars to X | ||
20 | |||
21 | if (!defined ($cmd = $legal_cmds{$arg[0]})) | ||
22 | { | ||
23 | $cmd = $pluginpath . $arg[0]; | ||
24 | } | ||
25 | |||
26 | exec { $cmd } @arg or die "Can't exec $cmd: $!"; | ||