1 |
elmex |
1.1 |
#! perl |
2 |
|
|
|
3 |
root |
1.2 |
use Storable qw/nfreeze thaw/; |
4 |
elmex |
1.1 |
|
5 |
root |
1.2 |
my %global; # for use by eval'ed commands |
6 |
|
|
|
7 |
|
|
cf::register_extcmd perl_eval => sub { |
8 |
|
|
my ($pl, $data) = @_; |
9 |
|
|
|
10 |
|
|
my ($token, $data) = split / /, $data, 2; |
11 |
|
|
|
12 |
root |
1.3 |
unless ($pl->ob->flag (cf::FLAG_WIZ)) { |
13 |
root |
1.2 |
$pl->send ("ext $token error permission denied"); |
14 |
|
|
return; |
15 |
|
|
} |
16 |
|
|
|
17 |
|
|
my ($code, $arg) = split /\0/, $data, 2; |
18 |
|
|
|
19 |
|
|
$arg = eval { thaw $arg }; |
20 |
|
|
my @res = eval $code; |
21 |
|
|
|
22 |
root |
1.3 |
$@ ? $pl->send ("ext $token error $@") |
23 |
root |
1.2 |
: $pl->send ("ext $token ok " . nfreeze \@res); |
24 |
|
|
}; |