]> git.ipfire.org Git - people/ms/network.git/commitdiff
Fix zone_config_check_same_setting
authorJonatan Schlag <jonatan.schlag@ipfire.org>
Wed, 7 Feb 2018 14:53:47 +0000 (14:53 +0000)
committerMichael Tremer <michael.tremer@ipfire.org>
Sun, 11 Feb 2018 22:29:39 +0000 (22:29 +0000)
Every time we edited a config zone_config_check_same_setting
returns that a identical config was found but this config was the config
we want to edit. So we now generate the id inside hook_new and pass the
id always to hook_parse_cmdline and to zone_config_check_same_setting.

So we can skip this config.

Fixes: #11451
Signed-off-by: Jonatan Schlag <jonatan.schlag@ipfire.org>
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.zone
src/header-config
src/hooks/configs/dhcp
src/hooks/configs/ipv6-auto
src/hooks/configs/pppoe-server

index f724f503bd182e44869ba9cc82df91cbc654e83d..58c034722e926b9976033ea2dff19b4a183117a6 100644 (file)
@@ -1097,22 +1097,29 @@ zone_config_check_same_setting() {
        # with the same setting is already configured for this zone.
        # Returns True when yes and False when no.
 
-       assert [ $# -eq 4 ]
+       assert [ $# -eq 5 ]
 
        local zone=${1}
        local hook=${2}
-       local key=${3}
-       local value=${4}
+       local id=${3}
+       local key=${4}
+       local value=${5}
 
        # The key should be local for this function
        local ${key}
        local config
 
        for config in $(zone_configs_list ${zone}); do
+               # Check if the config is eqal with the config we want to edit, when continue
+               if [[ "${config}" = "${hook}.${id}" ]]; then
+                       continue
+               fi
+
                # Check if the config is from the given hook, when not continue
                if  [[ $(zone_config_get_hook "${zone}" "${config}") != ${hook} ]]; then
                        continue
                fi
+
                # Get the value of the key for a given function
                zone_config_settings_read "${zone}" "${config}" \
                 --ignore-superfluous-settings "${key}"
@@ -1343,10 +1350,7 @@ zone_config_settings_write() {
        local hook="${2}"
        local id=${3}
 
-       if ! isset id; then
-               id=$(zone_config_get_new_id ${zone})
-               log DEBUG "ID for the config is: ${id}"
-       fi
+       assert isset id
 
        local args
        if function_exists "hook_check_config_settings"; then
index 141d52b3c233371fa90d686d2e70912007b3dba5..4458eaa94862472c93d512520f95194a2733b1da 100644 (file)
@@ -23,8 +23,12 @@ hook_new() {
        local zone="${1}"
        shift
 
+       local id=$(zone_config_get_new_id ${zone})
+       log DEBUG "ID for the config is: ${id}"
+
        # Parse command line arguments
-       if ! hook_parse_cmdline "$@"; then
+       if ! hook_parse_cmdline "${id}" "$@"; then
+               # Return an error if the parsing of the cmd line fails
                return ${EXIT_ERROR}
        fi
 
@@ -68,7 +72,7 @@ hook_edit() {
                return ${EXIT_ERROR}
        fi
 
-       if ! hook_parse_cmdline "$@"; then
+       if ! hook_parse_cmdline "${id}" "$@"; then
                # Return an error if the parsing of the cmd line fails
                return ${EXIT_ERROR}
        fi
index f22507c651a83fe6665c26fdee22829779faf22e..b643022a7442926eac67e3ede9fa5828b318e57b 100644 (file)
@@ -35,6 +35,9 @@ hook_check_config_settings() {
 }
 
 hook_parse_cmdline() {
+       local id="${1}"
+       shift
+
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --enable-ipv6)
@@ -72,12 +75,15 @@ hook_new() {
                return ${EXIT_ERROR}
        fi
 
-       if ! hook_parse_cmdline "$@"; then
+       local id=$(zone_config_get_new_id ${zone})
+       log DEBUG "ID for the config is: ${id}"
+
+       if ! hook_parse_cmdline "${id}" "$@"; then
                # Return an error if the parsing of the cmd line fails
                return ${EXIT_ERROR}
        fi
 
-       zone_config_settings_write "${zone}" "${HOOK}"
+       zone_config_settings_write "${zone}" "${HOOK}" "${id}"
 
        exit ${EXIT_OK}
 }
index bf1003d1988ce3e150ed1684efba932d046ecf77..8796723ecb65b22098fec07bef97baf435311e73 100644 (file)
@@ -31,6 +31,9 @@ hook_check_config_settings() {
 }
 
 hook_parse_cmdline() {
+       local id="${1}"
+       shift
+
        local arg
 
        while read arg; do
@@ -57,12 +60,15 @@ hook_new() {
                return ${EXIT_ERROR}
        fi
 
-       if ! hook_parse_cmdline "$@"; then
+       local id=$(zone_config_get_new_id ${zone})
+       log DEBUG "ID for the config is: ${id}"
+
+       if ! hook_parse_cmdline "${id}" "$@"; then
                # Return an error if the parsing of the cmd line fails
                return ${EXIT_ERROR}
        fi
 
-       zone_config_settings_write "${zone}" "${HOOK}"
+       zone_config_settings_write "${zone}" "${HOOK}" "${id}"
 
        exit ${EXIT_OK}
 }
index 7021be2a973c60440a592a5e31dc573a5d173856..6a2c014c21935a0353e99103a7c5289fd2bf6db6 100644 (file)
@@ -49,6 +49,9 @@ hook_check_config_settings() {
 }
 
 hook_parse_cmdline() {
+       local id="${1}"
+       shift
+
        while [ $# -gt 0 ]; do
                case "${1}" in
                        --dns-server=*)
@@ -105,12 +108,15 @@ hook_new() {
                return ${EXIT_ERROR}
        fi
 
-       if ! hook_parse_cmdline "$@"; then
+       local id=$(zone_config_get_new_id ${zone})
+       log DEBUG "ID for the config is: ${id}"
+
+       if ! hook_parse_cmdline "${id}" "$@"; then
                # Return an error if the parsing of the cmd line fails
                return ${EXIT_ERROR}
        fi
 
-       zone_config_settings_write "${zone}" "${HOOK}"
+       zone_config_settings_write "${zone}" "${HOOK}" "${id}"
 
        exit ${EXIT_OK}
 }