summaryrefslogtreecommitdiffstats
path: root/contrib/restrict.pl
diff options
context:
space:
mode:
authorEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 (GMT)
committerEthan Galstad <egalstad@users.sourceforge.net>2002-02-28 06:42:51 (GMT)
commit44a321cb8a42d6c0ea2d96a1086a17f2134c89cc (patch)
treea1a4d9f7b92412a17ab08f34f04eec45433048b7 /contrib/restrict.pl
parent54fd5d7022ff2d6a59bc52b8869182f3fc77a058 (diff)
downloadmonitoring-plugins-44a321cb8a42d6c0ea2d96a1086a17f2134c89cc.tar.gz
Initial revision
git-svn-id: https://nagiosplug.svn.sourceforge.net/svnroot/nagiosplug/nagiosplug/trunk@2 f882894a-f735-0410-b71e-b25c423dba1c
Diffstat (limited to 'contrib/restrict.pl')
-rwxr-xr-xcontrib/restrict.pl26
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
3eval 'exec /usr/bin/perl -S $0 ${1+"$@"}'
4 if 0;
5
6# Set this to your local Nagios plugin path
7my $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.
12my %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
21if (!defined ($cmd = $legal_cmds{$arg[0]}))
22{
23 $cmd = $pluginpath . $arg[0];
24}
25
26exec { $cmd } @arg or die "Can't exec $cmd: $!";