Bug #15772
closedCaptive Portal zones can fail to start due to ID conflict
100%
Description
There seems to be a bug inside services_captiveportal.php which allows, under specific circumstances, the creation of multiple captive portal zones with the same zoneid.
Result:
The newly created captive portal zone does not start, and nginx logs "bind() to 0.0.0.0:80XX failed (48: Address already in use)".
Also, the previously existing captive portal zone with the same zoneid stops working until its configuration is re-applied (edit -> save).
How to reproduce:
- Create three captive portal zones. This results in the zoneids 2, 4, 6 to be created and saved inside the configuration in this order.
- Delete the second captive portal zone. This results in the zoneids 2, 6 being present inside the configuration in this order.
- Create one captive portal zone. This results in the zoneids 2, 6, 4 being present inside the configuration in this order.
- Create another captive portal zone. This triggers the bug and results in the zoneids 2, 6, 4, 6 being present inside the configuration in this order.
Reason:
The code inside /usr/local/www/services_captiveportal.php (lines 327-334) seems to require, that the captive portal zones inside the configuration are correctly ordered by their zoneids. If that's not the case, the zoneid conflict may occur once a new captive portal zone is created.