Skip to content
Browse files

plugins: use runtime $ENV{MUNIN_PLUGSTATE}

Since 780634c, the plugin state dir get
resolved at runtime for security issues. The old behavior was using a
compile-time resolution.
  • Loading branch information...
1 parent 780634c commit 9f2643c4cb13a34deadfea8fb7e8a29fa54fdc8e @steveschnepp steveschnepp committed Aug 29, 2012
View
3 plugins/lib/Munin/Plugin.pm
@@ -88,7 +88,8 @@ our $me = (split '/', $0)[-1];
=head3 $Munin::Plugin::pluginstatedir
Identical to the environment variable MUNIN_PLUGSTATE (available since
-Munin 1.3.3) or the install time @Z<>@PLUGSTATE@Z<>@ 'constant'.
+Munin 1.3.3)
+
You can use this if you need to save several different state files.
But there is also a function to change the state file name so the
state file support functions can be used for several state files.
View
2 plugins/node.d.linux/apt.in
@@ -75,7 +75,7 @@ use strict;
$ENV{'LANG'}="C";
$ENV{'LC_ALL'}="C";
-my $statefile = "@@PLUGSTATE@@/plugin-apt.state";
+my $statefile = "$ENV{MUNIN_PLUGSTATE}/plugin-apt.state";
sub update_state() {
if(-l $statefile) {
View
2 plugins/node.d.linux/apt_all.in
@@ -52,7 +52,7 @@ use strict;
$ENV{'LANG'}="C";
$ENV{'LC_ALL'}="C";
-my $statefile = "@@PLUGSTATE@@/plugin-apt.state";
+my $statefile = "$ENV{MUNIN_PLUGSTATE}/plugin-apt.state";
my @releases = ("stable", "testing","unstable");
View
2 plugins/node.d.linux/iostat_ios.in
@@ -62,7 +62,7 @@ use IO::File;
use Storable qw(store retrieve);
use Munin::Plugin;
-use constant STATEFILE => '@@PLUGSTATE@@/iostat-ios.state';
+use constant STATEFILE => "$ENV{MUNIN_PLUGSTATE}/iostat-ios.state";
if (defined($ARGV[0]) and $ARGV[0] eq 'autoconf') {
View
2 plugins/node.d.linux/port_.in
@@ -49,7 +49,7 @@ sub cache_open
{
my ($fd, $file) = @_;
- my $cache_dir = "@@PLUGSTATE@@";
+ my $cache_dir = "$ENV{MUNIN_PLUGSTATE}";
my $cache = $file;
$cache =~ s:/:_:g;
$cache = "$cache_dir/$cache";
View
3 plugins/node.d.linux/yum.in
@@ -27,9 +27,8 @@ GPLv2
=cut
use strict;
-use Munin::Common::Defaults;
-my $statefile = "$Munin::Common::Defaults::MUNIN_PLUGSTATE/yum.state";
+my $statefile = "$ENV{MUNIN_PLUGSTATE}/yum.state";
sub update {
if (-l $statefile) {
View
3 plugins/node.d/bind9.in
@@ -51,10 +51,9 @@ GPLv2
=cut
use strict;
-use Munin::Common::Defaults;
my $QUERYLOG = $ENV{logfile} || '/var/log/bind9/query.log';
-my $STATEFILE= $Munin::Common::Defaults::MUNIN_PLUGSTATE.'/bind9.state';
+my $STATEFILE= "$ENV{MUNIN_PLUGSTATE}/bind9.state";
my $OTHER=0;
my %IN;
View
2 plugins/node.d/courier_.in
@@ -54,7 +54,7 @@ Unknown
# Set the location of the courier logs
COURIER_LOG=${logfile:-/var/log/mail.log}
SERVICE=${service:-`basename $0 | sed 's/^courier_//g'`}
-OFFSET_FILE=@@PLUGSTATE@@/courier_${SERVICE}.offset
+OFFSET_FILE=${MUNIN_PLUGSTATE}/courier_${SERVICE}.offset
LOGTAIL=${logtail:-/usr/sbin/logtail}
mktempfile () {
View
2 plugins/node.d/courier_mta_mailstats.in
@@ -29,7 +29,7 @@ Unknown
=cut
-my $statefile = "@@PLUGSTATE@@/munin-plugin-courier_mta_mailstats.state";
+my $statefile = "$ENV{MUNIN_PLUGSTATE}/munin-plugin-courier_mta_mailstats.state";
my $pos = undef;
my $delivered = 0;
my $rejects = {};
View
2 plugins/node.d/courier_mta_mailvolume.in
@@ -28,7 +28,7 @@ GPLv2
=cut
-my $statefile = "@@PLUGSTATE@@/munin-plugin-courier_mta_mailvolume.state";
+my $statefile = "$ENV{MUNIN_PLUGSTATE}/munin-plugin-courier_mta_mailvolume.state";
my $pos = undef;
my $volume = 0;
my $LOGDIR = $ENV{'logdir'} || '/var/log';
View
2 plugins/node.d/cupsys_pages.in
@@ -32,7 +32,7 @@ GPLv2
use strict;
use Munin::Plugin;
-my $statefile = "@@PLUGSTATE@@/munin-cupsys-pages.state";
+my $statefile = "$ENV{MUNIN_PLUGSTATE}/munin-cupsys-pages.state";
my $pos = undef;
my %printers = ();
View
2 plugins/node.d/ipmi_sensor_.in
@@ -70,7 +70,7 @@ from time import time
import sys
import re
-CACHEDIR = "@@PLUGSTATE@@"
+CACHEDIR = os.environ['MUNIN_PLUGSTATE']
CACHEFILE = "plugin-ipmi_sensor.cache"
CACHEAGE = 120
CONFIG = '@@CONFDIR@@/ipmi'
View
2 plugins/node.d/loggrep.in
@@ -79,7 +79,7 @@ for my $key (map {/^regex_(.+)/} keys %ENV) {
die("No regexes specified") unless keys %regex;
-my $statefile = "@@PLUGSTATE@@/$name.state";
+my $statefile = "$ENV{MUNIN_PLUGSTATE}/$name.state";
if ($ARGV[0] and $ARGV[0] eq 'config') {
my $title = $ENV{title} || "Entries in $logfile";
View
4 plugins/node.d/mailman.in
@@ -24,9 +24,7 @@ License unknown
=cut
-use Munin::Common::Defaults;
-
-$statefile = "$Munin::Common::Defaults::MUNIN_PLUGSTATE/munin-mailman-log.state";
+$statefile = "$ENV{MUNIN_PLUGSTATE}/munin-mailman-log.state";
$pos = undef;
$posts = 0;
$members = 0;
View
2 plugins/node.d/mailscanner.in
@@ -43,7 +43,7 @@ use strict;
my $logfile = '/var/log/mail.log';
my $logtail = '/usr/sbin/logtail';
-my $offsetfile = "@@PLUGSTATE@@/munin-mailscanner.offset";
+my $offsetfile = "$ENV{MUNIN_PLUGSTATE}/munin-mailscanner.offset";
my ($clean, $viruses, $spams, $others, $total) = (0, 0, 0, 0, 0);
my $cmd = (defined($ARGV[0])) ? $ARGV[0] : '';
View
2 plugins/node.d/mhttping.in
@@ -36,7 +36,7 @@ use strict ;
############################## STUFF YOU MIGHT NEED TO CHANGE
-my $datafile = "@@PLUGSTATE@@/mhttping.data" ;
+my $datafile = "$ENV{MUNIN_PLUGSTATE}/mhttping.data" ;
my $resultsdir = "/home/gconnor/mhttping/results/" ;
my $httping = "/usr/local/bin/httping" ;
my $timeout = 30 ;
View
4 plugins/node.d/mysql_isam_space_.in
@@ -21,7 +21,7 @@ if you need to override the defaults below:
[mysql_isam_space_*]
env.mysqlopts
- env.statefile @@PLUGSTATE@@/plugin-mysql_isam_space.state
+ env.statefile $ENV{MUNIN_PLUGSTATE}/plugin-mysql_isam_space.state
env.ignore
env.absolute 0
@@ -50,7 +50,7 @@ munin-node.
my $DB = `basename $0 | sed 's/^mysql_isam_space_//g' | tr '_' '-'` ;
chomp $DB;
-my $STATEFILE = $ENV{'statefile'} || "@@PLUGSTATE@@/plugin-mysql_isam_space.state";
+my $STATEFILE = $ENV{'statefile'} || "$ENV{MUNIN_PLUGSTATE}/plugin-mysql_isam_space.state";
my $MYSQLSHOW = $ENV{'mysqlshow'} || `which mysqlshow`;
my $ABSOLUTE = $ENV{'absolute'} || 0;
my @mysql_opts = ();
View
2 plugins/node.d/perdition.in
@@ -55,7 +55,7 @@ mktempfile () {
# Set the location of the perdition logs
PERDITION_LOG=${logfile:-/var/log/perdition.log}
-OFFSET_FILE=@@PLUGSTATE@@/perdition.offset
+OFFSET_FILE=${MUNIN_PLUGSTATE}/perdition.offset
LOGTAIL=${logtail:-/usr/sbin/logtail}
case $1 in
View
2 plugins/node.d/pop_stats.in
@@ -4,7 +4,7 @@
#%# family=contrib
-$pop{'statefile'} = "@@PLUGSTATE@@/munin-pop-log.state";
+$pop{'statefile'} = "$ENV{MUNIN_PLUGSTATE}/munin-pop-log.state";
$pos = undef;
$logons = 0;
View
3 plugins/node.d/smart_.in
@@ -91,13 +91,12 @@
verbose=False
# Suppress SMART warnings (True/False)
report_warnings=True
-# Modify to your needs:
-statefiledir='@@PLUGSTATE@@'
# You may not modify anything below this line
import os, sys, string, pickle
from math import log
plugin_version="2.1"
+statefiledir=os.environ['MUNIN_PLUGSTATE']
def verboselog(s):
global plugin_name
View
2 plugins/node.d/spamstats.in
@@ -24,7 +24,7 @@ GPLv2
=cut
-$statefile = $ENV{statefile} || "@@PLUGSTATE@@/munin-spamstats.state";
+$statefile = $ENV{statefile} || "$ENV{MUNIN_PLUGSTATE}/munin-spamstats.state";
$pos = undef;
$ham = 0;
$spam = 0;

0 comments on commit 9f2643c

Please sign in to comment.
Something went wrong with that request. Please try again.