Re: Handling exit in eval

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Richard Quadling wrote:

> On 14 March 2011 12:14, DELiTH <tb@xxxxxxxxxxx> wrote:
>> Richard Quadling wrote:
>>
>>> 2011/3/14 Richard Quadling <rquadling@xxxxxxxxx>:
>>>
>>> And where is my UNDO button.
>>>
>>> Essentially, having exit in the eval code is no different to having it
>>> in non-eval code. eval isn't a separate entity which can be
>>> terminated.
>>>
>>> So, code the eval code differently.
>>>
>>> If you can provide some examples, maybe we can come up with a better solution.
>>>
>>>
>>>
>>
>> I'm developing a kind of sandbox where you will be able to run a script
>> without affecting your current context. The script is loaded and parsed
>> which gives me the opportunity to allow or deny functions and classes
>> used in the script.
>> The only problem I have so far is the exit function which, it if is
>> allowed, terminates the calling script as well as the eval'ed script.
>>
>> By using a return the problem is solved as long as the user doesn't
>> write a function containing an exit.
>>
>> Here is a simple script thet the user might write (probably as useful as
>> a "Hello, world!".
>>
>> <?php
>> function DoSomethingOrExit($test) {
>>  if($test == 1) {
>>    exit;
>>  }
>>  return;
>> }
>>
>> DoSomethingOrExit(0);
>> echo "Hello";
>> DoSomethingOrExit(1);
>> echo ", world!";
>> exit;
>> echo "Bye";
>> ?>
>>
>> By replacing exit with return this code will echo "Hello, world!" before
>> returning without echoing "Bye".
>>
>>
>> Another perfect solution would be if there was a way to trigger an error
>> within the eval'ed script that "crashes" it and returns to the calling
>> script. But then it just comes back to the entity-problem as you pointed
>> out.
>>
>>
>> /Thomas
>>
>> --
>> PHP General Mailing List (http://www.php.net/)
>> To unsubscribe, visit: http://www.php.net/unsub.php
>>
>>
>
> Why not just invoke a separate instance of PHP using exec() ?
>
> Or take a look at runkit/runkit_Sandbox :
> http://uk.php.net/manual/en/book.runkit.php
>

exec() tends to allocate to much resources and Runkit_Sandbox is what
I'm trying to get away from =)
The Runkit_Sandbox requires that the server is configured to use it and
my intended solution will run on almost any server without any spcial
needs. (exec is also restricted from many hosting server which makes it
a poor choise.)

My little SandBox will run on almost any server and doesn't require any
special configuration. Sure, it will suck on resources but it will work
as an alternative =)

/Thomas

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux