Blame SOURCES/0061-xtables-restore-Fix-program-names-in-help-texts.patch

1dc35b
From 4c351ba82a79b2781fc580f3f5473da0e5a276b8 Mon Sep 17 00:00:00 2001
1dc35b
From: Phil Sutter <phil@nwl.cc>
1dc35b
Date: Sat, 8 Jun 2019 19:34:13 +0200
1dc35b
Subject: [PATCH] xtables-restore: Fix program names in help texts
1dc35b
1dc35b
Avoid referring to wrong or even non-existent commands:
1dc35b
1dc35b
* When calling xtables_restore_main(), pass the actual program name
1dc35b
  taken from argv[0].
1dc35b
* Use 'prog_name' in unknown parameter and help output instead of
1dc35b
  'xtables-restore' which probably doesn't exist.
1dc35b
* While being at it, fix false whitespace in help text.
1dc35b
1dc35b
Signed-off-by: Phil Sutter <phil@nwl.cc>
1dc35b
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
1dc35b
(cherry picked from commit ac531b4681d1a0309a738d7bc3408fc2270eaa03)
1dc35b
1dc35b
Conflicts:
1dc35b
	iptables/xtables-restore.c
1dc35b
-> missing commit 093cec72e7f77 ("src: replace IPTABLES_VERSION by PACKAGE_VERSION")
1dc35b
1dc35b
Signed-off-by: Phil Sutter <psutter@redhat.com>
1dc35b
---
1dc35b
 iptables/xtables-restore.c | 13 +++++++------
1dc35b
 1 file changed, 7 insertions(+), 6 deletions(-)
1dc35b
1dc35b
diff --git a/iptables/xtables-restore.c b/iptables/xtables-restore.c
1dc35b
index 6e6daffc9a1df..7c2759a3c5932 100644
1dc35b
--- a/iptables/xtables-restore.c
1dc35b
+++ b/iptables/xtables-restore.c
1dc35b
@@ -7,6 +7,7 @@
1dc35b
 
1dc35b
 #include <getopt.h>
1dc35b
 #include <errno.h>
1dc35b
+#include <libgen.h>
1dc35b
 #include <stdbool.h>
1dc35b
 #include <string.h>
1dc35b
 #include <stdio.h>
1dc35b
@@ -51,7 +52,7 @@ static void print_usage(const char *name, const char *version)
1dc35b
 			"	   [ --help ]\n"
1dc35b
 			"	   [ --noflush ]\n"
1dc35b
 			"	   [ --table= ]\n"
1dc35b
-			"          [ --modprobe=<command> ]\n"
1dc35b
+			"	   [ --modprobe=<command> ]\n"
1dc35b
 			"	   [ --ipv4 ]\n"
1dc35b
 			"	   [ --ipv6 ]\n", name);
1dc35b
 }
1dc35b
@@ -376,8 +377,7 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
1dc35b
 				p.testing = 1;
1dc35b
 				break;
1dc35b
 			case 'h':
1dc35b
-				print_usage("xtables-restore",
1dc35b
-					    IPTABLES_VERSION);
1dc35b
+				print_usage(prog_name, IPTABLES_VERSION);
1dc35b
 				exit(0);
1dc35b
 			case 'n':
1dc35b
 				noflush = 1;
1dc35b
@@ -402,7 +402,8 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
1dc35b
 				break;
1dc35b
 			default:
1dc35b
 				fprintf(stderr,
1dc35b
-					"Try `xtables-restore -h' for more information.\n");
1dc35b
+					"Try `%s -h' for more information.\n",
1dc35b
+					prog_name);
1dc35b
 				exit(1);
1dc35b
 		}
1dc35b
 	}
1dc35b
@@ -458,13 +459,13 @@ xtables_restore_main(int family, const char *progname, int argc, char *argv[])
1dc35b
 
1dc35b
 int xtables_ip4_restore_main(int argc, char *argv[])
1dc35b
 {
1dc35b
-	return xtables_restore_main(NFPROTO_IPV4, "iptables-restore",
1dc35b
+	return xtables_restore_main(NFPROTO_IPV4, basename(*argv),
1dc35b
 				    argc, argv);
1dc35b
 }
1dc35b
 
1dc35b
 int xtables_ip6_restore_main(int argc, char *argv[])
1dc35b
 {
1dc35b
-	return xtables_restore_main(NFPROTO_IPV6, "ip6tables-restore",
1dc35b
+	return xtables_restore_main(NFPROTO_IPV6, basename(*argv),
1dc35b
 				    argc, argv);
1dc35b
 }
1dc35b
 
1dc35b
-- 
1dc35b
2.21.0
1dc35b