25
1
mirror of https://github.com/processone/ejabberd.git synced 2024-11-20 16:15:59 +01:00

Don't start sql connection pools for unknown hosts

It's possible to trigger that by passing wrong domain to some ctl commands,
and if you don't have default credentials for sql connections, you get
repeating errors when this pools tries to reconnect from error.
This commit is contained in:
Paweł Chmielowski 2024-04-04 11:05:29 +02:00
parent dbf0fb8e86
commit 735516ed37

View File

@ -37,6 +37,11 @@ start(Host) ->
case is_started(Host) of
true -> ok;
false ->
case lists:member(Host, ejabberd_option:hosts()) of
false ->
?WARNING_MSG("Rejecting start of sql worker for unknown host: ~ts", [Host]),
{error, invalid_host};
true ->
App = case ejabberd_option:sql_type(Host) of
mysql -> p1_mysql;
pgsql -> p1_pgsql;
@ -62,6 +67,7 @@ start(Host) ->
?ERROR_MSG("Failed to start ~ts: ~p", [?MODULE, Why]),
Err
end
end
end.
stop(Host) ->