diff --git a/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm b/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm index 2f6b838ec8..de3412af89 100644 --- a/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm +++ b/lib/NGCP/Panel/Utils/ProvisioningTemplates.pm @@ -28,6 +28,19 @@ use NGCP::Panel::Utils::Subscriber qw(); use NGCP::Panel::Utils::Preferences qw(); use NGCP::Panel::Utils::Kamailio qw(); +#The function _calculate() evaluates perl code provided via a configuration +#by the user, so we must make sure no such code will call exit() by +#accident or we would terminate the entire program. +our $DISABLE_EXIT = 0; +BEGIN { + *CORE::GLOBAL::exit = sub (;$) { + ## no critic (TestingAndDebugging::ProhibitNoWarnings) + no warnings 'exiting'; + die('exit() called') if $DISABLE_EXIT; + CORE::exit($_[0] // 0); + }; +} + my $IDENTIFIER_FNAME = 'identifier'; my $CODE_SUFFIX_FNAME = '_code'; my $FIELD_TYPE_ATTRIBUTE = 'type'; @@ -997,6 +1010,7 @@ sub _calculate { $context->{cr_c} //= {}; if ($f =~ /^([a-z0-9_]+)$CODE_SUFFIX_FNAME$/) { my $cl; + local $DISABLE_EXIT = 1; if ($strict_closure) { $cl = eval_closure( source => $c,