Page MenuHomekolab.org

Winterfell: guam has problem, bad argument in call to binary:match
Closed, ResolvedPublic

Description

this is in Winterfell on CentOS7:

journalctl -f -u guam shows:

Jun 14 07:51:21 050-centos7winterfell.kolab.pokorra.de guam[2331]: 07:51:20.473 [error] Supervisor {<0.93.0>,kolab_guam_listener} had child undefined started with {kolab_guam_session,start_link,undefined} at <0.1517.0> exit with reason bad argument in call to binary:match([{capabilities,<<"IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN AUTH=LOGIN SASL-IR">>},{server_id,<<"050...">>}], <<"STARTTLS">>) in kolab_guam_session:ensure_hello_does_not_have_starttls/1 line 307 in context child_terminated
Jun 14 07:51:27 050-centos7winterfell.kolab.pokorra.de guam[2331]: 07:51:27.045 [error] gen_server <0.1521.0> terminated with reason: bad argument in call to binary:match([{capabilities,<<"IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN AUTH=LOGIN SASL-IR">>},{server_id,<<"050...">>}], <<"STARTTLS">>) in kolab_guam_session:ensure_hello_does_not_have_starttls/1 line 307
Jun 14 07:51:27 050-centos7winterfell.kolab.pokorra.de guam[2331]: 07:51:27.046 [error] CRASH REPORT Process <0.1521.0> with 1 neighbours exited with reason: bad argument in call to binary:match([{capabilities,<<"IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN AUTH=LOGIN SASL-IR">>},{server_id,<<"050...">>}], <<"STARTTLS">>) in kolab_guam_session:ensure_hello_does_not_have_starttls/1 line 307

Details

Ticket Type
Task

Event Timeline

pokorra created this task.EditedJun 14 2016, 9:48 AM

This only started to happen in the past days, as far as I can see.
First time of failure: Fri Jun 10 21:21:06 2016, it still worked on Thursday.
That coincides with the release of Guam 0.8: https://obs.kolabsys.com/package/revisions/Kolab:Winterfell/guam
It happens in a fresh vanilla installation

pokorra added a subscriber: Restricted Project.
pokorra added a comment.EditedJun 17 2016, 11:44 AM

seems like this patch https://cgit.kolab.org/guam/commit/apps/kolab_guam/src/kolab_guam_session.erl?id=ef2ec46e597f70734aab6673a9735b6a6f807507 could show the solution?
that applies to another function, but should be applied to ensure_hello_does_not_have_starttls as well?

after applying this patch:

diff --git a/apps/kolab_guam/src/kolab_guam_session.erl b/apps/kolab_guam/src/kolab_guam_session.erl
index 60a28cb..6ea710e 100644
--- a/apps/kolab_guam/src/kolab_guam_session.erl
+++ b/apps/kolab_guam/src/kolab_guam_session.erl
@@ -96,7 +96,7 @@ handle_info({ { rule_data, Module, ResponseToken }, Data }, #state{ rules_active
 handle_info({ imap_server_response, Data }, #state{ socket = Socket, imap_session = ImapSession, client_tls_active = TLS, def
     %lager:debug("FROM SERVER: ~s", [Data]),
     { ModifiedData, CurrentlyActiveRules } = apply_ruleset_serverside(ImapSession, Data, ActiveRules),
-    relay_response(Socket, postprocess_server_data(Deflator, ModifiedData), TLS),
+    relay_response(Socket, postprocess_server_data(Deflator, <<ModifiedData/binary, "\r\n">>), TLS),
     { noreply, State#state{ rules_active = CurrentlyActiveRules } };
 handle_info({ 'EXIT', PID, _Reason }, #state { imap_session = PID } = State) ->
     { stop, normal, State };
@@ -294,7 +294,8 @@ ensure_hello_has_starttls(ServerResponse) ->
         _ -> ServerHello
     end.
 
-add_starttls_to_capabilities(ServerHello) ->
+add_starttls_to_capabilities(ServerResponse) ->
+    ServerHello = proplists:get_value(capabilities, ServerResponse, <<>>),
     case binary:match(ServerHello, <<"CAPABILITY ">>) of
         nomatch -> ServerHello;
         { Start, End } ->
@@ -303,7 +304,8 @@ add_starttls_to_capabilities(ServerHello) ->
             <<Prefix/binary, "STARTTLS ", Suffix/binary>>
     end.
 
-ensure_hello_does_not_have_starttls(ServerHello) ->
+ensure_hello_does_not_have_starttls(ServerResponse) ->
+    ServerHello = proplists:get_value(capabilities, ServerResponse, <<>>),
     case binary:match(ServerHello, <<"STARTTLS">>) of
         nomatch -> ServerHello;
         { Start, End } ->

Now I get less errors, but when I try to connect with imtest -p 143 -m login 127.0.0.1, then I get in journalctl -f -u guam:

Jun 17 13:01:36 050-centos7winterfell.kolab.pokorra.de guam[7247]: 13:01:36.075 [error] gen_server <0.95.0> terminated with reason: no function clause matching proplists:get_value(capabilities, <<"IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN AUTH=LOGIN SASL-IR">>, <<>>) line 226
Jun 17 13:01:36 050-centos7winterfell.kolab.pokorra.de guam[7247]: 13:01:36.075 [error] CRASH REPORT Process <0.95.0> with 1 neighbours exited with reason: no function clause matching proplists:get_value(capabilities, <<"IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN AUTH=LOGIN SASL-IR">>, <<>>) line 226 in gen_server:terminate/7 line 826
Jun 17 13:01:37 050-centos7winterfell.kolab.pokorra.de guam[7247]: 13:01:36.076 [error] Supervisor {<0.90.0>,kolab_guam_listener} had child undefined started with {kolab_guam_session,start_link,undefined} at <0.95.0> exit with reason no function clause matching proplists:get_value(capabilities, <<"IMAP4rev1 LITERAL+ ID ENABLE AUTH=PLAIN AUTH=LOGIN SASL-IR">>, <<>>) line 226 in context child_terminated
vanmeeuwen closed this task as Resolved.Jul 13 2016, 11:41 AM
vanmeeuwen claimed this task.
vanmeeuwen added a subscriber: vanmeeuwen.

Please see if 0.8.3 exposes the same problems for you and reopen if necessary.

seigo moved this task from Backlog to Done on the Guam board.Dec 13 2016, 2:11 PM