mariusz has asked for the wisdom of the Perl Monks concerning the following question:

I have a problem. I use program where i can create simple addons. Main program have a white list of function and for example i dont have permission to use "open" function

I will try something like this:

(...) my @users = (); open(FH,"/usr/bin/who|"); while(<FH>) { push @users,$1 if (/^(\w+)/); } close(FH); if ( grep ( /$luser\b/, @users) ) { _take_actions(); } (...)

But my code doesnt work. Of course i try use "system", "backticks", "exec" but without success.

How i can make "overloading" those function and execute "who" command? This white list is very simple. Main program looking only name of restricted commands. In white list i have only:

readline pack sleep time unpack sort

Sorry for my english skills.

Replies are listed 'Best First'.
Re: Overload "open" function
by tobyink (Canon) on Jul 25, 2012 at 15:21 UTC

    Your code is probably being run within a Safe sandbox. You're probably stuck I'm afraid.

    perl -E'sub Monkey::do{say$_,for@_,do{($monkey=[caller(0)]->[3])=~s{::}{ }and$monkey}}"Monkey say"->Monkey::do'