From: Zbigniew Jędrzejewski-Szmek Date: Mon, 9 Dec 2024 15:04:25 +0000 (+0100) Subject: systemd-cryptenroll: use pager for --help, add --no-pager option X-Git-Tag: v257~5^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=4b034cc128f2c1cd7ee3c6acc81db9f3ebb7a540;p=thirdparty%2Fsystemd.git systemd-cryptenroll: use pager for --help, add --no-pager option --- diff --git a/man/systemd-cryptenroll.xml b/man/systemd-cryptenroll.xml index 05d0f04f7f5..ab7bed40e19 100644 --- a/man/systemd-cryptenroll.xml +++ b/man/systemd-cryptenroll.xml @@ -728,6 +728,7 @@ + diff --git a/src/cryptenroll/cryptenroll.c b/src/cryptenroll/cryptenroll.c index dccb320c5dc..280d5107904 100644 --- a/src/cryptenroll/cryptenroll.c +++ b/src/cryptenroll/cryptenroll.c @@ -23,6 +23,7 @@ #include "libfido2-util.h" #include "main-func.h" #include "memory-util.h" +#include "pager.h" #include "parse-argument.h" #include "parse-util.h" #include "path-util.h" @@ -54,6 +55,7 @@ static uint32_t arg_tpm2_public_key_pcr_mask = 0; static char *arg_tpm2_signature = NULL; static char *arg_tpm2_pcrlock = NULL; static char *arg_node = NULL; +PagerFlags arg_pager_flags = 0; static int *arg_wipe_slots = NULL; static size_t arg_n_wipe_slots = 0; static WipeScope arg_wipe_slots_scope = WIPE_EXPLICIT; @@ -172,6 +174,8 @@ static int help(void) { _cleanup_free_ char *link = NULL; int r; + pager_open(arg_pager_flags); + r = terminal_urlify_man("systemd-cryptenroll", "1", &link); if (r < 0) return log_oom(); @@ -180,6 +184,7 @@ static int help(void) { "%5$sEnroll a security token or authentication credential to a LUKS volume.%6$s\n\n" " -h --help Show this help\n" " --version Show package version\n" + " --no-pager Do not spawn a pager\n" " --list-devices List candidate block devices to operate on\n" " --wipe-slot=SLOT1,SLOT2,…\n" " Wipe specified slots\n" @@ -245,6 +250,7 @@ static int help(void) { static int parse_argv(int argc, char *argv[]) { enum { ARG_VERSION = 0x100, + ARG_NO_PAGER, ARG_PASSWORD, ARG_RECOVERY_KEY, ARG_UNLOCK_KEYFILE, @@ -274,6 +280,7 @@ static int parse_argv(int argc, char *argv[]) { static const struct option options[] = { { "help", no_argument, NULL, 'h' }, { "version", no_argument, NULL, ARG_VERSION }, + { "no-pager", no_argument, NULL, ARG_NO_PAGER }, { "password", no_argument, NULL, ARG_PASSWORD }, { "recovery-key", no_argument, NULL, ARG_RECOVERY_KEY }, { "unlock-key-file", required_argument, NULL, ARG_UNLOCK_KEYFILE }, @@ -317,6 +324,10 @@ static int parse_argv(int argc, char *argv[]) { case ARG_VERSION: return version(); + case ARG_NO_PAGER: + arg_pager_flags |= PAGER_DISABLE; + break; + case ARG_FIDO2_WITH_PIN: r = parse_boolean_argument("--fido2-with-client-pin=", optarg, NULL); if (r < 0)