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