The dots at the end of log messages can be confusing. Especially behind variables,it is often unclear if the dot was part of the variable or not which make debugging much harder.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/functions/functions.settings b/src/functions/functions.settings index 0e50bf1..9efbe8e 100644 --- a/src/functions/functions.settings +++ b/src/functions/functions.settings @@ -159,7 +159,7 @@ settings_write() { return ${EXIT_ERROR} fi
- log DEBUG "Writing settings file ${settings_file}." + log DEBUG "Writing settings file '${settings_file}'."
mkdir -p $(dirname ${settings_file}) 2>/dev/null > ${settings_file}
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/inetcalc.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/src/inetcalc.c b/src/inetcalc.c index d08f0f3..da3444e 100644 --- a/src/inetcalc.c +++ b/src/inetcalc.c @@ -245,7 +245,10 @@ static void ip_address_print(const ip_address_t* ip) { if (r) return;
- if (ip->prefix >= 0) { + int address_prefix = default_prefix(ip->family); + + // Only print prefix when it is not the default one + if (ip->prefix != address_prefix) { size_t len = strlen(buffer); snprintf(buffer + len, sizeof(buffer) - len, "/%d", ip->prefix); }
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/functions/functions.zone | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/src/functions/functions.zone b/src/functions/functions.zone index 058110d..f2c5ddc 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -1008,6 +1008,28 @@ zone_config_get_hook() { print "${HOOK}" }
+zone_config_hook_is_configured() { + # Checks if a zone has already at least one config with the given hook. + # Returns True when yes and False when no + + assert [ $# -eq 2 ] + local zone=${1} + local hook=${2} + + local config + for config in $(zone_configs_list "${zone}"); do + local config_hook="$(zone_config_get_hook "${zone}" "${config}")" + assert isset config_hook + if [[ ${hook} == ${config_hook} ]]; then + return ${EXIT_TRUE} + fi + + done + + # If we get here the zone has no config with the given hook + return ${EXIT_FALSE} +} + zone_has_ip() { device_has_ip $@ }
Perfect coding style here! :)
On Tue, 2017-07-04 at 17:46 +0200, Jonatan Schlag wrote:
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/functions/functions.zone | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+)
diff --git a/src/functions/functions.zone b/src/functions/functions.zone index 058110d..f2c5ddc 100644 --- a/src/functions/functions.zone +++ b/src/functions/functions.zone @@ -1008,6 +1008,28 @@ zone_config_get_hook() { print "${HOOK}" } +zone_config_hook_is_configured() {
- # Checks if a zone has already at least one config with the
given hook.
- # Returns True when yes and False when no
- assert [ $# -eq 2 ]
- local zone=${1}
- local hook=${2}
- local config
- for config in $(zone_configs_list "${zone}"); do
local config_hook="$(zone_config_get_hook "${zone}"
"${config}")"
assert isset config_hook
if [[ ${hook} == ${config_hook} ]]; then
return ${EXIT_TRUE}
fi
- done
- # If we get here the zone has no config with the given hook
- return ${EXIT_FALSE}
+}
zone_has_ip() { device_has_ip $@ }
It is senseless to configure the ipv4-dhcp hook multiple times for a zone.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/hooks/configs/ipv4-dhcp | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/hooks/configs/ipv4-dhcp b/src/hooks/configs/ipv4-dhcp index ef23082..39e0312 100644 --- a/src/hooks/configs/ipv4-dhcp +++ b/src/hooks/configs/ipv4-dhcp @@ -35,6 +35,11 @@ hook_new() { local zone="${1}" shift
+ if zone_config_hook_is_configured ${zone} "ipv4-dhcp"; then + log ERROR "You can configure the ipv4-dhcp hook only once for a zone" + return ${EXIT_ERROR} + fi + while [ $# -gt 0 ]; do case "${1}" in --delay=*)
It is senseless to configure the ipv6-dhcp hook multiple times for a zone.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/hooks/configs/ipv6-dhcp | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/hooks/configs/ipv6-dhcp b/src/hooks/configs/ipv6-dhcp index 03dbbf0..74ec765 100644 --- a/src/hooks/configs/ipv6-dhcp +++ b/src/hooks/configs/ipv6-dhcp @@ -27,6 +27,11 @@ hook_new() { local zone="${1}" shift
+ if zone_config_hook_is_configured ${zone} "ipv6-dhcp"; then + log ERROR "You can configure the ipv6-dhcp hook only once for a zone" + return ${EXIT_ERROR} + fi + zone_config_settings_write "${zone}" "${HOOK}"
exit ${EXIT_OK}
It is senseless to configure the ipv6-auto hook multiple times for a zone.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/hooks/configs/ipv6-auto | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/hooks/configs/ipv6-auto b/src/hooks/configs/ipv6-auto index 44cef48..c362797 100644 --- a/src/hooks/configs/ipv6-auto +++ b/src/hooks/configs/ipv6-auto @@ -34,6 +34,11 @@ hook_new() { local zone="${1}" shift
+ if zone_config_hook_is_configured ${zone} "ipv6-auto"; then + log ERROR "You can configure the ipv6-auto hook only once for a zone" + return ${EXIT_ERROR} + fi + while read arg; do case "${arg}" in --privacy-extensions=*)
It is senseless to configure the ppoe-server hook multiple times for a zone.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org --- src/hooks/configs/pppoe-server | 5 +++++ 1 file changed, 5 insertions(+)
diff --git a/src/hooks/configs/pppoe-server b/src/hooks/configs/pppoe-server index 6f95212..22e0906 100644 --- a/src/hooks/configs/pppoe-server +++ b/src/hooks/configs/pppoe-server @@ -52,6 +52,11 @@ hook_new() { local zone=${1} shift
+ if zone_config_hook_is_configured ${zone} "pppoe-server"; then + log ERROR "You can configure the pppoe-server hook only once for a zone" + return ${EXIT_ERROR} + fi + while [ $# -gt 0 ]; do case "${1}" in --dns-server=*)
Hi,
this commit message says that you removed the dot, but it is still there...
-Michael
On Tue, 2017-07-04 at 17:46 +0200, Jonatan Schlag wrote:
The dots at the end of log messages can be confusing. Especially behind variables,it is often unclear if the dot was part of the variable or not which make debugging much harder.
Signed-off-by: Jonatan Schlag jonatan.schlag@ipfire.org
src/functions/functions.settings | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/functions/functions.settings b/src/functions/functions.settings index 0e50bf1..9efbe8e 100644 --- a/src/functions/functions.settings +++ b/src/functions/functions.settings @@ -159,7 +159,7 @@ settings_write() { return ${EXIT_ERROR} fi
- log DEBUG "Writing settings file ${settings_file}."
- log DEBUG "Writing settings file '${settings_file}'."
mkdir -p $(dirname ${settings_file}) 2>/dev/null > ${settings_file}