Repository navigation
[pfsense] Do not write config.xml while the Nexus controller serves the configuration - #420
Merged
Merged
Conversation
…he configuration On pfSense Plus 26.07, pfSense reads its configuration from the Netgate Nexus controller whenever the controller answers on its socket, whatever its Enable setting says. Writing config.xml then changes a file pfSense does not read, and the reload that follows can leave the firewall on a configuration that matches neither. write_config() now fails before writing when the controller serves the configuration, with the same test as pfSense's pfnet_controller_ready(): the socket exists and its ping answers 200.
Contributor
|
Sorry you got bit by this, but glad we got it before the release. I think I'm pretty much done with my latest exercising of the modules. I can build my firewalls from scratch now (minus Wireguard). I might wait a bit longer and test out Wireguard before releasing 0.8.0, but we're pretty close. Let me know if anything changes on your end. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Describe the bug
On pfSense Plus 26.07, pfSense reads its configuration from the Netgate Nexus controller whenever the controller answers on its socket (
pfnet_controller_ready()andconfig_provider_init()in/etc/inc/config.lib.inc), whatever the controller's Enable setting says. The modules still read and write/cf/conf/config.xmldirectly, then delete/tmp/config.cache: the next PHP call asks the controller to reload, and pfSense goes on with whatever the controller serves.On one of our firewalls (pfSense Plus 26.07.2) this took the site offline:
service pfnet-controller restartwhenever/var/etc/pfnet-controller/pfnet-controller.confexists, and the package had been reinstalled.pfsense_aliaschange wrote config.xml.config_get_path()returned no virtual IP and no address for the WAN interface. config.xml still had them: the nextpfsense_aliastasks read it fine.I could not find why the controller's reload lost those values: its log stayed on the firewall. But config.xml is not what pfSense reads while the controller runs, so writing it then cannot be safe.
To Reproduce
pfsense_alias.Expected behavior
The module refuses to write, instead of changing a file that pfSense does not read.
Fix
write_config()first checks whether the controller serves the configuration, with the same test aspfnet_controller_ready(): the socket/var/run/pfnet-controller.sockexists, andGET /api/config/?pinganswers 200.config.incwould read the configuration through the controller.Tests
test_config_write.py:ruff checkandruff format --checkpass./etc/inc/globals.plus.incandconfig.lib.incon pfSense Plus 26.07.2.