[erlang-questions] rpc:call to a restricted shell

Patrik Nyblom <>
Tue Dec 18 11:51:05 CET 2012


Hi!

On 12/18/2012 06:28 AM, Son Tran-Nguyen wrote:
> Hello list,
>
> In one of my application, I start a restricted shell as a slave node, 
> using a callback module as follow:
>
> The callback module, for example, returns {false, State} for 
> gen_event:start/0 function to prevent that to be run. When tested in 
> an actual restricted shell, it is prevented as expected:
>
> smba:eggs esente$ erl -pa apps/*/ebin -stdlib restricted_shell 
> shell_callback
> Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] 
> [async-threads:0] [hipe] [kernel-poll:false] [dtrace]
>
> Restricted Eshell V5.9.2  (abort with ^G)
> 1> gen_event:start().
> ** exception exit: restricted shell does not allow gen_event:start()
> 2>
>
> However, when used in my app by making a call to the remote restricted 
> shell using rpc:call/4, the call went through:
>
> Args = "-stdlib restricted_shell editor_shell",
> {ok, Node} = slave:start_link(smba, editor, Args),
> {ok, Entity} = rpc:call(Node, gen_event, start, []),
>
> It returns Entity as a pid().
>
> I understand that the callback functions cannot be used to allow or 
> disallow execution of functions called from compiled code, but only 
> functions called from expressions entered at the shell prompt.
>
> I would like to confirm that rpc:call/4 does not enter the call into 
> the remote shell, but doing some stuffs to run the call directly.

You are correct, rpc:call has nothing to do with the shell. Rpc calls an 
already started server (rex) on the node and asks it to apply the 
module, function and parameters and send the result back (basiacally). 
That never passes any shell or interpreter.

>
>
>
> _______________________________________________
> erlang-questions mailing list
> 
> http://erlang.org/mailman/listinfo/erlang-questions
Cheers,
/Patrik
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20121218/6e87598d/attachment.html>


More information about the erlang-questions mailing list