Improve legacy config parsing
This commit is contained in:
parent
4c6d6941e2
commit
36d4a2e9a8
|
@ -16,6 +16,7 @@ and this project **does not adhere to [Semantic Versioning](http://semver.org/sp
|
||||||
* use long options in some places
|
* use long options in some places
|
||||||
* output is normalized
|
* output is normalized
|
||||||
* source legacy config after macros but before DROP policy
|
* source legacy config after macros but before DROP policy
|
||||||
|
* improve legacy config parsing
|
||||||
|
|
||||||
### Deprecated
|
### Deprecated
|
||||||
|
|
||||||
|
|
|
@ -214,7 +214,8 @@ source_configuration() {
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if grep -e "iptables" -e "ip6tables" "${config_file}" | grep -qvE "^#"; then
|
# If we find something other than a blank line, a comment or a variable assignment
|
||||||
|
if grep --quiet --extended-regexp --invert-match "^\s*(#|$|\w+=)" "${config_file}"; then
|
||||||
# Backward compatible mode
|
# Backward compatible mode
|
||||||
###########################
|
###########################
|
||||||
|
|
||||||
|
@ -240,7 +241,8 @@ source_configuration() {
|
||||||
# and not interfere with the configuration step.
|
# and not interfere with the configuration step.
|
||||||
|
|
||||||
tmp_config_file=$(mktemp --tmpdir=/tmp minifirewall.XXX)
|
tmp_config_file=$(mktemp --tmpdir=/tmp minifirewall.XXX)
|
||||||
grep -E "^\s*[_a-zA-Z0-9]+=" "${config_file}" > "${tmp_config_file}"
|
# get only variable assignments
|
||||||
|
grep -E "^\s*\w+=" "${config_file}" > "${tmp_config_file}"
|
||||||
|
|
||||||
source_file_or_error "${tmp_config_file}"
|
source_file_or_error "${tmp_config_file}"
|
||||||
rm -f "${tmp_config_file}"
|
rm -f "${tmp_config_file}"
|
||||||
|
|
Loading…
Reference in a new issue