pcrextend: automatically measure SMBIOS product ID at boot
Now that PCRs are not that expensive anymore, let's use them to measure the SMBIOS product ID to one.
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
#include "errno-util.h"
|
||||
#include "escape.h"
|
||||
#include "fd-util.h"
|
||||
#include "id128-util.h"
|
||||
#include "log.h"
|
||||
#include "mountpoint-util.h"
|
||||
#include "pcrextend-util.h"
|
||||
@@ -158,3 +159,24 @@ int pcrextend_machine_id_word(char **ret) {
|
||||
*ret = TAKE_PTR(word);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int pcrextend_product_id_word(char **ret) {
|
||||
_cleanup_free_ char *word = NULL;
|
||||
sd_id128_t pid;
|
||||
int r;
|
||||
|
||||
assert(ret);
|
||||
|
||||
r = id128_get_product(&pid);
|
||||
if (IN_SET(r, -ENOENT, -EADDRNOTAVAIL)) /* No product UUID field, or an all-zero or all-0xFF UUID */
|
||||
word = strdup("product-id:missing");
|
||||
else if (r < 0)
|
||||
return log_error_errno(r, "Failed to acquire product ID: %m");
|
||||
else
|
||||
word = strjoin("product-id:", SD_ID128_TO_STRING(pid));
|
||||
if (!word)
|
||||
return log_oom();
|
||||
|
||||
*ret = TAKE_PTR(word);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -3,3 +3,4 @@
|
||||
|
||||
int pcrextend_file_system_word(const char *path, char **ret, char **ret_normalized_path);
|
||||
int pcrextend_machine_id_word(char **ret);
|
||||
int pcrextend_product_id_word(char **ret);
|
||||
|
||||
@@ -6424,6 +6424,7 @@ static const char* tpm2_userspace_event_type_table[_TPM2_USERSPACE_EVENT_TYPE_MA
|
||||
[TPM2_EVENT_FILESYSTEM] = "filesystem",
|
||||
[TPM2_EVENT_VOLUME_KEY] = "volume-key",
|
||||
[TPM2_EVENT_MACHINE_ID] = "machine-id",
|
||||
[TPM2_EVENT_PRODUCT_ID] = "product-id",
|
||||
};
|
||||
|
||||
DEFINE_STRING_TABLE_LOOKUP(tpm2_userspace_event_type, Tpm2UserspaceEventType);
|
||||
|
||||
@@ -142,6 +142,7 @@ typedef enum Tpm2UserspaceEventType {
|
||||
TPM2_EVENT_FILESYSTEM,
|
||||
TPM2_EVENT_VOLUME_KEY,
|
||||
TPM2_EVENT_MACHINE_ID,
|
||||
TPM2_EVENT_PRODUCT_ID,
|
||||
_TPM2_USERSPACE_EVENT_TYPE_MAX,
|
||||
_TPM2_USERSPACE_EVENT_TYPE_INVALID = -EINVAL,
|
||||
} Tpm2UserspaceEventType;
|
||||
|
||||
Reference in New Issue
Block a user