]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
don't complain about "-sql" when the module isn't defined
authorAlan T. DeKok <aland@freeradius.org>
Fri, 12 Dec 2025 20:58:57 +0000 (15:58 -0500)
committerAlan T. DeKok <aland@freeradius.org>
Fri, 12 Dec 2025 20:58:57 +0000 (15:58 -0500)
this cleans up the debug output and makes it easier to read.

src/lib/server/module_rlm.c
src/lib/unlang/compile.c

index 22ffc9b68764c9a19e091f3c27f7fec3464c5cd6..b752457e9e84a290c64261044278bb3759629838 100644 (file)
@@ -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;
                }
index a23e456a1469822293682f090008e31765935e13..b606be702788f836680dce0ec6fb64521bc2b93e 100644 (file)
@@ -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;