tpm2: support "+" as separator for TPM PCR lists
Previously, we supported only "," as separator. This adds support for "+" and makes it the documented choice. This is to make specifying PCRs in crypttab easier, since commas are already used there for separating volume options, and needless escaping sucks. "," continues to be supported, but in order to keep things minimal not documented. Fixe: #19205
This commit is contained in:
@@ -920,13 +920,16 @@ int tpm2_parse_pcrs(const char *s, uint32_t *ret) {
|
||||
uint32_t mask = 0;
|
||||
int r;
|
||||
|
||||
/* Parses a comma-separated list of PCR indexes */
|
||||
/* Parses a "," or "+" separated list of PCR indexes. We support "," since this is a list after all,
|
||||
* and most other tools expect comma separated PCR specifications. We also support "+" since in
|
||||
* /etc/crypttab the "," is already used to separate options, hence a different separator is nice to
|
||||
* avoid escaping. */
|
||||
|
||||
for (;;) {
|
||||
_cleanup_free_ char *pcr = NULL;
|
||||
unsigned n;
|
||||
|
||||
r = extract_first_word(&p, &pcr, ",", EXTRACT_DONT_COALESCE_SEPARATORS);
|
||||
r = extract_first_word(&p, &pcr, ",+", EXTRACT_DONT_COALESCE_SEPARATORS);
|
||||
if (r == 0)
|
||||
break;
|
||||
if (r < 0)
|
||||
|
||||
Reference in New Issue
Block a user