Skip to content

pfSense CE 2.8.1 + RESTAPI 2.6.5: dhcp static mapping creates empty <dhcpd><wan></wan> and causes crash on DNS Resolver Apply (related to #781) #787

@AssiaAzzouzi

Description

@AssiaAzzouzi

Describe the bug

On pfSense CE 2.8.1 with the KEA DHCP backend and pfSense-pkg-RESTAPI-2.6_5, calling the v2 dhcp_server/static_mapping endpoint for a non-WAN interface (e.g. opt1) introduces an empty element into config.xml.

When the DNS Resolver configuration is applied (either via the GUI or via /api/v2/services/dns_resolver/apply while KEA is enabled), pfSense crashes.

This looks like a remaining instance of the problem that was addressed in #781 (“DHCPServer model initializing config for non-static interfaces”) since the v2.6.5 release notes say:

“Fixes an issue where the DHCPServer model could unintentionally initialize a DHCP server configuration for non-static interfaces. #781

To Reproduce

  1. Start from a clean config with KEA enabled and no <dhcpd><wan> block.
  2. Add static mapping with POST /api/v2/services/dhcp_server/static_mapping endpoint
  3. Download config.xml
  4. Apply static mapping with POST /api/v2/services/dhcp_server/apply
  5. In dns server add host override with: /api/v2/services/dns_resolver/host_override
  6. Apply new host override with /api/v2/services/dns_resolver/apply

Expected behavior

  • In the taken file in step 4. there should be no empty <dhcpd><wan></wan>
  • The new DHCP end DNS entries should be applied with no errors.

Actual behavior

  • Empty <dhcpd><wan></wan> is introduced in config.xml
  • pfsense crashes with this error:

PHP ERROR: Type: 1, File: /etc/inc/util.inc, Line: 3961, Message: Uncaught TypeError: array_get_path(): Argument #1 ($arr) must be of type array, string given, called in /usr/local/pfSense/include/www/services_dhcp.inc on line 162 and defined in /etc/inc/util.inc:3961
Stack trace:
#0 /usr/local/pfSense/include/www/services_dhcp.inc(162): array_get_path()
#1 /etc/inc/system.inc(628): kea_earlydnsreg_mappings()
#2 /etc/inc/system.inc(660): system_hosts_entries()
#3 /etc/inc/services.inc(4983): system_hosts_generate()
#4 /usr/local/www/services_unbound.php(88): services_unbound_configure()
#5 {main}
thrown

pfSense Version & Package Version:

  • pfSense Version: [e.g. pfSense 2.8.1]
  • Package Version [e.g. v2.6_5]

Affected Endpoints:

  • /api/v2/services/dhcp_server/static_mapping
  • /api/v2/services/dns_resolver/apply

Additional context

I had to make this workaround to make thinks work:

I went to Services → DHCP Server → set WAN with a dummy range while keeping DHCP disabled , saved & applied

that fills <wan></wan> with content and avoids crash. But it's not clean...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions