From: Alan T. DeKok Date: Fri, 12 Dec 2025 20:58:57 +0000 (-0500) Subject: don't complain about "-sql" when the module isn't defined X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=13dab3f2a8a244add3121ccc10f23dfb48e93df2;p=thirdparty%2Ffreeradius-server.git don't complain about "-sql" when the module isn't defined this cleans up the debug output and makes it easier to read. --- diff --git a/src/lib/server/module_rlm.c b/src/lib/server/module_rlm.c index 22ffc9b6876..b752457e9e8 100644 --- a/src/lib/server/module_rlm.c +++ b/src/lib/server/module_rlm.c @@ -585,12 +585,15 @@ fr_slen_t module_rlm_by_name_and_method(TALLOC_CTX *ctx, module_method_call_t *m module_method_binding_t const *mmb; fr_sbuff_marker_t meth_start; + bool softfail; fr_slen_t slen; fr_sbuff_t our_name = FR_SBUFF(name); mmc = mmc_out ? mmc_out : &mmc_tmp; - if (mmc_out) memset(mmc_out, 0, sizeof(*mmc_out)); + if (mmc_out) *mmc_out = (module_method_call_t) {}; + + softfail = fr_sbuff_next_if_char(&our_name, '-'); /* * Advance until the start of the dynamic selector @@ -683,6 +686,8 @@ fr_slen_t module_rlm_by_name_and_method(TALLOC_CTX *ctx, module_method_call_t *m } if (!mmc->mi) { + if (softfail) return fr_sbuff_set(name, &our_name); + fr_strerror_printf("No such module '%pV'", fr_box_strvalue_len(our_name.start, slen)); return -1; } diff --git a/src/lib/unlang/compile.c b/src/lib/unlang/compile.c index a23e456a146..b606be70278 100644 --- a/src/lib/unlang/compile.c +++ b/src/lib/unlang/compile.c @@ -1815,6 +1815,11 @@ static unlang_t *compile_module(unlang_t *parent, unlang_compile_ctx_t *unlang_c return NULL; } + /* + * We parsed a string, but we were told to ignore it. Don't do anything. + */ + if (!m->mmc.rlm) return UNLANG_IGNORE; + if (m->mmc.rlm->common.dict && !fr_dict_compatible(*m->mmc.rlm->common.dict, unlang_ctx->rules->attr.dict_def)) { cf_log_err(ci, "The '%s' module can only be used within a '%s' namespace.", @@ -1986,11 +1991,9 @@ static unlang_t *compile_item(unlang_t *parent, unlang_compile_ctx_t *unlang_ctx { char const *name, *p; CONF_SECTION *cs, *subcs, *modules; - char const *realname; unlang_compile_ctx_t unlang_ctx2; bool policy; unlang_t *c; - bool ignore_notfound = false; unlang_op_t const *op; if (cf_item_is_section(ci)) { @@ -2139,16 +2142,6 @@ check_for_module: return NULL; } - realname = name; - - /* - * Try to load the optional module. - */ - if (*realname == '-') { - ignore_notfound = true; - realname++; - } - /* * Set the child compilation context BEFORE parsing the * module name and method. The lookup function will take @@ -2156,16 +2149,7 @@ check_for_module: * name2, etc. */ UPDATE_CTX2; - c = compile_module(parent, &unlang_ctx2, ci, realname); - if (!c) { - if (ignore_notfound) { - cf_log_warn(ci, "Ignoring \"%s\" as the \"%s\" module is not enabled, " - "or the method does not exist", name, realname); - return UNLANG_IGNORE; - } - - return NULL; - } + c = compile_module(parent, &unlang_ctx2, ci, name); allocate_number: if (!c) return NULL;