From 6af3ec29545257ac2c2e243eb7bec2ba65f3905d Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Tue, 19 Sep 2023 15:39:06 +0200 Subject: [PATCH] mvc: throw on template reload issues in mutable service controller #6487 While this omits all other callers of "template reload" functionality we would only like to be concerned with these GUI ones and migrate everything to using a mutable controller (for maintenance reasons at the very last). Only make a short hint to where the error is. The service is not started on purpose now. --- .../OPNsense/Base/ApiMutableServiceControllerBase.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php index 4580b0972..d6048e518 100644 --- a/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php +++ b/src/opnsense/mvc/app/controllers/OPNsense/Base/ApiMutableServiceControllerBase.php @@ -194,7 +194,10 @@ abstract class ApiMutableServiceControllerBase extends ApiControllerBase } if (!empty(static::$internalServiceTemplate)) { - $backend->configdRun('template reload ' . escapeshellarg(static::$internalServiceTemplate)); + $result = trim($backend->configdpRun('template reload', [static::$internalServiceTemplate]) ?? ''); + if ($result !== 'OK') { + throw new UserException(gettext('Template generation failed. See backend log for details.')); + } } if ($this->serviceEnabled()) {