diff options
author | Badlop <badlop@process-one.net> | 2011-04-26 13:59:08 +0200 |
---|---|---|
committer | Badlop <badlop@process-one.net> | 2011-04-26 13:59:08 +0200 |
commit | 9b145385afa4fe300497c1925202bb2f9acc4e9d (patch) | |
tree | 013eeda2d9a46e1c7205a6004c2459e94356ccb1 /src | |
parent | Do not decrease MUC admin's role/affiliation (diff) |
Throw error when captcha fails at server start, not later at runtime
Diffstat (limited to 'src')
-rw-r--r-- | src/ejabberd_captcha.erl | 28 |
1 files changed, 8 insertions, 20 deletions
diff --git a/src/ejabberd_captcha.erl b/src/ejabberd_captcha.erl index ff0bd0d2..250dd333 100644 --- a/src/ejabberd_captcha.erl +++ b/src/ejabberd_captcha.erl @@ -428,10 +428,10 @@ get_prog_name() -> case ejabberd_config:get_local_option(captcha_cmd) of FileName when is_list(FileName) -> FileName; - _ -> + Value when (Value == undefined) or (Value == "") -> ?DEBUG("The option captcha_cmd is not configured, but some " "module wants to use the CAPTCHA feature.", []), - throw({error, option_not_configured_captcha_cmd}) + false end. get_url(Str) -> @@ -552,23 +552,10 @@ return(Port, TRef, Result) -> catch port_close(Port), Result. -is_feature_enabled() -> - try get_prog_name() of - Prog when is_list(Prog) -> true - catch - _:_ -> false - end. - is_feature_available() -> - case is_feature_enabled() of - false -> false; - true -> - %% Do not generate image in order to avoid CAPTCHA DoS - %% case create_image() of - %% {ok, _, _, _} -> true; - %% _Error -> false - %% end - true + case get_prog_name() of + Prog when is_list(Prog) -> true; + false -> false end. check_captcha_setup() -> @@ -576,10 +563,11 @@ check_captcha_setup() -> {ok, _, _, _} -> true; _Error -> false end, - case is_feature_enabled() andalso not AbleToGenerateCaptcha of + case is_feature_available() andalso not AbleToGenerateCaptcha of true -> ?CRITICAL_MSG("Captcha is enabled in the option captcha_cmd, " - "but it can't generate images.", []); + "but it can't generate images.", []), + throw({error, captcha_cmd_enabled_but_fails}); false -> ok end. |