diff options
author | Lennart Poettering <lennart@poettering.net> | 2022-08-17 17:00:27 +0200 |
---|---|---|
committer | Lennart Poettering <lennart@poettering.net> | 2022-08-19 21:26:26 +0200 |
commit | 222a951fa4a625e2d7d9c2799d9873377029d1bf (patch) | |
tree | c9dab5810fa7f5f25b9b9a7a27fbc0cb384ef877 /src/creds | |
parent | 466266c1728e3b53b7020e4c0165c3e88576b805 (diff) | |
download | systemd-222a951fa4a625e2d7d9c2799d9873377029d1bf.tar.gz |
tpm2-util: introduce tpm2_parse_pcr_argument() helper
Add a new tpm2_parse_pcr_argument() helper that unifies how we merge PCR
masks in a single function, we can use all over the place. Previously we
had basically the same code for this at 4 places.
Diffstat (limited to 'src/creds')
-rw-r--r-- | src/creds/creds.c | 17 |
1 files changed, 2 insertions, 15 deletions
diff --git a/src/creds/creds.c b/src/creds/creds.c index e9c7c96fc5..c067c886db 100644 --- a/src/creds/creds.c +++ b/src/creds/creds.c @@ -832,25 +832,12 @@ static int parse_argv(int argc, char *argv[]) { arg_tpm2_device = streq(optarg, "auto") ? NULL : optarg; break; - case ARG_TPM2_PCRS: { - uint32_t mask; - - if (isempty(optarg)) { - arg_tpm2_pcr_mask = 0; - break; - } - - r = tpm2_parse_pcrs(optarg, &mask); + case ARG_TPM2_PCRS: + r = tpm2_parse_pcr_argument(optarg, &arg_tpm2_pcr_mask); if (r < 0) return r; - if (arg_tpm2_pcr_mask == UINT32_MAX) - arg_tpm2_pcr_mask = mask; - else - arg_tpm2_pcr_mask |= mask; - break; - } case ARG_NAME: if (isempty(optarg)) { |