Created
November 15, 2015 23:47
-
-
Save yevrah/f45c41afdae7a3dca383 to your computer and use it in GitHub Desktop.
Perl: Ovverride core perl routines
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
# See my post on http://stackoverflow.com/questions/33725298/perl-disable-shell-access | |
# Ref: https://github.com/Perl/perl5/blob/blead/lib/CORE.pod | |
BEGIN { | |
*CORE::GLOBAL::system = sub { | |
die('Do not use system calls.'); | |
}; | |
*CORE::GLOBAL::exec = sub { | |
die('Do not use exec.'); | |
}; | |
*CORE::GLOBAL::readpipe = sub { | |
die('Do not use back ticks.'); | |
}; | |
} | |
#... | |
my $out = system('ls -lah'); # I will die at this point, but not before | |
print $out; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment