Created
June 26, 2013 18:43
-
-
Save ztmr/5870171 to your computer and use it in GitHub Desktop.
Erlang Restricted Shell Module -- as mentioned in [erlang-programming groups.](https://groups.google.com/d/msg/erlang-programming/LI3O8VwMbGc/LDPm6fkUEy0J)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-module (restricted_shell). | |
-export ([local_allowed/3, non_local_allowed/3]). | |
-export ([lock/0, unlock/0, is_locked/0]). | |
-define (APP, 'SuperCluster'). | |
-define (IS_LOCKED, 'restricted.is_locked'). | |
local_allowed (q, [], _State) -> | |
{not is_locked (), _State}; | |
local_allowed ({init, stop}, [], _State) -> | |
{not is_locked (), _State}; | |
local_allowed (_Func, _ArgList, _State) -> | |
{true, _State}. | |
non_local_allowed (q, [], _State) -> | |
{not is_locked (), _State}; | |
non_local_allowed ({init, stop}, [], _State) -> | |
{not is_locked (), _State}; | |
non_local_allowed (_Func, _ArgList, _State) -> | |
{true, _State}. | |
is_locked () -> | |
{ok, false} =/= application:get_env (?APP, ?IS_LOCKED). | |
lock () -> application:set_env (?APP, ?IS_LOCKED, true). | |
unlock () -> application:set_env (?APP, ?IS_LOCKED, false). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment