From be8841d9af2aba23222776fccafc13a1cee940f2 Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Wed, 11 Dec 2024 15:46:23 +0100 Subject: [PATCH] util:legacy - ignore plugins_interfaces() errors in write_config() when called without sufficient imports (missing libraries in registered plugins). Scripts like https://github.com/opnsense/core/blob/master/src/etc/rc.expireaccounts will die horribly at the moment when there's actual work to be done (although this example should likely be rmeoved for 25.1 anyway) --- src/etc/inc/config.inc | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/etc/inc/config.inc b/src/etc/inc/config.inc index 8163bccfb..d57ec1e39 100644 --- a/src/etc/inc/config.inc +++ b/src/etc/inc/config.inc @@ -197,7 +197,20 @@ function write_config($desc = '', $backup = true) } } - plugins_interfaces(); + /** + * XXX: Temporary construction. + * When called via a legacy interface configure page, we might want to register new interfaces, but + * in cases we just want to save our changes (not related to interfaces), we risk raising errors for + * missing imports. + * Eventually relevant callers should call 'interface invoke registration', which is the same as + * mvc components use now (but can't be called here without side effects) + */ + try { + plugins_interfaces(); + } catch (Throwable $e) { + null; + } + $cnf = OPNsense\Core\Config::getInstance(); $cnf->fromArray($config);