cb_admin problem

28 views
Skip to first unread message

Greg Martin

unread,
Aug 29, 2017, 9:04:41 AM8/29/17
to chica...@googlegroups.com
Good morning,

I'm just getting started with Chicago Boss. Hello World works for me and
I'm trying to add the admin interface. This is the error I get:

07:56:56.609 [error] gen_server <0.313.0> terminated with reason: call
to undefined function crypto:rand_bytes/1 from
boss_session_controller:generate_session_id/0 line 90
07:56:56.609 [error] CRASH REPORT Process <0.313.0> with 0 neighbours
crashed with reason: call to undefined function crypto:rand_bytes(2048)
07:56:56.610 [error] Supervisor {<0.137.0>,poolboy_sup} had child
boss_session_controller started with
{boss_session_controller,start_link,undefined} at <0.313.0> exit with
reason call to undefined function crypto:rand_bytes(2048) in context
child_terminated
07:56:56.610 [error] Unhandled Error: exit:{{undef,
[{crypto,rand_bytes,[2048],[]},
{boss_session_controller,generate_session_id,0,
[{file,"src/boss/boss_session_controller.erl"},{line,90}]},
{boss_session_controller,handle_call,3,
[{file,"src/boss/boss_session_controller.erl"},{line,44}]},
{gen_server,try_handle_call,4,[{file,"gen_server.erl"},{line,636}]},
{gen_server,handle_msg,6,[{file,"gen_server.erl"},{line,665}]},
{proc_lib,init_p_do_apply,3,[{file,"proc_lib.erl"},{line,247}]}]},
{gen_server,call,[<0.313.0>,{new_session,undefined}]}}
Stacktrace:
[{gen_server,call,2,[{file,"gen_server.erl"},{line,206}]},{boss_pool,call,2,[{file,"src/boss_pool.erl"},{line,6}]},{boss_web_controller,execute_action_inner,9,[{file,"src/boss/boss_web_controller.erl"},{line,262}]},{boss_web_controller_handle_request,process_dynamic_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,256}]},{boss_web_controller_handle_request,process_request,5,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,247}]},{timer,tc,3,[{file,"timer.erl"},{line,197}]},{boss_web_controller_handle_request,build_dynamic_response,4,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,136}]},{boss_web_controller_handle_request,handle_request,2,[{file,"src/boss/boss_web_controller_handle_request.erl"},{line,35}]}]


#######################

I installed version 20.0 OTP using kerl and the only dependency I didn't
resolve was the ability to bind to wxWidgets.

My openssl version:

#apt-cache policy openssl
openssl:
Installed: 1.0.1f-1ubuntu2.22
Candidate: 1.0.1f-1ubuntu2.22

Thanks and regards,

Greg Martin

Graeme Defty

unread,
Aug 29, 2017, 11:32:42 AM8/29/17
to chica...@googlegroups.com
Hi Greg,

The name of this function has changed. You will need to make a patch to the CB source (assuming you have the latest, which menas that it is not fixed yet).

The change needed is in boss_session_controller.erl around line 87. This is the patch that I made, according to git ...

<pre>
diff --git a/src/boss/boss_session_controller.erl b/src/boss/boss_session_controller.erl
index 8712fc6..0ef0980 100644
--- a/src/boss/boss_session_controller.erl
+++ b/src/boss/boss_session_controller.erl
@@ -87,7 +87,7 @@ handle_info(_Info, State) ->
     {noreply, State}.
 
 generate_session_id() ->
-    Data = crypto:rand_bytes(2048),
+    Data = crypto:strong_rand_bytes(2048),
     Sha_list = binary_to_list(crypto:hash(sha, Data)),
     lists:flatten(list_to_hex(Sha_list)).
 %% Convert Integer from the SHA to Hex
</pre>

Good luck!

graeme










--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/chicagoboss.
To view this discussion on the web visit https://groups.google.com/d/msgid/chicagoboss/0bf28950-baba-17ef-badc-184e276b7cac%40softsprocket.com.
For more options, visit https://groups.google.com/d/optout.

Greg Martin

unread,
Sep 9, 2017, 10:42:42 AM9/9/17
to chica...@googlegroups.com
I thought I'd try this again since I didn't get any response to my first
email. I'm guessing that this page
https://bugs.erlang.org/browse/ERL-459 explains why the error and would
suggest that cb_admin won't run on erlang 20.0 without that method
(crpto:rand_bytes) being changed to crpto:strong_rand_bytes. I thought
I'd have a go at making the change. I new (again) to erlang, having
begun learning it more then 10 years ago. The difficulty is trying to
learn it around the margins of life and work but a new website and an
erlang framework seems an opportunity.

My question for this morning (sorry to be long winded): how active is
the Chicago Boss community. I like the simplicity of the CB approach
over Nitrogen or Zotonic but am concerned about how actively it is being
maintained.

In any event,

Thanks for any response in advance,

- Greg.

Dmitry Polyanovsky

unread,
Sep 12, 2017, 1:47:43 AM9/12/17
to ChicagoBoss
not too active. you can get answers, but it takes time. Most issues solved only if you one who submit PR.

Igor Clark

unread,
Sep 14, 2017, 11:53:14 AM9/14/17
to chica...@googlegroups.com
Hi Greg, maybe it didn't come through to you for some reason but Graeme Defty did reply to your message, on Aug 29:


Hope it helps!

Cheers,
Igor

--
You received this message because you are subscribed to the Google Groups "ChicagoBoss" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chicagoboss+unsubscribe@googlegroups.com.
Visit this group at https://groups.google.com/group/chicagoboss.

Jesse Gumm

unread,
Sep 14, 2017, 12:26:44 PM9/14/17
to chica...@googlegroups.com
Also, I'll add that a solution that could be added to be more generalized would be to add a compatibility script that adds a macro to be defined based on which version of Erlang you're running.

You can see how I do it for simple_bridge and its crypto compat script here: https://github.com/nitrogen/simple_bridge/blob/master/crypto_compat.escript#L27-L32


Adding something like this to either cb_admin or CB proper should be rather simple.

The alternative, if it's not run too frequently would be to make a compat function that simply checks for the existence of the function during runtime, but obviously, if it's something being run very frequently, you probably don't want to do that for performance reasons:


cb_rand_bytes() ->
     case erlang:function_exported(crypto, strong_rand_bytes, 1) of
         true ->
           crypto:strong_rand_bytes(2048);
         false ->
           crypto:rand_bytes(2048)
    end.


A similar thing will have to be employed for anything relying on crypto:rand_uniform/2, which has been deprecated in 20.

-Jesse





For more options, visit https://groups.google.com/d/optout.



--
Jesse Gumm
Owner, Sigma Star Systems
414.940.4866 || sigma-star.com || @jessegumm
Reply all
Reply to author
Forward
0 new messages