diff --git a/src/etc/inc/system.inc b/src/etc/inc/system.inc index 65cf9ad4e..ffa94d0f0 100644 --- a/src/etc/inc/system.inc +++ b/src/etc/inc/system.inc @@ -306,12 +306,9 @@ function get_searchdomains() } } - if (is_array($search_list)) { - foreach ($search_list as $fdns) { - $contents = file($fdns, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); - if (!is_array($contents)) { - continue; - } + foreach ($search_list as $fdns) { + $contents = file($fdns, FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES); + if (is_array($contents)) { foreach ($contents as $dns) { if (!empty($dns) && is_hostname($dns)) { $master_list[] = $dns; @@ -365,7 +362,9 @@ function get_nameservers($interface = null, $with_gateway = false) foreach ($dns_lists as $fdns) { /* inspect dynamic servers registered in the system files */ - $intf = explode('_', basename($fdns), 2); + $intf = []; + $intf[0] = preg_replace('/_[^_]+$/', '', basename($fdns)); + $intf[1] = preg_replace('/^.+_/', '', basename($fdns)); $intf[1] = strpos($intf[1], 'v6') === false ? '4' : '6'; if (in_array($intf, $exclude_interfaces)) { continue; diff --git a/src/opnsense/scripts/interfaces/ifctl.sh b/src/opnsense/scripts/interfaces/ifctl.sh index 3eb87bfa1..e6d2a6cb3 100755 --- a/src/opnsense/scripts/interfaces/ifctl.sh +++ b/src/opnsense/scripts/interfaces/ifctl.sh @@ -142,9 +142,9 @@ elif [ "${DO_COMMAND}" = "-l" ]; then for MATCH in ${MATCHES}; do FILE=${MATCH##*/} - IF=${FILE%%:*} - IF=${IF%%_*} - MD=${FILE#*_} + IF=${FILE%_*} + IF=${IF%%:*} + MD=${FILE##*_} # suffix :slaac sorts before plain interface # so we can export the resulting file name first @@ -170,7 +170,7 @@ if [ -z "${IF}" ]; then # list all interfaces that have the requested file for FOUND in $(find -s /tmp -name "${FILE#/tmp/}"); do FOUND=${FOUND#/tmp/} - FOUND=${FOUND%%_*} + FOUND=${FOUND%_*} FOUND=${FOUND%:*} if [ -z "$(eval echo \${${FOUND}_found})" ]; then RESULTS="${RESULTS} ${FOUND}_found"