All of lore.kernel.org
 help / color / mirror / Atom feed
From: Matteo Croce <mcroce@linux.microsoft.com>
To: David Howells <dhowells@redhat.com>,
	David Woodhouse <dwmw2@infradead.org>,
	keyrings@vger.kernel.org
Cc: linux-kernel@vger.kernel.org
Subject: [PATCH] sign-file: refactor help output
Date: Fri,  8 Oct 2021 15:45:47 +0200	[thread overview]
Message-ID: <20211008134547.32281-1-mcroce@linux.microsoft.com> (raw)

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


                 reply	other threads:[~2021-10-08 13:45 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211008134547.32281-1-mcroce@linux.microsoft.com \
    --to=mcroce@linux.microsoft.com \
    --cc=dhowells@redhat.com \
    --cc=dwmw2@infradead.org \
    --cc=keyrings@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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.