From 07985a3db3b05bbd0308d6792f7f462df198bcac Mon Sep 17 00:00:00 2001 From: Ad Schellevis Date: Tue, 15 Oct 2024 15:26:25 +0200 Subject: [PATCH] Config - fix file open mode in overwrite(), to prevent trying to open a lock on a boolean. This is a bit of an edge case, but when someone removes /conf/config.xml and backups exists, we can not construct a config object anymore. --- src/opnsense/mvc/app/library/OPNsense/Core/Config.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index fd55ccd4b..ec9177bcd 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -626,7 +626,7 @@ class Config extends Singleton */ private function overwrite($filename) { - $fhandle = fopen($this->config_file, "r+"); + $fhandle = fopen($this->config_file, "a+e"); if (flock($fhandle, LOCK_EX)) { fseek($fhandle, 0); chmod($this->config_file, 0640);