|
|
ab08bb |
From 7450d63abf0608efba8d48858e54ff23f2179300 Mon Sep 17 00:00:00 2001
|
|
|
ab08bb |
From: Phil Sutter <psutter@redhat.com>
|
|
|
ab08bb |
Date: Fri, 11 May 2018 15:29:24 +0200
|
|
|
ab08bb |
Subject: [PATCH] iptables-restore/save: exit when given an unknown option
|
|
|
ab08bb |
|
|
|
ab08bb |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1465078
|
|
|
ab08bb |
Upstream Status: iptables commit d89dc47ab3875
|
|
|
ab08bb |
Conflicts:
|
|
|
ab08bb |
* Context changes in ip{6,}tables-restore.c
|
|
|
ab08bb |
* xtables-{save,restore}.c not present here.
|
|
|
ab08bb |
|
|
|
ab08bb |
commit d89dc47ab3875f6fe6679cebceccd2000bf81b8e
|
|
|
ab08bb |
Author: Vincent Bernat <vincent@bernat.im>
|
|
|
ab08bb |
Date: Sat Apr 15 12:16:47 2017 +0200
|
|
|
ab08bb |
|
|
|
ab08bb |
iptables-restore/save: exit when given an unknown option
|
|
|
ab08bb |
|
|
|
ab08bb |
When an unknown option is given, iptables-restore should exit instead of
|
|
|
ab08bb |
continue its operation. For example, if `--table` was misspelled, this
|
|
|
ab08bb |
could lead to an unwanted change. Moreover, exit with a status code of
|
|
|
ab08bb |
1. Make the same change for iptables-save.
|
|
|
ab08bb |
|
|
|
ab08bb |
OTOH, exit with a status code of 0 when requesting help.
|
|
|
ab08bb |
|
|
|
ab08bb |
Signed-off-by: Vincent Bernat <vincent@bernat.im>
|
|
|
ab08bb |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
ab08bb |
|
|
|
ab08bb |
Signed-off-by: Phil Sutter <psutter@redhat.com>
|
|
|
ab08bb |
---
|
|
|
ab08bb |
iptables/ip6tables-restore.c | 10 +++++-----
|
|
|
ab08bb |
iptables/ip6tables-save.c | 4 ++++
|
|
|
ab08bb |
iptables/iptables-restore.c | 10 +++++-----
|
|
|
ab08bb |
iptables/iptables-save.c | 4 ++++
|
|
|
ab08bb |
4 files changed, 18 insertions(+), 10 deletions(-)
|
|
|
ab08bb |
|
|
|
ab08bb |
diff --git a/iptables/ip6tables-restore.c b/iptables/ip6tables-restore.c
|
|
|
ab08bb |
index 0b8b95607febf..0f85fee3593d5 100644
|
|
|
ab08bb |
--- a/iptables/ip6tables-restore.c
|
|
|
ab08bb |
+++ b/iptables/ip6tables-restore.c
|
|
|
ab08bb |
@@ -48,8 +48,6 @@ static const struct option options[] = {
|
|
|
ab08bb |
{NULL},
|
|
|
ab08bb |
};
|
|
|
ab08bb |
|
|
|
ab08bb |
-static void print_usage(const char *name, const char *version) __attribute__((noreturn));
|
|
|
ab08bb |
-
|
|
|
ab08bb |
#define prog_name ip6tables_globals.program_name
|
|
|
ab08bb |
#define prog_vers ip6tables_globals.program_version
|
|
|
ab08bb |
|
|
|
ab08bb |
@@ -66,8 +64,6 @@ static void print_usage(const char *name, const char *version)
|
|
|
ab08bb |
" [ --wait-interval=<usecs>\n"
|
|
|
ab08bb |
" [ --noflush ]\n"
|
|
|
ab08bb |
" [ --modprobe=<command>]\n", name);
|
|
|
ab08bb |
-
|
|
|
ab08bb |
- exit(1);
|
|
|
ab08bb |
}
|
|
|
ab08bb |
|
|
|
ab08bb |
static struct xtc_handle *create_handle(const char *tablename)
|
|
|
ab08bb |
@@ -238,7 +234,7 @@ int ip6tables_restore_main(int argc, char *argv[])
|
|
|
ab08bb |
case 'h':
|
|
|
ab08bb |
print_usage("ip6tables-restore",
|
|
|
ab08bb |
IPTABLES_VERSION);
|
|
|
ab08bb |
- break;
|
|
|
ab08bb |
+ exit(0);
|
|
|
ab08bb |
case 'n':
|
|
|
ab08bb |
noflush = 1;
|
|
|
ab08bb |
break;
|
|
|
ab08bb |
@@ -254,6 +250,10 @@ int ip6tables_restore_main(int argc, char *argv[])
|
|
|
ab08bb |
case 'T':
|
|
|
ab08bb |
tablename = optarg;
|
|
|
ab08bb |
break;
|
|
|
ab08bb |
+ default:
|
|
|
ab08bb |
+ fprintf(stderr,
|
|
|
ab08bb |
+ "Try `ip6tables-restore -h' for more information.\n");
|
|
|
ab08bb |
+ exit(1);
|
|
|
ab08bb |
}
|
|
|
ab08bb |
}
|
|
|
ab08bb |
|
|
|
ab08bb |
diff --git a/iptables/ip6tables-save.c b/iptables/ip6tables-save.c
|
|
|
ab08bb |
index 3a1ded162fad1..a64d169fc1211 100644
|
|
|
ab08bb |
--- a/iptables/ip6tables-save.c
|
|
|
ab08bb |
+++ b/iptables/ip6tables-save.c
|
|
|
ab08bb |
@@ -157,6 +157,10 @@ int ip6tables_save_main(int argc, char *argv[])
|
|
|
ab08bb |
case 'd':
|
|
|
ab08bb |
do_output(tablename);
|
|
|
ab08bb |
exit(0);
|
|
|
ab08bb |
+ default:
|
|
|
ab08bb |
+ fprintf(stderr,
|
|
|
ab08bb |
+ "Look at manual page `ip6tables-save.8' for more information.\n");
|
|
|
ab08bb |
+ exit(1);
|
|
|
ab08bb |
}
|
|
|
ab08bb |
}
|
|
|
ab08bb |
|
|
|
ab08bb |
diff --git a/iptables/iptables-restore.c b/iptables/iptables-restore.c
|
|
|
ab08bb |
index 7aab1e78d7e0e..6d0df8d1c0f36 100644
|
|
|
ab08bb |
--- a/iptables/iptables-restore.c
|
|
|
ab08bb |
+++ b/iptables/iptables-restore.c
|
|
|
ab08bb |
@@ -45,8 +45,6 @@ static const struct option options[] = {
|
|
|
ab08bb |
{NULL},
|
|
|
ab08bb |
};
|
|
|
ab08bb |
|
|
|
ab08bb |
-static void print_usage(const char *name, const char *version) __attribute__((noreturn));
|
|
|
ab08bb |
-
|
|
|
ab08bb |
#define prog_name iptables_globals.program_name
|
|
|
ab08bb |
#define prog_vers iptables_globals.program_version
|
|
|
ab08bb |
|
|
|
ab08bb |
@@ -64,8 +62,6 @@ static void print_usage(const char *name, const char *version)
|
|
|
ab08bb |
" [ --wait-interval=<usecs>\n"
|
|
|
ab08bb |
" [ --table= ]\n"
|
|
|
ab08bb |
" [ --modprobe=<command>]\n", name);
|
|
|
ab08bb |
-
|
|
|
ab08bb |
- exit(1);
|
|
|
ab08bb |
}
|
|
|
ab08bb |
|
|
|
ab08bb |
static struct xtc_handle *create_handle(const char *tablename)
|
|
|
ab08bb |
@@ -237,7 +233,7 @@ iptables_restore_main(int argc, char *argv[])
|
|
|
ab08bb |
case 'h':
|
|
|
ab08bb |
print_usage("iptables-restore",
|
|
|
ab08bb |
IPTABLES_VERSION);
|
|
|
ab08bb |
- break;
|
|
|
ab08bb |
+ exit(0);
|
|
|
ab08bb |
case 'n':
|
|
|
ab08bb |
noflush = 1;
|
|
|
ab08bb |
break;
|
|
|
ab08bb |
@@ -253,6 +249,10 @@ iptables_restore_main(int argc, char *argv[])
|
|
|
ab08bb |
case 'T':
|
|
|
ab08bb |
tablename = optarg;
|
|
|
ab08bb |
break;
|
|
|
ab08bb |
+ default:
|
|
|
ab08bb |
+ fprintf(stderr,
|
|
|
ab08bb |
+ "Try `iptables-restore -h' for more information.\n");
|
|
|
ab08bb |
+ exit(1);
|
|
|
ab08bb |
}
|
|
|
ab08bb |
}
|
|
|
ab08bb |
|
|
|
ab08bb |
diff --git a/iptables/iptables-save.c b/iptables/iptables-save.c
|
|
|
ab08bb |
index 21f8839e8cd82..87bc885735dc3 100644
|
|
|
ab08bb |
--- a/iptables/iptables-save.c
|
|
|
ab08bb |
+++ b/iptables/iptables-save.c
|
|
|
ab08bb |
@@ -156,6 +156,10 @@ iptables_save_main(int argc, char *argv[])
|
|
|
ab08bb |
case 'd':
|
|
|
ab08bb |
do_output(tablename);
|
|
|
ab08bb |
exit(0);
|
|
|
ab08bb |
+ default:
|
|
|
ab08bb |
+ fprintf(stderr,
|
|
|
ab08bb |
+ "Look at manual page `iptables-save.8' for more information.\n");
|
|
|
ab08bb |
+ exit(1);
|
|
|
ab08bb |
}
|
|
|
ab08bb |
}
|
|
|
ab08bb |
|
|
|
ab08bb |
--
|
|
|
ab08bb |
2.17.0
|
|
|
ab08bb |
|