restrict_remsh_mod (util v1.3.5)

View Source

Sample restricted remote shell module disabling q/0 (from the c module) and init:stop/{0,1} commands. The shell introduces a replacement command to stop remote node: remote_node_stop/1 equivalent to init:stop/1.

To activate restricted shell, run the server node like this: erl -sname node@host +Bi -shell restricted_shell restrict_remsh_mod

Then you can connect to it with: erl -sname a@myhost -remsh node@host

See: [http://www.erlang.org/doc/man/shell.html#start_restricted-1]

Summary

Types

funspec()

-type funspec() :: {Mod :: atom(), Fun :: atom()}.

Functions

local_allowed(Func, Args, State)

-spec local_allowed(Func :: atom(), Args :: list(), State :: term()) -> {boolean(), NewState :: term()}.

non_local_allowed(FunSpec, Args, State)

-spec non_local_allowed(FunSpec :: funspec(), Args :: list(), State :: term()) ->
                           {true, NewState :: term()} |
                           {false, NewState :: term()} |
                           {{redirect, NewFuncSpec :: funspec(), NewArgs :: list()}, NewState :: term()}.

remote_node_stop(Status)

-spec remote_node_stop(Status :: integer()) -> ok.

Replaces init:stop/1 with remote_node_stop/1 to avoid accidental exit of remote shell.