From: Lennart Poettering Date: Tue, 4 Jun 2024 14:36:39 +0000 (+0200) Subject: tpm2-setup: split out SRK setup into a function of its own X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=2da86d62ffc8969511a6b87ee06af9f17d3ad86b;p=thirdparty%2Fsystemd.git tpm2-setup: split out SRK setup into a function of its own --- diff --git a/src/tpm2-setup/tpm2-setup.c b/src/tpm2-setup/tpm2-setup.c index 032b1e3381b..6338b7a75b6 100644 --- a/src/tpm2-setup/tpm2-setup.c +++ b/src/tpm2-setup/tpm2-setup.c @@ -252,22 +252,9 @@ static int load_public_key_tpm2(struct public_key_data *ret) { return 0; } -static int run(int argc, char *argv[]) { +static int setup_srk(void) { int r; - log_setup(); - - r = parse_argv(argc, argv); - if (r <= 0) - return r; - - if (arg_graceful && !tpm2_is_fully_supported()) { - log_notice("No complete TPM2 support detected, exiting gracefully."); - return EXIT_SUCCESS; - } - - umask(0022); - _cleanup_(public_key_data_done) struct public_key_data runtime_key = {}, persistent_key = {}, tpm2_key = {}; r = load_public_key_disk(TPM2_SRK_PEM_RUNTIME_PATH, &runtime_key); @@ -390,4 +377,23 @@ static int run(int argc, char *argv[]) { return 0; } +static int run(int argc, char *argv[]) { + int r; + + log_setup(); + + r = parse_argv(argc, argv); + if (r <= 0) + return r; + + if (arg_graceful && !tpm2_is_fully_supported()) { + log_notice("No complete TPM2 support detected, exiting gracefully."); + return EXIT_SUCCESS; + } + + umask(0022); + + return setup_srk(); +} + DEFINE_MAIN_FUNCTION_WITH_POSITIVE_FAILURE(run);