view src/RESTRICTED.setting @ 0:c341f82e7ad7 default tip

Rakudo branch in cr.ie.u-ryukyu.ac.jp
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 26 Dec 2019 16:50:27 +0900
parents
children
line wrap: on
line source

sub restricted($what) {
    die "$what is disallowed in restricted setting"
}

sub chmod(|)  { restricted('chmod')   }
sub copy(|)   { restricted('copy')    }
sub link(|)   { restricted('link')   }
sub mkdir(|)  { restricted('mkdir')   }
sub open(|)   { restricted('open') }
sub pipe(|)   { restricted('pipe') }
sub QX(|)     { restricted('qx, qqx') }
sub rename(|) { restricted('rename')  }
sub rmdir(|)  { restricted('rmdir') }
sub run(|)    { restricted('run') }
sub shell(|)  { restricted('shell') }
sub socket(|) { restricted('socket') }
sub spurt(|)  { restricted('spurt')   }
sub symlink(|){ restricted('symlink') }
sub unlink(|) { restricted('unlink') }

my class RESTRICTED-CLASS is Mu {
    method FALLBACK(|) { restricted(self.^name) }
    method new(|)      { restricted(self.^name) }
    method gist(|)     { restricted(self.^name) }
}

my class IO::CatHandle    is RESTRICTED-CLASS { }
my class IO::Handle       is RESTRICTED-CLASS { }
my class IO::Path         is RESTRICTED-CLASS { }
my class IO::Pipe         is RESTRICTED-CLASS { }
my class IO::Socket       is RESTRICTED-CLASS { }
my class IO::Socket::INET is RESTRICTED-CLASS { }
my class NativeCall       is RESTRICTED-CLASS { }
my class Proc             is RESTRICTED-CLASS { }
my class Proc::Async      is RESTRICTED-CLASS { }

my role RESTRICTED-ROLE {
    method FALLBACK(|) { restricted(self.^name) }
    method new(|)      { restricted(self.^name) }
    method gist(|)     { restricted(self.^name) }
}