[Mimedefang] Does MIMEdefang 'remember' variable values between successive invocations?
Rolf E. Sonneveld
R.E.Sonneveld at sonnection.nl
Tue Sep 6 14:25:53 EDT 2011
Hi,
running 2.71
Within filter_begin the mimedefang-filter script reads in variables from
a config file (mimedefang-filter.conf), to separate data from script and
to make changing variables a dynamic process:
# Read variables from configuration file...
my $success = open CONFIG, "<", "$bindir/mimedefang-filter.conf";
if ( $success ) {
while (<CONFIG>) {
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
next unless length;
($var, $value) = split(/\s*=\s*/, $_, 2);
no strict "refs";
$$var = $value;
}
close CONFIG;
Now, it seems to me it's not as dynamic as I thought it was. I have
tested manually a number of messages (runs):
Run 1: I define variable $var in mimedefang-filter.conf to be "xyz".
Works OK.
Run 2: I redefine variable $var to be "abc". Works OK.
Run 3: I removed variable $var from the config file and check in the
script whether the variable is undefined or not. The variable is not
undefined: it still contains value "abc"!
Then I run /etc/init.d/mimedefang reread
Run 4: $var is still not defined in mimedefang-filter.conf. This works
OK, the variable $var is now undefined within the context of the script.
Now I wonder: does MIMEdefang keep state between successive runs? Is
there a way I can 'clean up' (= undefine) all variables before a run?
The workaround I now use is, that the variables in the config file are
defined without a value and then in the script I set the variable to an
empty string and check the variable for an empty value:
# Read variables from configuration file...
my $success = open CONFIG, "<", "$bindir/mimedefang-filter.conf";
if ( $success ) {
while (<CONFIG>) {
chomp;
s/#.*//;
s/^\s+//;
s/\s+$//;
next unless length;
($var, $value) = split(/\s*=\s*/, $_, 2);
no strict "refs";
$$var = "";
$$var = $value;
}
close CONFIG;
I would prefer to be able to remove or comment out a variable in the
config file and not having to do a 'reread' of mimedefang.
Any ideas?
/rolf
More information about the MIMEDefang
mailing list