]> git.ipfire.org Git - people/stevee/network.git/commitdiff
Validate input for --offloading flag and throw an error when empty
authorMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Sep 2018 13:00:44 +0000 (15:00 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Fri, 21 Sep 2018 13:00:44 +0000 (15:00 +0200)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
src/functions/functions.util
src/hooks/ports/bonding
src/hooks/ports/ethernet

index a326d239225463c832bac1e2b9d8af55a6b326c0..8831d84b3953c0aca5918bbc3840e6e5f4861edd 100644 (file)
@@ -266,6 +266,12 @@ enabled() {
        list_match "${!param}" yes on true 1
 }
 
+disabled() {
+       local param="${1}"
+
+       list_match "${!param}" no off false 0
+}
+
 mac_generate() {
        local b="$(random 12)"
 
index 6248cc15d4adb895bf9d54feffbe91326680f2f8..1a6399e818ad1ad42e9031bcd632e581107e2ca3 100644 (file)
@@ -52,8 +52,11 @@ hook_parse_cmdline() {
 
                                if enabled OFFLOADING; then
                                        OFFLOADING="on"
-                               else
+                               elif disabled OFFLOADING; then
                                        OFFLOADING="off"
+                               else
+                                       error "Invalid value for offloading: ${OFFLOADING}"
+                                       return ${EXIT_ERROR}
                                fi
                                ;;
                        +*)
index b782e52fe2f8ff2cff11642be7e2ddab29a6a462..765d34db3e7cd5ded6408042b8921f17ff55aa9e 100644 (file)
@@ -83,8 +83,11 @@ hook_parse_cmdline() {
 
                                if enabled OFFLOADING; then
                                        OFFLOADING="on"
-                               else
+                               elif disabled OFFLOADING; then
                                        OFFLOADING="off"
+                               else
+                                       error "Invalid value for offloading: ${OFFLOADING}"
+                                       return ${EXIT_ERROR}
                                fi
                                ;;