Add die handler that stores the error from eval message

This commit is contained in:
Ilia Ross
2023-09-17 13:42:30 +03:00
parent cb41eff450
commit f01197df71
2 changed files with 9 additions and 4 deletions

View File

@@ -34,5 +34,12 @@ if (!$done_web_lib_funcs) {
$remote_error_handler ||= \&error;
$main::remote_error_handler ||= \&error;
# Die handler that stores the error from
# eval message in a global variable
$SIG{__DIE__} = sub {
# Don't meddle with the natural functioning of eval.
$main::error_last_eval = $_[0] if (!$^S);
};
1;

View File

@@ -162,8 +162,7 @@ sub validate_twofactor_apikey_totp
{
my ($miniserv, $in) = @_;
eval "use Authen::OATH";
$main::error_last_eval = $@;
if ($main::error_last_eval) {
if ($@) {
return &text('twofactor_etotpmodule', 'Authen::OATH',
"../cpan/download.cgi?source=3&cpan=Authen::OATH&mode=2&".
"return=/$module_name/&returndesc=".&urlize($text{'index_return'}));
@@ -249,8 +248,7 @@ $id =~ /^[A-Z0-9=]+$/i || return $text{'twofactor_etotpid'};
$token =~ /^\d+$/ || return $text{'twofactor_etotptoken'};
eval "use lib (\"$root_directory/vendor_perl\")";
eval "use Authen::OATH";
$main::error_last_eval = $@;
if ($main::error_last_eval) {
if ($@) {
return &text('twofactor_etotpmodule2', 'Authen::OATH');
}
my $secret = &decode_base32($id);