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
}
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;
}
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.",
{
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)) {
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
* 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;