Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Projets publics
Sympa
Commits
61641d42
Commit
61641d42
authored
Nov 28, 2019
by
IKEDA Soji
Browse files
Scenario: Ensure to handle fatal errors.
parent
25102652
Changes
1
Hide whitespace changes
Inline
Side-by-side
src/lib/Sympa/Scenario.pm
View file @
61641d42
...
...
@@ -420,30 +420,37 @@ sub authz {
}
my
$sub
=
(
$self
->
{
_scenario
}
||
{})
->
{
sub
};
my
$result
=
$sub
->
(
$that
,
$context
,
$auth_method
)
if
ref
$sub
eq
'
CODE
';
my
$result
=
eval
{
$sub
->
(
$that
,
$context
,
$auth_method
)
}
if
ref
$sub
eq
'
CODE
';
# Cope with errors.
unless
(
$result
)
{
if
(
ref
$EVAL_ERROR
eq
'
HASH
'
and
not
%$EVAL_ERROR
)
{
unless
(
$sub
)
{
$result
=
{
reason
=>
'
not-compiled
'};
}
elsif
(
ref
$EVAL_ERROR
eq
'
HASH
')
{
$result
=
$EVAL_ERROR
;
}
else
{
# Fatal error will be logged but not be exposed.
$log
->
syslog
('
err
',
'
Error in scenario %s, context %s: (%s)
',
$self
,
$that
,
$EVAL_ERROR
||
'
unknown
');
$result
=
{};
}
$result
->
{
action
}
||=
'
reject
';
$result
->
{
reason
}
||=
'
error-performing-condition
';
$result
->
{
auth_method
}
||=
$auth_method
;
$result
->
{
condition
}
||=
'
default
';
if
(
$result
->
{
reason
}
eq
'
not-compiled
')
{
$log
->
syslog
('
info
',
'
%s: Not compiled, reject
',
$self
);
}
elsif
(
$result
->
{
reason
}
eq
'
no-rule-match
')
{
$log
->
syslog
('
info
',
'
%s: No rule match, reject
',
$self
);
return
{
action
=>
'
reject
',
reason
=>
'
no-rule-match
',
auth_method
=>
'
default
'
,
condition
=>
'
default
'
};
}
else
{
$log
->
syslog
('
info
',
'
Error in scenario %s, context %s: (%s)
',
$self
,
$that
,
$result
->
{
reason
});
Sympa::
send_notify_to_listmaster
(
$that
,
'
error_performing_condition
',
{
error
=>
$result
->
{
reason
}})
unless
$options
{
debug
};
}
$log
->
syslog
('
info
',
'
Error in scenario %s, context %s: (%s)
',
$self
,
$that
,
$EVAL_ERROR
||
'
unknown
');
Sympa::
send_notify_to_listmaster
(
$that
,
'
error_performing_condition
',
{
error
=>
(
$EVAL_ERROR
||
'
unknown
')})
unless
$options
{
debug
};
return
{
action
=>
'
reject
',
reason
=>
'
error-performing-condition
',
auth_method
=>
$auth_method
,
condition
=>
'
default
',
};
return
$result
;
}
my
%action
=
%$result
;
...
...
@@ -592,7 +599,7 @@ sub {
%s
%s
die
{};
die
{
reason
=>
'
no-rule-match
'
};
}
EOF
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment