All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] sign-file: refactor help output
@ 2021-10-08 13:45 Matteo Croce
  0 siblings, 0 replies; only message in thread
From: Matteo Croce @ 2021-10-08 13:45 UTC (permalink / raw)
  To: David Howells, David Woodhouse, keyrings; +Cc: linux-kernel

From: Matteo Croce <mcroce@microsoft.com>

Tidy up the error output, and document the undocumented
flags -k and -s.

Signed-off-by: Matteo Croce <mcroce@microsoft.com>
---
 scripts/sign-file.c | 23 +++++++++++++++--------
 1 file changed, 15 insertions(+), 8 deletions(-)

diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index fbd34b8e8f57..fad6563b2127 100644
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -67,12 +67,19 @@ struct module_signature {
 static char magic_number[] = "~Module signature appended~\n";
 
 static __attribute__((noreturn))
-void format(void)
+void format(char *argv0)
 {
 	fprintf(stderr,
-		"Usage: scripts/sign-file [-dp] <hash algo> <key> <x509> <module> [<dest>]\n");
-	fprintf(stderr,
-		"       scripts/sign-file -s <raw sig> <hash algo> <x509> <module> [<dest>]\n");
+		"Usage:	%s [-dp] <hash algo> <key> <x509> <module> [<dest>]\n"
+		"	%s -s <raw sig> <hash algo> <x509> <module> [<dest>]\n"
+		"\n"
+		"	-d only generate signature (implies -p)\n"
+#ifndef USE_PKCS7
+		"	-k use subject key identifier\n"
+#endif
+		"	-p keep signature file\n"
+		"	-s use raw signature\n",
+		argv0, argv0);
 	exit(2);
 }
 
@@ -245,20 +252,20 @@ int main(int argc, char **argv)
 		opt = getopt(argc, argv, "sdpk");
 		switch (opt) {
 		case 's': raw_sig = true; break;
+		case 'd': sign_only = true;
 		case 'p': save_sig = true; break;
-		case 'd': sign_only = true; save_sig = true; break;
 #ifndef USE_PKCS7
 		case 'k': use_keyid = CMS_USE_KEYID; break;
 #endif
 		case -1: break;
-		default: format();
+		default: format(basename(argv[0]));
 		}
 	} while (opt != -1);
 
 	argc -= optind;
-	argv += optind;
 	if (argc < 4 || argc > 5)
-		format();
+		format(basename(argv[0]));
+	argv += optind;
 
 	if (raw_sig) {
 		raw_sig_name = argv[0];
-- 
2.33.0


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-08 13:45 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-08 13:45 [PATCH] sign-file: refactor help output Matteo Croce

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.