From: Shreenidhi Shedi <yesshedi@gmail.com>
To: gregkh@linuxfoundation.org, dhowells@redhat.com, dwmw2@infradead.org
Cc: linux-kernel@vger.kernel.org, sshedi@vmware.com, yesshedi@gmail.com
Subject: [PATCH v6 4/7] sign-file: add support to sign modules in bulk
Date: Wed, 22 Mar 2023 01:03:38 +0530 [thread overview]
Message-ID: <20230321193341.87997-5-sshedi@vmware.com> (raw)
In-Reply-To: <20230321193341.87997-1-sshedi@vmware.com>
From: Shreenidhi Shedi <yesshedi@gmail.com>
In the existing system, we need to invoke sign-file binary for every
module we want to sign. This patch adds support to give modules list
in bulk and it will sign them all one by one.
Signed-off-by: Shreenidhi Shedi <yesshedi@gmail.com>
---
scripts/sign-file.c | 41 +++++++++++++++++++++++++++--------------
1 file changed, 27 insertions(+), 14 deletions(-)
diff --git a/scripts/sign-file.c b/scripts/sign-file.c
index 64d5e00f08e2..0a275256ca16 100644
--- a/scripts/sign-file.c
+++ b/scripts/sign-file.c
@@ -224,6 +224,7 @@ struct cmd_opts {
bool replace_orig;
bool raw_sig;
bool sign_only;
+ bool bulk_sign;
#ifndef USE_PKCS7
unsigned int use_keyid;
#endif
@@ -252,10 +253,10 @@ static void parse_args(int argc, char **argv, struct cmd_opts *opts)
do {
#ifndef USE_PKCS7
- opt = getopt_long_only(argc, argv, "hpds:i:a:x:t:r:",
+ opt = getopt_long_only(argc, argv, "hpdbs:i:a:x:t:r:",
cmd_options, &opt_index);
#else
- opt = getopt_long_only(argc, argv, "hpdks:i:a:x:t:r:",
+ opt = getopt_long_only(argc, argv, "hpdkbs:i:a:x:t:r:",
cmd_options, &opt_index);
#endif
switch (opt) {
@@ -303,6 +304,10 @@ static void parse_args(int argc, char **argv, struct cmd_opts *opts)
opts->replace_orig = true;
break;
+ case 'b':
+ opts->bulk_sign = true;
+ break;
+
case -1:
break;
@@ -460,26 +465,34 @@ static int sign_single_file(struct cmd_opts *opts)
int main(int argc, char **argv)
{
+ int i;
struct cmd_opts opts = {};
parse_args(argc, argv, &opts);
argc -= optind;
argv += optind;
- if (!argv[0] || argc != 1)
- format();
-
- if (opts.dest_name && strcmp(argv[0], opts.dest_name)) {
- opts.replace_orig = false;
- } else {
- ERR(asprintf(&opts.dest_name, "%s.~signed~", opts.module_name) < 0,
- "asprintf");
- opts.replace_orig = true;
- }
-
OpenSSL_add_all_algorithms();
ERR_load_crypto_strings();
ERR_clear_error();
- return sign_single_file(&opts);
+ for (i = 0; i < argc; ++i) {
+ opts.module_name = argv[i];
+
+ if (!opts.bulk_sign && opts.dest_name && strcmp(argv[i], opts.dest_name)) {
+ opts.replace_orig = false;
+ } else {
+ ERR(asprintf(&opts.dest_name, "%s.~signed~", opts.module_name) < 0,
+ "asprintf");
+ if (!opts.replace_orig)
+ opts.replace_orig = true;
+ }
+
+ if (sign_single_file(&opts)) {
+ fprintf(stderr, "Failed to sign: %s module\n", opts.module_name);
+ return -1;
+ }
+ }
+
+ return 0;
}
--
2.39.2
next prev parent reply other threads:[~2023-03-21 19:35 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-03-21 19:33 [PATCH v6 0/7] refactor file signing program Shreenidhi Shedi
2023-03-21 19:33 ` [PATCH v6 1/7] sign-file: use getopt_long_only for parsing input args Shreenidhi Shedi
2023-03-21 19:33 ` [PATCH v6 2/7] sign-file: inntroduce few new flags to make argument processing easy Shreenidhi Shedi
2023-03-21 19:33 ` [PATCH v6 3/7] sign-file: move file signing logic to its own function Shreenidhi Shedi
2023-03-21 19:33 ` Shreenidhi Shedi [this message]
2023-03-21 19:33 ` [PATCH v6 5/7] sign-file: improve help message Shreenidhi Shedi
2023-03-21 19:33 ` [PATCH v6 6/7] sign-file: use const with a global string constant Shreenidhi Shedi
2023-03-21 19:33 ` [PATCH v6 7/7] sign-file: fix do while styling issue Shreenidhi Shedi
2023-04-25 10:44 ` [PATCH v6 0/7] refactor file signing program Shreenidhi Shedi
2023-05-31 14:38 ` Greg KH
2023-05-31 15:31 ` Shreenidhi Shedi
2023-05-31 16:50 ` Greg KH
2023-06-01 9:03 ` Shreenidhi Shedi
2023-06-01 9:08 ` Greg KH
2023-06-23 15:00 ` Shreenidhi Shedi
2023-08-07 2:23 ` Masahiro Yamada
2023-08-07 8:17 ` Shreenidhi Shedi
2023-08-07 10:21 ` Shreenidhi Shedi
2023-08-07 18:35 ` Masahiro Yamada
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=20230321193341.87997-5-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