Jelajahi Sumber

Fix trusted path

When configuring the plugins you have the option to specify a trusted path with --with-trusted-path. This option seems to have been deprecated at some point for unknown reasons and had typically had no affect. This commit makes this option work again for those who have a desire to use it. There should be no affect on those who have not chosen to specify a trusted path.
awiddersheim 12 tahun lalu
induk
melakukan
3c1b67d62a

+ 1 - 1
plugins-scripts/check_breeze.pl

@@ -13,7 +13,7 @@ $PROGNAME = "check_breeze";
 sub print_help ();
 sub print_usage ();
 
-$ENV{'PATH'}='';
+$ENV{'PATH'}='@trusted_path@';
 $ENV{'BASH_ENV'}=''; 
 $ENV{'ENV'}='';
 

+ 1 - 1
plugins-scripts/check_disk_smb.pl

@@ -33,7 +33,7 @@ sub print_usage ();
 
 $PROGNAME = "check_disk_smb";
 
-$ENV{'PATH'}='';
+$ENV{'PATH'}='@trusted_path@';
 $ENV{'BASH_ENV'}=''; 
 $ENV{'ENV'}='';
 

+ 4 - 0
plugins-scripts/check_file_age.pl

@@ -37,6 +37,10 @@ my ($result, $message, $age, $size, $st);
 
 $PROGNAME="check_file_age";
 
+$ENV{'PATH'}='@trusted_path@';
+$ENV{'BASH_ENV'}=''; 
+$ENV{'ENV'}='';
+
 $opt_w = 240;
 $opt_c = 600;
 $opt_W = 0;

+ 1 - 1
plugins-scripts/check_flexlm.pl

@@ -44,7 +44,7 @@ $PROGNAME="check_flexlm";
 sub print_help ();
 sub print_usage ();
 
-$ENV{'PATH'}='';
+$ENV{'PATH'}='@trusted_path@';
 $ENV{'BASH_ENV'}=''; 
 $ENV{'ENV'}='';
 

+ 4 - 0
plugins-scripts/check_ifoperstatus.pl

@@ -48,6 +48,10 @@ sub usage ($);
 sub print_usage ();
 sub process_arguments ();
 
