diff --git a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php index 694cb855c..8aa9b1654 100644 --- a/src/opnsense/mvc/app/library/OPNsense/Core/Config.php +++ b/src/opnsense/mvc/app/library/OPNsense/Core/Config.php @@ -69,6 +69,10 @@ class Config extends Singleton */ private $statusIsValid = false; + /** + * @var float current modification time of our known config + */ + private $mtime = 0; /** * return last known status of this configuration (valid or not) @@ -430,6 +434,7 @@ class Config extends Singleton } $this->simplexml = $this->loadFromStream($this->config_file_handle); + $this->mtime = fstat($this->config_file_handle)['mtime']; $this->statusIsValid = true; } @@ -659,6 +664,14 @@ class Config extends Singleton } } + /** + * @return bool when config file underneath has changed without our instance being aware of it + */ + public function hasChanged() + { + return $this->mtime != fstat($this->config_file_handle)['mtime']; + } + /** * return backup file path if revision exists * @param $revision revision timestamp (e.g. 1583766095.9337) @@ -728,6 +741,7 @@ class Config extends Singleton $logger->info("config-event: new_config " . $backup_filename); } flock($this->config_file_handle, LOCK_UN); + $this->mtime = fstat($this->config_file_handle)['mtime']; } else { throw new ConfigException("Unable to lock config"); }