|
|
9c64ad |
Adapted version of
|
|
|
9c64ad |
|
|
|
9c64ad |
commit 9cd3adbed2fd8cdb6366293f3799573b811be89b
|
|
|
9c64ad |
Author: Dan Williams <dcbw@redhat.com>
|
|
|
9c64ad |
Date: Mon Apr 10 12:31:56 2017 -0500
|
|
|
9c64ad |
|
|
|
9c64ad |
iptables-restore/ip6tables-restore: add --version/-V argument
|
|
|
9c64ad |
|
|
|
9c64ad |
Prints program version just like iptables/ip6tables.
|
|
|
9c64ad |
|
|
|
9c64ad |
Signed-off-by: Dan Williams <dcbw@redhat.com>
|
|
|
9c64ad |
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
|
|
|
9c64ad |
|
|
|
9c64ad |
diff -up iptables-1.4.21/iptables/ip6tables-restore.c.restore_version iptables-1.4.21/iptables/ip6tables-restore.c
|
|
|
9c64ad |
--- iptables-1.4.21/iptables/ip6tables-restore.c.restore_version 2017-04-20 16:49:34.253130005 +0200
|
|
|
9c64ad |
+++ iptables-1.4.21/iptables/ip6tables-restore.c 2017-04-20 16:51:43.931089903 +0200
|
|
|
9c64ad |
@@ -37,6 +37,7 @@ static const struct option options[] = {
|
|
|
9c64ad |
{.name = "binary", .has_arg = 0, .val = 'b'},
|
|
|
9c64ad |
{.name = "counters", .has_arg = 0, .val = 'c'},
|
|
|
9c64ad |
{.name = "verbose", .has_arg = 0, .val = 'v'},
|
|
|
9c64ad |
+ {.name = "version", .has_arg = 0, .val = 'V'},
|
|
|
9c64ad |
{.name = "test", .has_arg = 0, .val = 't'},
|
|
|
9c64ad |
{.name = "help", .has_arg = 0, .val = 'h'},
|
|
|
9c64ad |
{.name = "noflush", .has_arg = 0, .val = 'n'},
|
|
|
9c64ad |
@@ -49,12 +50,16 @@ static const struct option options[] = {
|
|
|
9c64ad |
|
|
|
9c64ad |
static void print_usage(const char *name, const char *version) __attribute__((noreturn));
|
|
|
9c64ad |
|
|
|
9c64ad |
+#define prog_name ip6tables_globals.program_name
|
|
|
9c64ad |
+#define prog_vers ip6tables_globals.program_version
|
|
|
9c64ad |
+
|
|
|
9c64ad |
static void print_usage(const char *name, const char *version)
|
|
|
9c64ad |
{
|
|
|
9c64ad |
- fprintf(stderr, "Usage: %s [-b] [-c] [-v] [-t] [-h] [-w secs] [-W usecs]\n"
|
|
|
9c64ad |
+ fprintf(stderr, "Usage: %s [-b] [-c] [-v] [-V] [-t] [-h] [-w secs] [-W usecs]\n"
|
|
|
9c64ad |
" [ --binary ]\n"
|
|
|
9c64ad |
" [ --counters ]\n"
|
|
|
9c64ad |
" [ --verbose ]\n"
|
|
|
9c64ad |
+ " [ --version]\n"
|
|
|
9c64ad |
" [ --test ]\n"
|
|
|
9c64ad |
" [ --help ]\n"
|
|
|
9c64ad |
" [ --wait=<seconds>\n"
|
|
|
9c64ad |
@@ -79,8 +84,7 @@ static struct xtc_handle *create_handle(
|
|
|
9c64ad |
|
|
|
9c64ad |
if (!handle) {
|
|
|
9c64ad |
xtables_error(PARAMETER_PROBLEM, "%s: unable to initialize "
|
|
|
9c64ad |
- "table '%s'\n", ip6tables_globals.program_name,
|
|
|
9c64ad |
- tablename);
|
|
|
9c64ad |
+ "table '%s'\n", prog_name, tablename);
|
|
|
9c64ad |
exit(1);
|
|
|
9c64ad |
}
|
|
|
9c64ad |
return handle;
|
|
|
9c64ad |
@@ -214,7 +218,7 @@ int ip6tables_restore_main(int argc, cha
|
|
|
9c64ad |
init_extensions6();
|
|
|
9c64ad |
#endif
|
|
|
9c64ad |
|
|
|
9c64ad |
- while ((c = getopt_long(argc, argv, "bcvthnwWM:T:", options, NULL)) != -1) {
|
|
|
9c64ad |
+ while ((c = getopt_long(argc, argv, "bcvVthnwWM:T:", options, NULL)) != -1) {
|
|
|
9c64ad |
switch (c) {
|
|
|
9c64ad |
case 'b':
|
|
|
9c64ad |
binary = 1;
|
|
|
9c64ad |
@@ -225,6 +229,9 @@ int ip6tables_restore_main(int argc, cha
|
|
|
9c64ad |
case 'v':
|
|
|
9c64ad |
verbose = 1;
|
|
|
9c64ad |
break;
|
|
|
9c64ad |
+ case 'V':
|
|
|
9c64ad |
+ printf("%s v%s\n", prog_name, prog_vers);
|
|
|
9c64ad |
+ exit(0);
|
|
|
9c64ad |
case 't':
|
|
|
9c64ad |
testing = 1;
|
|
|
9c64ad |
break;
|
|
|
9c64ad |
diff -up iptables-1.4.21/iptables/iptables-restore.8.in.restore_version iptables-1.4.21/iptables/iptables-restore.8.in
|
|
|
9c64ad |
--- iptables-1.4.21/iptables/iptables-restore.8.in.restore_version 2013-11-22 12:18:13.000000000 +0100
|
|
|
9c64ad |
+++ iptables-1.4.21/iptables/iptables-restore.8.in 2017-04-20 16:52:20.883299806 +0200
|
|
|
9c64ad |
@@ -23,9 +23,9 @@ iptables-restore \(em Restore IP Tables
|
|
|
9c64ad |
.P
|
|
|
9c64ad |
ip6tables-restore \(em Restore IPv6 Tables
|
|
|
9c64ad |
.SH SYNOPSIS
|
|
|
9c64ad |
-\fBiptables\-restore\fP [\fB\-chntv\fP] [\fB\-M\fP \fImodprobe\fP]
|
|
|
9c64ad |
+\fBiptables\-restore\fP [\fB\-chntvV\fP] [\fB\-M\fP \fImodprobe\fP]
|
|
|
9c64ad |
.P
|
|
|
9c64ad |
-\fBip6tables\-restore\fP [\fB\-chntv\fP] [\fB\-M\fP \fImodprobe\fP]
|
|
|
9c64ad |
+\fBip6tables\-restore\fP [\fB\-chntvV\fP] [\fB\-M\fP \fImodprobe\fP]
|
|
|
9c64ad |
[\fB\-T\fP \fIname\fP]
|
|
|
9c64ad |
.SH DESCRIPTION
|
|
|
9c64ad |
.PP
|
|
|
9c64ad |
@@ -51,6 +51,9 @@ Only parse and construct the ruleset, bu
|
|
|
9c64ad |
\fB\-v\fP, \fB\-\-verbose\fP
|
|
|
9c64ad |
Print additional debug info during ruleset processing.
|
|
|
9c64ad |
.TP
|
|
|
9c64ad |
+\fB\-V\fP, \fB\-\-version\fP
|
|
|
9c64ad |
+Print the program version number.
|
|
|
9c64ad |
+.TP
|
|
|
9c64ad |
\fB\-M\fP, \fB\-\-modprobe\fP \fImodprobe_program\fP
|
|
|
9c64ad |
Specify the path to the modprobe program. By default, iptables-restore will
|
|
|
9c64ad |
inspect /proc/sys/kernel/modprobe to determine the executable's path.
|
|
|
9c64ad |
diff -up iptables-1.4.21/iptables/iptables-restore.c.restore_version iptables-1.4.21/iptables/iptables-restore.c
|
|
|
9c64ad |
--- iptables-1.4.21/iptables/iptables-restore.c.restore_version 2017-04-20 16:49:34.253130005 +0200
|
|
|
9c64ad |
+++ iptables-1.4.21/iptables/iptables-restore.c 2017-04-20 17:29:32.495390523 +0200
|
|
|
9c64ad |
@@ -34,6 +34,7 @@ static const struct option options[] = {
|
|
|
9c64ad |
{.name = "binary", .has_arg = 0, .val = 'b'},
|
|
|
9c64ad |
{.name = "counters", .has_arg = 0, .val = 'c'},
|
|
|
9c64ad |
{.name = "verbose", .has_arg = 0, .val = 'v'},
|
|
|
9c64ad |
+ {.name = "version", .has_arg = 0, .val = 'V'},
|
|
|
9c64ad |
{.name = "test", .has_arg = 0, .val = 't'},
|
|
|
9c64ad |
{.name = "help", .has_arg = 0, .val = 'h'},
|
|
|
9c64ad |
{.name = "noflush", .has_arg = 0, .val = 'n'},
|
|
|
9c64ad |
@@ -47,13 +48,15 @@ static const struct option options[] = {
|
|
|
9c64ad |
static void print_usage(const char *name, const char *version) __attribute__((noreturn));
|
|
|
9c64ad |
|
|
|
9c64ad |
#define prog_name iptables_globals.program_name
|
|
|
9c64ad |
+#define prog_vers iptables_globals.program_version
|
|
|
9c64ad |
|
|
|
9c64ad |
static void print_usage(const char *name, const char *version)
|
|
|
9c64ad |
{
|
|
|
9c64ad |
- fprintf(stderr, "Usage: %s [-b] [-c] [-v] [-t] [-h] [-W usecs]\n"
|
|
|
9c64ad |
+ fprintf(stderr, "Usage: %s [-b] [-c] [-v] [-V] [-t] [-h] [-W usecs]\n"
|
|
|
9c64ad |
" [ --binary ]\n"
|
|
|
9c64ad |
" [ --counters ]\n"
|
|
|
9c64ad |
" [ --verbose ]\n"
|
|
|
9c64ad |
+ " [ --version]\n"
|
|
|
9c64ad |
" [ --test ]\n"
|
|
|
9c64ad |
" [ --help ]\n"
|
|
|
9c64ad |
" [ --noflush ]\n"
|
|
|
9c64ad |
@@ -214,7 +217,7 @@ iptables_restore_main(int argc, char *ar
|
|
|
9c64ad |
init_extensions4();
|
|
|
9c64ad |
#endif
|
|
|
9c64ad |
|
|
|
9c64ad |
- while ((c = getopt_long(argc, argv, "bcvthnwWM:T:", options, NULL)) != -1) {
|
|
|
9c64ad |
+ while ((c = getopt_long(argc, argv, "bcvVthnwWM:T:", options, NULL)) != -1) {
|
|
|
9c64ad |
switch (c) {
|
|
|
9c64ad |
case 'b':
|
|
|
9c64ad |
binary = 1;
|
|
|
9c64ad |
@@ -225,6 +228,9 @@ iptables_restore_main(int argc, char *ar
|
|
|
9c64ad |
case 'v':
|
|
|
9c64ad |
verbose = 1;
|
|
|
9c64ad |
break;
|
|
|
9c64ad |
+ case 'V':
|
|
|
9c64ad |
+ printf("%s v%s\n", prog_name, prog_vers);
|
|
|
9c64ad |
+ exit(0);
|
|
|
9c64ad |
case 't':
|
|
|
9c64ad |
testing = 1;
|
|
|
9c64ad |
break;
|