mosquitto icon indicating copy to clipboard operation
mosquitto copied to clipboard

[plugin] options not passed with reload event

Open wwizz opened this issue 9 months ago • 2 comments

Hi,

I am developing a plugin and I want to support reload of the configuration file. As far as I understand I need to subscribe to the MOSQ_EVT_RELOAD with mosquitto_callback_register.

res = mosquitto_callback_register(mosq_pid, MOSQ_EVT_RELOAD, mosq_callback_reload, nullptr, nullptr);
    if (res != MOSQ_ERR_SUCCESS) {
        plugin_printf(MOSQ_LOG_ERR, "Error: %s", res);
        return res;
    }

When reload happens I see the callback being executed with struct mosquitto_evt_reload. However the options are not set when the plugin get called.


static int mosq_callback_reload(int /*unused*/, void *event_data, void * /*unused*/) {
    auto *evt_message = static_cast<struct mosquitto_evt_reload *>(event_data);
    // event_data->options = NULL
    return 0;
}

As far as I understand from the code that is not implemented:

https://github.com/eclipse-mosquitto/mosquitto/blob/c6c6850d5c23fbf4a29aab2281b22b7a2fa2640b/src/security.c#L469

Is this a correct assumtion?

wwizz avatar Apr 14 '25 13:04 wwizz

Yes, that's correct. As it stands it's not possible to change a plugin configuration once it is loaded, and the plugin options are not passed to the reload callback. I'm afraid it's unlikely this will change in the short term.

ralight avatar May 01 '25 12:05 ralight

you could probably parse it yourself upon the callback though.

/proc/self/cmdline should contain the whole command line used to start mosquitto if started with a -c flag.

otherwise, just open the standard /etc/mosquitto/mosquitto.conf file and parse it :)

hacky, but works in theory.

Daedaluz avatar May 01 '25 21:05 Daedaluz