All hook_parse_cmdline take now the id as the first argument. This is required because zone_config_check_same_setting needs the id to ignore the config we edit in the moment. All hook_parse_cmdline functions are changed to keep the generic hook_edit function working. Another option was to write an own hook_edit function for the ipv4-static and ipv6-static hook. But this solution is not easier then to keep things more generic and equal. Makes also maintaining easier.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/hooks/configs/dhcp | 4 ++++ src/hooks/configs/ipv4-static | 7 ++++++- src/hooks/configs/ipv6-auto | 5 +++++ src/hooks/configs/ipv6-static | 7 ++++++- src/hooks/configs/pppoe-server | 5 +++++ 5 files changed, 26 insertions(+), 2 deletions(-)
diff --git a/src/hooks/configs/dhcp b/src/hooks/configs/dhcp index 7f6780b..f1c43f3 100644 --- a/src/hooks/configs/dhcp +++ b/src/hooks/configs/dhcp @@ -35,6 +35,10 @@ hook_check_config_settings() { }
hook_parse_cmdline() { + local id=${1} + shift + + assert isinteger id while [ $# -gt 0 ]; do case "${1}" in --enable-ipv6) diff --git a/src/hooks/configs/ipv4-static b/src/hooks/configs/ipv4-static index ef74991..a6b010f 100644 --- a/src/hooks/configs/ipv4-static +++ b/src/hooks/configs/ipv4-static @@ -36,6 +36,11 @@ hook_check_config_settings() { }
hook_parse_cmdline() { + local id=${1} + shift + + assert isinteger id + local arg
while read -r arg; do @@ -99,7 +104,7 @@ hook_parse_cmdline() { exit ${EXIT_CONF_ERROR} fi
- if zone_config_check_same_setting "${zone}" "ipv4-static" "ADDRESS" "${ADDRESS}"; then + if zone_config_check_same_setting "${zone}" "ipv4-static" ${id} "ADDRESS" "${ADDRESS}"; then error "An ipv4-static config with the same IPv4 address is already configured" exit ${EXIT_CONF_ERROR} fi diff --git a/src/hooks/configs/ipv6-auto b/src/hooks/configs/ipv6-auto index 375e585..e89af28 100644 --- a/src/hooks/configs/ipv6-auto +++ b/src/hooks/configs/ipv6-auto @@ -31,6 +31,11 @@ hook_check_config_settings() { }
hook_parse_cmdline() { + local id=${1} + shift + + assert isinteger id + local arg
while read arg; do diff --git a/src/hooks/configs/ipv6-static b/src/hooks/configs/ipv6-static index c41401c..bb75240 100644 --- a/src/hooks/configs/ipv6-static +++ b/src/hooks/configs/ipv6-static @@ -34,6 +34,11 @@ hook_check_config_settings() { }
hook_parse_cmdline() { + local id=${1} + shift + + assert isinteger id + while [ $# -gt 0 ]; do case "${1}" in --address=*) @@ -49,7 +54,7 @@ hook_parse_cmdline() { shift done
- if zone_config_check_same_setting "${zone}" "ipv6-static" "ADDRESS" "${ADDRESS}"; then + if zone_config_check_same_setting "${zone}" "ipv6-static" ${id} "ADDRESS" "${ADDRESS}"; then error "An ipv6-static config with the same IPv6 address is already configured" exit ${EXIT_CONF_ERROR} fi diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe-server index b4d2538..5861e70 100644 --- a/src/hooks/configs/pppoe-server +++ b/src/hooks/configs/pppoe-server @@ -49,6 +49,11 @@ hook_check_config_settings() { }
hook_parse_cmdline() { + local id=${1} + shift + + assert isinteger id + while [ $# -gt 0 ]; do case "${1}" in --dns-server=*)