ndejong / pfsense_fauxapi

REST based API interface for pfSense 2.3.x and 2.4.x to facilitate devops
Apache License 2.0
354 stars 61 forks source link

pfSense 2.4.4-p3 - URL table alias updating broken (simple fix) #70

Closed eli-kaplan closed 3 years ago

eli-kaplan commented 4 years ago

Upon updating pfSense from 2.4.4 to 2.4.4-p3 I noticed that calling that alias_update_urltables seemed to no longer trigger any server-side activity. I updated FauxAPI to the latest package version, and the issue was not resolved, so I did a bit of digging, and found the issue:

In /etc/inc/fauxapi/fauxapi_pfsense_interface.inc (line 707), the following logic is used to retrieve URL table aliases:

if (
            array_key_exists('aliases', $config) and
            is_array($config['aliases']) and
            array_key_exists('aliases', $config['aliases'])) {
                foreach ($config['alias']['alias'] as $alias) {
                    if (preg_match('/urltable/i', $alias['type'])) {
...

However, it seems that either this is a typo, or pfSense 2.4.4-p3 (or one of the intermediate versions) changed the configuration path for aliases, so the list of aliases now resides at $config['aliases']['alias']. Updating the above conditional to the following fixes this issue, and restores URL table updating functionality:

if (
            array_key_exists('aliases', $config) and
            is_array($config['aliases']) and
            array_key_exists('alias', $config['aliases'])) {
                foreach ($config['aliases']['alias'] as $alias) {
                    if (preg_match('/urltable/i', $alias['type'])) {

I am not sure if this is specific to 2.4.4-p3 - however, this is the configuration path used to retrieve URL table aliases in the installed version of /etc/rc.update_urltables, which FauxAPI's alias_update_urltables() is based off of.

k1ng440 commented 3 years ago

fix does not work in pfsense 2.5.1

ndejong commented 3 years ago

Yep - this is a bug - working on a new version that will patch this