summaryrefslogtreecommitdiffstats
path: root/web/attachments/263441-check_mailq-add-sudo.patch
diff options
context:
space:
mode:
Diffstat (limited to 'web/attachments/263441-check_mailq-add-sudo.patch')
-rw-r--r--web/attachments/263441-check_mailq-add-sudo.patch57
1 files changed, 57 insertions, 0 deletions
diff --git a/web/attachments/263441-check_mailq-add-sudo.patch b/web/attachments/263441-check_mailq-add-sudo.patch
new file mode 100644
index 0000000..dff08c3
--- /dev/null
+++ b/web/attachments/263441-check_mailq-add-sudo.patch
@@ -0,0 +1,57 @@
1diff -Naur /home/qqnagio/software/nagios/nagios-plugins-1.4.11/plugins-scripts/check_mailq.pl /home/qqnagio/software/nagios/nagios-plugins-1.4.11.sudomailq/plugins-scripts/check_mailq.pl
2--- /home/qqnagio/software/nagios/nagios-plugins-1.4.11/plugins-scripts/check_mailq.pl 2006-07-05 15:45:57.000000000 +0200
3+++ /home/qqnagio/software/nagios/nagios-plugins-1.4.11.sudomailq/plugins-scripts/check_mailq.pl 2008-01-23 14:52:01.556368612 +0100
4@@ -62,12 +62,29 @@
5 };
6 alarm($opt_t);
7
8+# if there is an entry in the sudoers file which allows the caller of this
9+# plugin to execute the $utils::PATH_TO_MAILQ command with superuser privileges
10+# then prepend $utils::PATH_TO_MAILQ with "sudo "
11+
12+sub sudoize {
13+ my $ppath_to_mailq = shift;
14+ if (grep(/$$ppath_to_mailq/,
15+ map { s/^\s+//g; s/\s+$//g; $_; }
16+ map { split /, / }
17+ map { s/^.*?://g; $_; }
18+ do { local (@ARGV) = "/usr/bin/sudo -l |"; <> })) {
19+ $$ppath_to_mailq = "/usr/bin/sudo ".$$ppath_to_mailq;
20+ }
21+}
22+
23+
24 # switch based on MTA
25
26 if ($mailq eq "sendmail") {
27
28 ## open mailq
29 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
30+ sudoize(\$utils::PATH_TO_MAILQ);
31 if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
32 print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
33 exit $ERRORS{'UNKNOWN'};
34@@ -297,6 +314,7 @@
35
36 ## open mailq
37 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
38+ sudoize(\$utils::PATH_TO_MAILQ);
39 if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
40 print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
41 exit $ERRORS{'UNKNOWN'};
42@@ -379,6 +397,7 @@
43
44 # open qmail-qstat
45 if ( defined $utils::PATH_TO_QMAIL_QSTAT && -x $utils::PATH_TO_QMAIL_QSTAT ) {
46+ sudoize(\$utils::PATH_TO_MAILQ);
47 if (! open (MAILQ, "$utils::PATH_TO_QMAIL_QSTAT | " ) ) {
48 print "ERROR: could not open $utils::PATH_TO_QMAIL_QSTAT \n";
49 exit $ERRORS{'UNKNOWN'};
50@@ -461,6 +480,7 @@
51 elsif ( $mailq eq "exim" ) {
52 ## open mailq
53 if ( defined $utils::PATH_TO_MAILQ && -x $utils::PATH_TO_MAILQ ) {
54+ sudoize(\$utils::PATH_TO_MAILQ);
55 if (! open (MAILQ, "$utils::PATH_TO_MAILQ | " ) ) {
56 print "ERROR: could not open $utils::PATH_TO_MAILQ \n";
57 exit $ERRORS{'UNKNOWN'};