https://bz.apache.org/SpamAssassin/show_bug.cgi?id=7610

--- Comment #5 from John Hardin <[email protected]> ---
The rules parsing occurs before the DKIM module first tries to "require
Mail::DKIM::Verifier", and the sub that loads Mail::DKIM has a call to the SA
log-the-time utility which doesn't (in the current form) work from can():

warn: config: error in if - $self->cond_clause_can(
"Mail::SpamAssassin::Plugin::DKIM::_dkim_load_modules" ) : Can't call method
"can" on an undefined value at lib/Mail/SpamAssassin/Plugin/DKIM.pm line 672.

671         my $timemethod = $self->{main}->UNIVERSAL::can("time_method") &&
672                          $self->{main}->time_method("dkim_load_modules");

So a code change will be needed somewhere to support this. The options I see:

(1) My perl is way rusty so I don't offhand know how to fix that timing call so
it would work in that situation - advice?

(2) Lose the timing call in _dkim_load_modules so we can do
"can(Mail::SpamAssassin::Plugin::DKIM::_dkim_load_modules)"

(3) Add a much simpler can-able sub like:

sub is_mail_dkim_unavailable {
  return !eval { require Mail::DKIM::Verifier; }
}

...which has the side-effect of loading the module and rendering the timing
measurement from the actual call to _dkim_load_modules useless.


Which approach is preferable?


I think the new sub() is preferable because that approach doesn't generate an
error from can(Mail::SpamAssassin::Plugin::DKIM::_dkim_load_modules) if (when)
the rules get run against an older version of SA. Perhaps also with removing
the timing call from _dkim_load_modules since it's now pointless...


Which would lead to this in the rules file:

# This is useless while __DKIM_EXISTS continues to perform so well.
# This is useless while ruleqa continues to lack DKIM support.
ifplugin Mail::SpamAssassin::Plugin::DKIM
  meta     DKIM_INVALID __DKIM_EXISTS && !DKIM_VALID
  if can(Mail::SpamAssassin::Plugin::DKIM::is_mail_dkim_unavailable)
    describe DKIM_INVALID       Mail::DKIM module unavailable, cannot verify
DKIM header
  else
    describe DKIM_INVALID       DKIM-Signature header exists but is not valid
  endif
  # masscheck ignores ifplugins and thus always has DKIM_INVALID==__DKIM_EXISTS
endif


Comments solicited before I make any commits.

-- 
You are receiving this mail because:
You are the assignee for the bug.

Reply via email to