Skip to content

Instantly share code, notes, and snippets.

@pmichaud
Created March 20, 2013 13:46
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save pmichaud/5204740 to your computer and use it in GitHub Desktop.
Save pmichaud/5204740 to your computer and use it in GitHub Desktop.
pmichaud@kiwi:~/p6/rakudo$ cat R.setting
sub restricted($what) {
die "$what is disallowed in restricted setting"
}
sub open(|) { restricted('open') }
sub unlink(|) { restricted('unlink') }
sub shell(|) { restricted('shell') }
sub run(|) { restricted('run') }
sub QX(|) { restricted('qx, qqx') }
sub mkdir(|) { restricted('mkdir') }
sub rmdir(|) { restricted('rmdir') }
sub rename(|) { restricted('rename') }
sub copy(|) { restricted('copy') }
my class RESTRICTED is Mu {
method new { restricted(self.^name) }
method gist { restricted(self.^name) }
}
my class IO is RESTRICTED { }
my class IO::Socket is RESTRICTED { }
pmichaud@kiwi:~/p6/rakudo$ ./perl6 --setting=R
> say IO
IO is disallowed in restricted setting
in sub restricted at R.setting:2
in method gist at R.setting:17
> say IO::Socket
IO::Socket is disallowed in restricted setting
in sub restricted at R.setting:2
in method gist at R.setting:17
> say IO.new
IO is disallowed in restricted setting
in sub restricted at R.setting:2
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment