From patchwork Mon Aug 7 11:13:13 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shreenidhi Shedi X-Patchwork-Id: 13343637 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6D89BC41513 for ; Mon, 7 Aug 2023 11:16:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232142AbjHGLQD (ORCPT ); Mon, 7 Aug 2023 07:16:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:49728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232152AbjHGLPj (ORCPT ); Mon, 7 Aug 2023 07:15:39 -0400 Received: from mail-pf1-x42c.google.com (mail-pf1-x42c.google.com [IPv6:2607:f8b0:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4236C1998; Mon, 7 Aug 2023 04:14:33 -0700 (PDT) Received: by mail-pf1-x42c.google.com with SMTP id d2e1a72fcca58-686efb9ee0cso4186225b3a.3; Mon, 07 Aug 2023 04:14:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1691406808; x=1692011608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Ig5W7IVmZukpubm43ufz7bJD8pT18xKkNxAjQ1Pkr0Y=; b=Nxsxc2gtfadujSZDWH7cc/dc7W+ZNp114hMajuoIKwCi17Mfc4/P0yHFCE7sUTvcix qqPMTqdG3QyGE2SBMPcnmpIonHmZdbaYqFou1wsKUs/O2aB5YJaJCiytoKlHcKNwkj3d qvUbuRekv2TrTamHt7fgnRYlS8Qc+AuRRigcqvZSNvdJQFeQvBXJ1fbwm7ZuQ1x9P7H7 UAbkL8lh/zxBNrb1z6yzDX9cl9evUuvoETb7Cw/E92QvHTDStspHeQq48Gk+1F/mj7BO dxnhO/QPLP/etVNAiBvrW5HjcpQasZ6cG3CNophVUU86v7fAmxlmjetfpZDthR/PQdRP yawA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1691406808; x=1692011608; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Ig5W7IVmZukpubm43ufz7bJD8pT18xKkNxAjQ1Pkr0Y=; b=Hl3sDcpAMV8y8nzlFXR0jrcx3cc0BT0XZ6iwPjAa+1/H7aFibmvEaR4JPMM0fPwBph H/etwi8v6LoC9DyE3SjZh5eHSgiGyHGA6tGB0FY37z34BLtlnqNi1GACXK7PbA/uN2CA SMUaC3POqFOBXWWtqatpdJUzXurRtuyWOguD4MdNsohes2OqWL7kuGRUOY7Ab9c477dL 7vEVuUbdVLHyMBJM9BHqaYoR/ozmltxhIOuQr4YpnL7FeNUMwH9jRZWWduoPTV8+/kFt EVBvujiuSAqVBPH5XZYqgGAcNT/8BRD1nzFY+HOmnuECnXhKXFm/Wy0xsf7FmnLUFldD 52wA== X-Gm-Message-State: AOJu0YxsfYEdtWh/YKAplf4lDiHU/nUNszBih4uuohmRIVYDEwKm1ztL KZrzAS19BmRuzqOt2LHsMnc= X-Google-Smtp-Source: AGHT+IFRe/K/CpxkThSa7MFgXDiNocYf6+yZh2HUY05rxMAr7ugegSi2NlisoesFfCHknUQ62NZqNg== X-Received: by 2002:a05:6a20:728e:b0:138:48d7:4a31 with SMTP id o14-20020a056a20728e00b0013848d74a31mr11880590pzk.62.1691406808410; Mon, 07 Aug 2023 04:13:28 -0700 (PDT) Received: from f38.eng.vmware.com ([66.170.99.1]) by smtp.googlemail.com with ESMTPSA id 4-20020aa79144000000b00660d80087a8sm5939173pfi.187.2023.08.07.04.13.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 07 Aug 2023 04:13:28 -0700 (PDT) From: Shreenidhi Shedi To: dhowells@redhat.com, dwmw2@infradead.org, gregkh@linuxfoundation.org, masahiroy@kernel.org, nathan@kernel.org, ndesaulniers@google.com, nicolas@fjasle.eu Cc: yesshedi@gmail.com, linux-kernel@vger.kernel.org, sshedi@vmware.com, linux-kbuild@vger.kernel.org Subject: [PATCH v8 5/8] sign-file: improve help message Date: Mon, 7 Aug 2023 16:43:13 +0530 Message-ID: <20230807111316.315836-6-yesshedi@gmail.com> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20230807111316.315836-1-yesshedi@gmail.com> References: <20230807111316.315836-1-yesshedi@gmail.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-kbuild@vger.kernel.org Add a proper help message with examples on how to use this tool. Signed-off-by: Shreenidhi Shedi --- 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] []\n"); - fprintf(stderr, - " scripts/sign-file -s []\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 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 Destination path "); + fprintf(stderr, "(Exclusive with bulk option)\n"); + + fprintf(stderr, "\nMandatory args:\n"); + fprintf(stderr, "-i, --privkey Private key\n"); + fprintf(stderr, "-a, --hashalgo Hash algorithm\n"); + fprintf(stderr, "-x, --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 \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 -t \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 ...\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();