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