summaryrefslogtreecommitdiff
path: root/net-mgmt/nagios-plugins/files/patch-plugins-scripts__subst.in
blob: d4a9c6a34f3eaaec3b2bc54e93e10f68b9479dd2 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
--- plugins-scripts/subst.in.orig	2014-03-04 21:41:57 UTC
+++ plugins-scripts/subst.in
@@ -1,7 +1,7 @@
 #!/usr/bin/awk
 
 function which(c,path) {
-	cmd = "test -x " c;
+	cmd = "[ " c " = @libexecdir@ ] || test -x " c;
 
 	if (system(cmd)==0) {
 		return c;
@@ -53,7 +53,7 @@
 # FIXME: Prepend executables with a substitution keyword instead.
 #
 /^[^#]/ && /(\/.*)?\/(bin|sbin|lib|libexec)\// {
-	match($0,/(\/.*)?\/(bin|sbin|lib|libexec)\/[-_a-zA-Z0-9]+/);
+	match($0,/(\/[^ ]*)?\/(bin|sbin|lib|libexec)\/[-_a-zA-Z0-9]+/);
 	c=substr($0,RSTART,RLENGTH);
 	sub(c,which(c,path));
 }
@@ -65,7 +65,7 @@
 # Trusted path mechanism (deprecated)
 
 /^[ \t]*\$ENV[ \t]*\{[ \t'"]*PATH[ \t"']*\}[ \t]*=/ {
-	sub(/\=[ \t]*['"][^"']+["']/,"='@with_trusted_path@' # autoconf-derived");
+	sub(/\=[ \t]*['"][^"']+["'];/,"='@with_trusted_path@'; # autoconf-derived");
 }
 
 /^[\t ]*(export[\t ]*)?PATH[\t ]*=['"]+.+["']$/ {