]> git.ipfire.org Git - thirdparty/freeradius-server.git/commitdiff
Make exfile based triggers optional
authorNick Porter <nick@portercomputing.co.uk>
Fri, 22 Aug 2025 09:14:15 +0000 (10:14 +0100)
committerNick Porter <nick@portercomputing.co.uk>
Mon, 25 Aug 2025 13:56:11 +0000 (14:56 +0100)
Otherwise, enabling triggers will cause `rlm_linelog` and `rlm_detail`
to perform a lot of hunting for configured triggers as files are openned
and closed.

src/lib/server/module_rlm.c
src/lib/server/module_rlm.h
src/modules/rlm_detail/rlm_detail.c
src/modules/rlm_linelog/rlm_linelog.c
src/modules/rlm_sql/rlm_sql.c

index 5d0da277e25b53b9f91cd786dfcedb9cce9f708f..57ba6df3f1f3eae84cc7c24715a5d5a806e6ae76 100644 (file)
@@ -93,6 +93,7 @@ void module_rlm_list_debug(void)
  * @param[in] max_entries      Max file descriptors to cache, and manage locks for.
  * @param[in] max_idle         Maximum time a file descriptor can be idle before it's closed.
  * @param[in] locking          Whether or not to lock the files.
+ * @param[in] triggers         Should triggers be enabled.
  * @param[in] trigger_prefix   if NULL will be set automatically from the module CONF_SECTION.
  * @param[in] trigger_args     to make available in any triggers executed by the connection pool.
  * @return
@@ -104,6 +105,7 @@ exfile_t *module_rlm_exfile_init(TALLOC_CTX *ctx,
                                 uint32_t max_entries,
                                 fr_time_delta_t max_idle,
                                 bool locking,
+                                bool triggers,
                                 char const *trigger_prefix,
                                 fr_pair_list_t *trigger_args)
 {
@@ -118,7 +120,7 @@ exfile_t *module_rlm_exfile_init(TALLOC_CTX *ctx,
        handle = exfile_init(ctx, max_entries, max_idle, locking);
        if (!handle) return NULL;
 
-       exfile_enable_triggers(handle, cf_section_find(module, "file", NULL), trigger_prefix, trigger_args);
+       if (triggers) exfile_enable_triggers(handle, cf_section_find(module, "file", NULL), trigger_prefix, trigger_args);
 
        return handle;
 }
index c0d00984ebc7cc1959e036ae89c057e104683e80..a67243b35a824a3b8cf51c6b92c1bf7f3b9c2275 100644 (file)
@@ -103,6 +103,7 @@ exfile_t            *module_rlm_exfile_init(TALLOC_CTX *ctx,
                                                uint32_t max_entries,
                                                fr_time_delta_t max_idle,
                                                bool locking,
+                                               bool triggers,
                                                char const *trigger_prefix,
                                                fr_pair_list_t *trigger_args);
 /** @} */
index 40174d0f0d7cceb151c69eb3799610fd4767f92a..c6ef1fab1bb1b3714bf1fca7cdd81df18b3d8d41 100644 (file)
@@ -58,6 +58,8 @@ typedef struct {
        bool            escape;         //!< do filename escaping, yes / no
 
        exfile_t        *ef;            //!< Log file handler
+
+       bool            triggers;       //!< Do we run triggers.
 } rlm_detail_t;
 
 typedef struct {
@@ -77,6 +79,7 @@ static const conf_parser_t module_config[] = {
        { FR_CONF_OFFSET("locking", rlm_detail_t, locking), .dflt = "no" },
        { FR_CONF_OFFSET("escape_filenames", rlm_detail_t, escape), .dflt = "no" },
        { FR_CONF_OFFSET("log_packet_header", rlm_detail_t, log_srcdst), .dflt = "no" },
+       { FR_CONF_OFFSET("triggers", rlm_detail_t, triggers) },
        CONF_PARSER_TERMINATOR
 };
 
@@ -157,7 +160,8 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
        rlm_detail_t    *inst = talloc_get_type_abort(mctx->mi->data, rlm_detail_t);
        CONF_SECTION    *conf = mctx->mi->conf;
 
-       inst->ef = module_rlm_exfile_init(inst, conf, 256, fr_time_delta_from_sec(30), inst->locking, NULL, NULL);
+       inst->ef = module_rlm_exfile_init(inst, conf, 256, fr_time_delta_from_sec(30), inst->locking,
+                                         inst->triggers, NULL, NULL);
        if (!inst->ef) {
                cf_log_err(conf, "Failed creating log file context");
                return -1;
index d31665ef2c1f107a92b03e8d560fb20915cdf167..396b5abc6e6e1c3a860616cf2096f72205b7b15c 100644 (file)
@@ -133,6 +133,8 @@ typedef struct {
        linelog_net_t           udp;                    //!< UDP server.
 
        CONF_SECTION            *cs;                    //!< #CONF_SECTION to use as the root for #log_ref lookups.
+
+       bool                    triggers;               //!< Do we do triggers.
 } rlm_linelog_t;
 
 typedef struct {
@@ -178,6 +180,8 @@ static const conf_parser_t module_config[] = {
 
        { FR_CONF_OFFSET("delimiter", rlm_linelog_t, delimiter), .dflt = "\n" },
 
+       { FR_CONF_OFFSET("triggers", rlm_linelog_t, triggers) },
+
        /*
         *      Log destinations
         */
@@ -960,7 +964,8 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
                }
                if (!cf_pair_find(cs, "filename")) goto no_filename;
 
-               inst->file.ef = module_rlm_exfile_init(inst, conf, 256, fr_time_delta_from_sec(30), true, NULL, NULL);
+               inst->file.ef = module_rlm_exfile_init(inst, conf, 256, fr_time_delta_from_sec(30), true,
+                                                      inst->triggers, NULL, NULL);
                if (!inst->file.ef) {
                        cf_log_err(conf, "Failed creating log file context");
                        return -1;
index dbcc6627a0b2c89aa0baae4c65d1d524efb67bec..1683dc25e5b94972ce4ac7c85a40e8836b1f1795 100644 (file)
@@ -2184,7 +2184,7 @@ static int mod_instantiate(module_inst_ctx_t const *mctx)
                .always_escape = false,
        };
 
-       inst->ef = module_rlm_exfile_init(inst, conf, 256, fr_time_delta_from_sec(30), true, NULL, NULL);
+       inst->ef = module_rlm_exfile_init(inst, conf, 256, fr_time_delta_from_sec(30), true, false, NULL, NULL);
        if (!inst->ef) {
                cf_log_err(conf, "Failed creating log file context");
                return -1;