From: Shreenidhi Shedi <yesshedi@gmail.com>
To: gregkh@linuxfoundation.org, dhowells@redhat.com, dwmw2@infradead.org
Cc: yesshedi@gmail.com, linux-kernel@vger.kernel.org, sshedi@vmware.com
Subject: [PATCH v5 5/7] sign-file: improve help message
Date: Tue, 21 Mar 2023 00:13:43 +0530 [thread overview]
Message-ID: <20230320184345.80166-6-sshedi@vmware.com> (raw)
In-Reply-To: <20230320184345.80166-1-sshedi@vmware.com>
From: Shreenidhi Shedi <yesshedi@gmail.com>
Add a proper help message with examples on how to use this tool.
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---
scripts/sign-file.c | 48 ++++++++++++++++++++++++++++++++++++++-------
1 file changed, 41 insertions(+), 7 deletions(-)
diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index 0a275256ca16..d3abc5721a7e 100644
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -74,12 +74,43 @@ struct module_signature {
static char magic_number[] = "~Module signature appended~\n";
static __attribute__((noreturn))
-void format(void)
+void print_usage(void)
{
- 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");
+ fprintf(stderr, "Usage: scripts/sign-file [OPTIONS]... [MODULE]...\n");
+ fprintf(stderr, "Available options:\n");
+ fprintf(stderr, "-h, --help Print this help message and exit\n");
+
+ fprintf(stderr, "\nOptional args:\n");
+ fprintf(stderr, "-s, --rawsig <sig> Raw signature\n");
+ fprintf(stderr, "-p, --savesig Save signature\n");
+ fprintf(stderr, "-d, --signonly Sign only\n");
+#ifndef USE_PKCS7
+ fprintf(stderr, "-k, --usekeyid Use key ID\n");
+#endif
+ fprintf(stderr, "-b, --bulksign Sign modules in bulk\n");
+ fprintf(stderr, "-r, --replaceorig Replace original\n");
+ fprintf(stderr, "-t, --dest <dest> Destination path ");
+ fprintf(stderr, "(Exclusive with bulk option)\n");
+
+ fprintf(stderr, "\nMandatory args:\n");
+ fprintf(stderr, "-i, --privkey <key> Private key\n");
+ fprintf(stderr, "-a, --hashalgo <alg> Hash algorithm\n");
+ fprintf(stderr, "-x, --x509 <x509> X509\n");
+
+ fprintf(stderr, "\nExamples:\n");
+
+ fprintf(stderr, "\n Regular signing:\n");
+ fprintf(stderr, " scripts/sign-file -a sha512 -i certs/signing_key.pem ");
+ fprintf(stderr, "-x certs/signing_key.x509 <module>\n");
+
+ fprintf(stderr, "\n Signing with destination path:\n");
+ fprintf(stderr, " scripts/sign-file -a sha512 -i certs/signing_key.pem ");
+ fprintf(stderr, "-x certs/signing_key.x509 <module> -t <path>\n");
+
+ fprintf(stderr, "\n Signing modules in bulk:\n");
+ fprintf(stderr, " scripts/sign-file -a sha512 -i certs/signing_key.pem ");
+ fprintf(stderr, "-x certs/signing_key.x509 -b <module1> <module2> ...\n");
+
exit(2);
}
@@ -281,7 +312,7 @@ static void parse_args(int argc, char **argv, struct cmd_opts *opts)
#endif
case 'h':
- format();
+ print_usage();
break;
case 'i':
@@ -312,7 +343,7 @@ static void parse_args(int argc, char **argv, struct cmd_opts *opts)
break;
default:
- format();
+ print_usage();
break;
}
} while (opt != -1);
@@ -472,6 +503,9 @@ int main(int argc, char **argv)
argc -= optind;
argv += optind;
+ if ((opts.bulk_sign && opts.dest_name) || (!opts.bulk_sign && argc != 1))
+ print_usage();
+
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
ERR_clear_error();
--
2.39.2
next prev parent reply other threads:[~2023-03-20 18:51 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-20 18:43 [PATCH v5 0/7] refactor file signing program Shreenidhi Shedi
2023-03-20 18:43 ` [PATCH v5 1/7] sign-file: refactor argument parsing logic - 1 Shreenidhi Shedi
2023-03-20 18:43 ` [PATCH v5 2/7] sign-file: refactor argument parsing logic - 2 Shreenidhi Shedi
2023-03-20 18:43 ` [PATCH v5 3/7] sign-file: refactor argument parsing logic - 3 Shreenidhi Shedi
2023-03-20 18:43 ` [PATCH v5 4/7] sign-file: add support to sign modules in bulk Shreenidhi Shedi
2023-03-20 18:43 ` Shreenidhi Shedi [this message]
2023-03-20 18:43 ` [PATCH v5 6/7] sign-file: use const with a global string constant Shreenidhi Shedi
2023-03-20 18:43 ` [PATCH v5 7/7] sign-file: fix do while styling issue Shreenidhi Shedi
2023-03-20 18:49 ` [PATCH v5 0/7] refactor file signing program Shreenidhi Shedi
2023-03-21 7:00 ` Greg KH
2023-03-21 7:04 ` [PATCH v5 1/7] sign-file: refactor argument parsing logic - 1 David Howells
2023-03-21 19:50 ` Shreenidhi Shedi
-- strict thread matches above, loose matches on Subject: below --
2023-03-20 17:57 Shreenidhi Shedi
2023-03-20 17:57 ` [PATCH v5 5/7] sign-file: improve help message Shreenidhi Shedi
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=20230320184345.80166-6-sshedi@vmware.com \
--to=yesshedi@gmail.com \
--cc=dhowells@redhat.com \
--cc=dwmw2@infradead.org \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=sshedi@vmware.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).