Blame SOURCES/iptables-1.4.21-restore_version.patch

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