]> granicus.if.org Git - ejabberd/commitdiff
Improve logging of external authentication failures
authorEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 8 May 2018 06:36:34 +0000 (09:36 +0300)
committerEvgeniy Khramtsov <ekhramtsov@process-one.net>
Tue, 8 May 2018 06:36:34 +0000 (09:36 +0300)
src/ejabberd_auth_external.erl

index b36c519d6d914c47a039d1e96eba90871bdab3b9..ec30870dbb1843c94399f2077de724260dd0dd58 100644 (file)
@@ -64,27 +64,27 @@ check_password(User, AuthzId, Server, Password) ->
 set_password(User, Server, Password) ->
     case extauth:set_password(User, Server, Password) of
        Res when is_boolean(Res) -> ok;
-       {error, Reason} -> failure(Reason)
+       {error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
     end.
 
 try_register(User, Server, Password) ->
     case extauth:try_register(User, Server, Password) of
        true -> ok;
        false -> {error, not_allowed};
-       {error, Reason} -> failure(Reason)
+       {error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
     end.
 
 user_exists(User, Server) ->
     case extauth:user_exists(User, Server) of
        Res when is_boolean(Res) -> Res;
-       {error, Reason} -> failure(Reason)
+       {error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
     end.
 
 remove_user(User, Server) ->
     case extauth:remove_user(User, Server) of
        false -> {error, not_allowed};
        true -> ok;
-       {error, Reason} -> failure(Reason)
+       {error, Reason} -> failure(User, Server, ?FUNCTION_NAME, Reason)
     end.
 
 check_password_extauth(User, _AuthzId, Server, Password) ->
@@ -92,16 +92,17 @@ check_password_extauth(User, _AuthzId, Server, Password) ->
            case extauth:check_password(User, Server, Password) of
                Res when is_boolean(Res) -> Res;
                {error, Reason} ->
-                   failure(Reason),
+                   failure(User, Server, ?FUNCTION_NAME, Reason),
                    false
            end;
        true ->
            false
     end.
 
--spec failure(any()) -> {error, db_failure}.
-failure(Reason) ->
-    ?ERROR_MSG("External authentication program failure: ~p", [Reason]),
+-spec failure(binary(), binary(), atom(), any()) -> {error, db_failure}.
+failure(User, Server, Fun, Reason) ->
+    ?ERROR_MSG("External authentication program failed when calling "
+              "'~s' for ~s@~s: ~p", [Fun, User, Server, Reason]),
     {error, db_failure}.
 
 opt_type(extauth_cache) ->