+$ENV{'PATH'}='@trusted_path@';
+$ENV{'BASH_ENV'}=''; 
+$ENV{'ENV'}='';
+
 my $timeout;
 my $status;
 my %ifOperStatus = 	('1','up',

+ 3 - 0
plugins-scripts/check_ifstatus.pl

@@ -47,6 +47,9 @@ sub usage ($);
 sub print_usage ();
 sub process_arguments ();
 
+$ENV{'PATH'}='@trusted_path@';
+$ENV{'BASH_ENV'}=''; 
+$ENV{'ENV'}='';
 
 my $status;
 my %ifOperStatus =	('1','up',

+ 3 - 3
plugins-scripts/check_ircd.pl

@@ -64,9 +64,9 @@ sub bindRemote ($$);
 
 # -------------------------------------------------------------[ Enviroment ]--
 
-$ENV{PATH} = "";
-$ENV{ENV} = "";
-$ENV{BASH_ENV} = "";
+$ENV{'PATH'}='@trusted_path@';
+$ENV{'BASH_ENV'}=''; 
+$ENV{'ENV'}='';
 
 # -----------------------------------------------------------------[ Global ]--
 

+ 1 - 2
plugins-scripts/check_log.sh

@@ -57,8 +57,6 @@
 
 # Paths to commands used in this script.  These
 # may have to be modified to match your system setup.
-# TV: removed PATH restriction. Need to think more about what this means overall
-#PATH=""
 
 GREP="/bin/egrep"
 DIFF="/bin/diff"
@@ -71,6 +69,7 @@ TOUCH="/bin/touch"
 PROGNAME=`/bin/basename $0`
 PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
 REVISION="@NP_VERSION@"
+PATH="@trusted_path@"
 
 . $PROGPATH/utils.sh
 

+ 1 - 1
plugins-scripts/check_mailq.pl

@@ -40,7 +40,7 @@ sub print_help ();
 sub print_usage ();
 sub process_arguments ();
 
-$ENV{'PATH'}='';
+$ENV{'PATH'}='@trusted_path@';
 $ENV{'BASH_ENV'}=''; 
 $ENV{'ENV'}='';
 $PROGNAME = "check_mailq";

+ 4 - 0
plugins-scripts/check_mssql.pl

@@ -36,6 +36,10 @@ use strict;
 
 my $PROGNAME = "check_mssql";
 
+$ENV{'PATH'}='@trusted_path@';
+$ENV{'BASH_ENV'}=''; 
+$ENV{'ENV'}='';
+
 my (
 	$server,$database,$username,$password,$query,$help,$verbose,$timeout,
 	$dbh,$sth,$row,

+ 4 - 0
plugins-scripts/check_netdns.pl

@@ -33,6 +33,10 @@ use utils ;
 
 my $PROGNAME = "check_netdns";
 
+$ENV{'PATH'}='@trusted_path@';
+$ENV{'BASH_ENV'}=''; 
+$ENV{'ENV'}='';
+
 Getopt::Long::Configure(`bundling`);
 GetOptions("V" => $opt_V,         "version" => $opt_V,
 					 "h" => $opt_h,         "help" => $opt_h,

+ 1 - 1
plugins-scripts/check_ntp.pl

@@ -69,7 +69,7 @@ $PROGNAME="check_ntp";
 sub print_help ();
 sub print_usage ();
 
-$ENV{'PATH'}='';
+$ENV{'PATH'}='@trusted_path@';
 $ENV{'BASH_ENV'}='';
 $ENV{'ENV'}='';
 

+ 1 - 0
plugins-scripts/check_oracle.sh

@@ -9,6 +9,7 @@
 PROGNAME=`basename $0`
 PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
 REVISION="@NP_VERSION@"
+PATH="@trusted_path@"
 
 . $PROGPATH/utils.sh
 

+ 2 - 2
plugins-scripts/check_rpc.pl

@@ -37,9 +37,9 @@ sub print_help ();
 sub print_usage ();
 sub in ($$);
 
-$ENV{'BASH_ENV'}='';
+$ENV{'PATH'}='@trusted_path@';
+$ENV{'BASH_ENV'}=''; 
 $ENV{'ENV'}='';
-$ENV{'PATH'}='';
 $ENV{'LC_ALL'}='C';
 
 #Initialise protocol for each progname number

+ 2 - 3
plugins-scripts/check_sensors.sh

@@ -1,14 +1,13 @@
 #!/bin/sh
 
-PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin
-
 PROGNAME=`basename $0`
 PROGPATH=`echo $0 | sed -e 's,[\\/][^\\/][^\\/]*$,,'`
 REVISION="@NP_VERSION@"
+TRUSTED_PATH="@trusted_path@"
+PATH=${TRUSTED_PATH:-"/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin"}
 
 . $PROGPATH/utils.sh
 
-
 print_usage() {
 	echo "Usage: $PROGNAME" [--ignore-fault]
 }

+ 1 - 1
plugins-scripts/check_wave.pl

@@ -16,7 +16,7 @@ $PROGNAME = "check_wave";
 sub print_help ();
 sub print_usage ();
 
-$ENV{'PATH'}='';
+$ENV{'PATH'}='@trusted_path@';
 $ENV{'BASH_ENV'}='';
 $ENV{'ENV'}='';
 

+ 6 - 14
plugins-scripts/subst.in

@@ -45,17 +45,9 @@ BEGIN {
 	sub(c,which(c,path));
 }
 
-# Trusted path mechanism (deprecated)
-
-/^[ \t]*\$ENV[ \t]*\{[ \t'"]*PATH[ \t"']*\}[ \t]*=/ {
-	sub(/\=[ \t]*['"][^"']+["']/,"='@with_trusted_path@' # autoconf-derived");
-}
-
-/^[\t ]*(export[\t ]*)?PATH[\t ]*=['"]+.+["']$/ {
-	sub(/\=.*$/,"='@with_trusted_path@' # autoconf-derived");
-}
-
-{
-	print;
-}
-
+# Trusted path mechanism
+/@trusted_path@/ {sub(/@trusted_path@/,"@with_trusted_path@");}
+ 
+ {
+ 	print;
+ }