]> granicus.if.org Git - ejabberd/commitdiff
When passwords are scrammed, report check_password_hash cannot work (#559)
authorBadlop <badlop@process-one.net>
Thu, 25 Jun 2015 11:39:45 +0000 (13:39 +0200)
committerBadlop <badlop@process-one.net>
Thu, 25 Jun 2015 11:39:45 +0000 (13:39 +0200)
src/mod_admin_extra.erl

index 6fbf762eb73cdd34495cc9e7b1b3c238b33600ec..436108ead4fcf08084612248afb331c192722dc2 100644 (file)
@@ -515,12 +515,16 @@ set_password(User, Host, Password) ->
 %% Copied some code from ejabberd_commands.erl
 check_password_hash(User, Host, PasswordHash, HashMethod) ->
     AccountPass = ejabberd_auth:get_password_s(User, Host),
-    AccountPassHash = case HashMethod of
-                         "md5" -> get_md5(AccountPass);
-                         "sha" -> get_sha(AccountPass);
+    AccountPassHash = case {AccountPass, HashMethod} of
+                         {A, _} when is_tuple(A) -> scrammed;
+                         {_, "md5"} -> get_md5(AccountPass);
+                         {_, "sha"} -> get_sha(AccountPass);
                          _ -> undefined
                      end,
     case AccountPassHash of
+       scrammed ->
+           ?ERROR_MSG("Passwords are scrammed, and check_password_hash can not work.", []),
+           throw(passwords_scrammed_command_cannot_work);
        undefined -> error;
        PasswordHash -> ok;
        _ -> error