<div dir="ltr"><font color="#3366ff"><font><font face="tahoma,sans-serif">Thanks all.</font></font></font><div><font color="#3366ff"><font><font face="tahoma,sans-serif"><br></font></font></font></div><div><font color="#3366ff"><font><font face="tahoma,sans-serif">I guess I can't rely on that then.</font></font></font></div>
<div class="gmail_extra"><br clear="all"><div>Sincerely,<br><br><div><br>Son Tran-Nguyen</div></div><br>
<br><br><div class="gmail_quote">On Tue, Dec 18, 2012 at 2:28 PM, Laszlo Lovei <span dir="ltr"><<a href="mailto:lovei.laszlo@gmail.com" target="_blank">lovei.laszlo@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
It's quite important to understand that Erlang is not a scripting language where your source code is interpreted and you can use the same interpreter as a shell. It's exactly the opposite: the shell is an interpreter (written in Erlang and compiled into binary code understood by the Erlang VM) that evaluates Erlang expressions entered at the prompt and formatting their results. This has a number of consequences regarding performance and semantics, expressions evaluated by the shell do not have the same meaning as code compiled into modules.<br>
<br>To answer your question too: the rpc server runs independently of the shell, and the latter may impose artificial restrictions on what it accepts without affecting any other part of the system.<span><font color="#888888"><br>
<br><br>L.</font></span><div><div><br><br>On Tuesday, December 18, 2012 6:28:13 AM UTC+1, Son Tran-Nguyen wrote:<blockquote class="gmail_quote" style="margin:0;margin-left:0.8ex;border-left:1px #ccc solid;padding-left:1ex">
<div dir="ltr"><font color="#3366ff" face="tahoma, sans-serif">Hello list,</font><div><font color="#3366ff" face="tahoma, sans-serif"><br></font></div><div><font color="#3366ff" face="tahoma, sans-serif">In one of my application, I start a restricted shell as a slave node, using a callback module as follow:</font></div>
<div><br></div><div><font color="#3366ff" face="tahoma, sans-serif">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:</font></div>
<div><font color="#3366ff" face="tahoma, sans-serif"><br></font></div><div><font color="#3366ff" face="tahoma, sans-serif"><div>smba:eggs esente$ erl -pa apps/*/ebin -stdlib restricted_shell shell_callback</div>
<div>Erlang R15B02 (erts-5.9.2) [source] [64-bit] [smp:4:4] [async-threads:0] [hipe] [kernel-poll:false] [dtrace]</div><div><br></div><div>Restricted Eshell V5.9.2 (abort with ^G)</div><div>1> gen_event:start().</div>
<div>** exception exit: restricted shell does not allow gen_event:start()</div><div>2> </div><div><br></div><div>However, when used in my app by making a call to the remote restricted shell using rpc:call/4, the call went through:</div>
<div><br></div><div><div>Args = "-stdlib restricted_shell editor_shell",</div><div>{ok, Node} = slave:start_link(smba, editor, Args),</div></div></font></div>
<div><font color="#3366ff" face="tahoma, sans-serif">{ok, Entity} = rpc:call(Node, gen_event, start, []),</font></div><div><font color="#3366ff" face="tahoma, sans-serif"><br></font></div><div><font color="#3366ff" face="tahoma, sans-serif">It returns Entity as a pid().</font></div>
<div><font color="#3366ff" face="tahoma, sans-serif"><br></font></div><div><font color="#3366ff" face="tahoma, sans-serif">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.</font></div>
<div><font color="#3366ff" face="tahoma, sans-serif"><br></font></div><div><font color="#3366ff" face="tahoma, sans-serif">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.<br>
</font><br>
</div></div>
</blockquote></div></div></blockquote></div><br></div></div>