CC: | IT-1288 [...] jira.mensa.de |
Subject: | Mail::DKIM::Verifier calls my $SIG{__DIE__} handler |
My qmail-dmarc script included in App::Qmail::DMARC uses a ${__SIG__} handler to ensure that in case of emergency, :-) things get properly logged: https://metacpan.org/source/FANY/App-Qmail-DMARC-0.43/bin/qmail-dmarc
Recently my log contained the message "died: not available".
This message comes from the Mail::DKIM::Signature->fetch_public_key method which gets called by Mail::DKIM::Verifier when I call its ->CLOSE method:
eval { $pkey = $signature->get_public_key; };
The solution is described in "perldoc -f eval":
Using the "eval {}" form as an exception trap in libraries
does have some issues. Due to the current arguably broken
state of "__DIE__" hooks, you may wish not to trigger any
"__DIE__" hooks that user code may have installed. You can
use the "local $SIG{__DIE__}" construct for this purpose, as
this example shows:
# a private exception trap for divide-by-zero
eval { local $SIG{'__DIE__'}; $answer = $a / $b; };
warn $@ if $@;
In fact, you should IMHO typically do this in each evalĀ {}.
Should I send you a pull request for https://github.com/marcbradshaw/mail-dkim?
Regards
fany