]> git.ipfire.org Git - thirdparty/iptables.git/commitdiff
xtables: Accept --wait in iptables-nft-restore
authorPhil Sutter <phil@nwl.cc>
Wed, 5 Sep 2018 17:14:40 +0000 (19:14 +0200)
committerFlorian Westphal <fw@strlen.de>
Mon, 10 Sep 2018 13:27:33 +0000 (15:27 +0200)
Passing --wait option to iptables-nft-restore led to program abort
because the flag parameter was not skipped. Mimick iptables-restore
behaviour when encountering --wait or --wait-interval options (but still
ignore the parameter).

Fixes: b9d7b49d84bc2 ("xtables-compat: restore: sync options with iptables-restore")
Signed-off-by: Phil Sutter <phil@nwl.cc>
Signed-off-by: Florian Westphal <fw@strlen.de>
iptables/tests/shell/testcases/ipt-restore/0002-parameters_0 [new file with mode: 0755]
iptables/xtables-restore.c

diff --git a/iptables/tests/shell/testcases/ipt-restore/0002-parameters_0 b/iptables/tests/shell/testcases/ipt-restore/0002-parameters_0
new file mode 100755 (executable)
index 0000000..5c8748e
--- /dev/null
@@ -0,0 +1,21 @@
+#!/bin/sh
+
+set -e
+
+# make sure wait and wait-interval options are accepted
+
+clean_tempfile()
+{
+       if [ -n "${tmpfile}" ]; then
+               rm -f "${tmpfile}"
+       fi
+}
+
+trap clean_tempfile EXIT
+
+tmpfile=$(mktemp) || exit 1
+
+$XT_MULTI iptables-save -f $tmpfile
+$XT_MULTI iptables-restore $tmpfile
+$XT_MULTI iptables-restore -w 5 $tmpfile
+$XT_MULTI iptables-restore -w 5 -W 1 $tmpfile
index d187b129f35da921a3d4de0f037605ee85dd5fa4..9d15593f95eedb54dc1c2a54eb16a86ef66781b7 100644 (file)
@@ -419,6 +419,8 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
                                break;
                        case 'w': /* fallthrough.  Ignored by xt-restore */
                        case 'W':
+                               if (!optarg && xs_has_arg(argc, argv))
+                                       optind++;
                                break;
                        default:
                                fprintf(stderr,