diff options
author | niko.mauno@vaisala.com <niko.mauno@vaisala.com> | 2020-09-10 16:17:53 +0000 |
---|---|---|
committer | Armin Kuster <akuster808@gmail.com> | 2020-09-12 08:55:28 -0700 |
commit | 170945ff9f8835ab7b0045b722c2a480b450ef90 (patch) | |
tree | c641978f33a83660a7656940dbb0a12772fb3871 | |
parent | 6f40921308be358ffce1a4e51a76672ad4168c21 (diff) | |
download | meta-security-170945ff9f8835ab7b0045b722c2a480b450ef90.tar.gz |
dm-verity-img.bbclass: Stage verity.env file
Introduce new STAGING_VERITY_DIR variable specific to this bbclass which
defines the directory where the verity.env file is stored during
<DM_VERITY_IMAGE>:do_image_<DM_VERITY_IMAGE_TYPE> task and can
consequtively be picked up into associated initramfs rootfs (which
facilitates executing 'veritysetup' and related actions).
By doing this we mitigate failures that were thus far associated to this
facility, such as
install: cannot stat '.../build/tmp/deploy/images/qemux86-64/core-image-minimal-qemux86-64.ext4.verity.env': No such file or directory
and
install: cannot stat '.../build/tmp/deploy/images/beaglebone-yocto/core-image-minimal-beaglebone-yocto.ext4.verity.env': No such file or directory
Signed-off-by: Niko Mauno <niko.mauno@vaisala.com>
Signed-off-by: Armin Kuster <akuster808@gmail.com>
-rw-r--r-- | classes/dm-verity-img.bbclass | 10 | ||||
-rw-r--r-- | recipes-core/images/dm-verity-image-initramfs.bb | 2 |
2 files changed, 8 insertions, 4 deletions
diff --git a/classes/dm-verity-img.bbclass b/classes/dm-verity-img.bbclass index 6ad0f75..16d395b 100644 --- a/classes/dm-verity-img.bbclass +++ b/classes/dm-verity-img.bbclass | |||
@@ -18,12 +18,18 @@ | |||
18 | # The resulting image can then be used to implement the device mapper block | 18 | # The resulting image can then be used to implement the device mapper block |
19 | # integrity checking on the target device. | 19 | # integrity checking on the target device. |
20 | 20 | ||
21 | # Define the location where the DM_VERITY_IMAGE specific dm-verity root hash | ||
22 | # is stored where it can be installed into associated initramfs rootfs. | ||
23 | STAGING_VERITY_DIR ?= "${TMPDIR}/work-shared/${MACHINE}/dm-verity" | ||
24 | |||
21 | # Process the output from veritysetup and generate the corresponding .env | 25 | # Process the output from veritysetup and generate the corresponding .env |
22 | # file. The output from veritysetup is not very machine-friendly so we need to | 26 | # file. The output from veritysetup is not very machine-friendly so we need to |
23 | # convert it to some better format. Let's drop the first line (doesn't contain | 27 | # convert it to some better format. Let's drop the first line (doesn't contain |
24 | # any useful info) and feed the rest to a script. | 28 | # any useful info) and feed the rest to a script. |
25 | process_verity() { | 29 | process_verity() { |
26 | local ENV="$OUTPUT.env" | 30 | local ENV="${STAGING_VERITY_DIR}/${IMAGE_BASENAME}.$TYPE.verity.env" |
31 | install -d ${STAGING_VERITY_DIR} | ||
32 | rm -f $ENV | ||
27 | 33 | ||
28 | # Each line contains a key and a value string delimited by ':'. Read the | 34 | # Each line contains a key and a value string delimited by ':'. Read the |
29 | # two parts into separate variables and process them separately. For the | 35 | # two parts into separate variables and process them separately. For the |
@@ -39,8 +45,6 @@ process_verity() { | |||
39 | 45 | ||
40 | # Add partition size | 46 | # Add partition size |
41 | echo "DATA_SIZE=$SIZE" >> $ENV | 47 | echo "DATA_SIZE=$SIZE" >> $ENV |
42 | |||
43 | ln -sf $ENV ${IMAGE_BASENAME}-${MACHINE}.$TYPE.verity.env | ||
44 | } | 48 | } |
45 | 49 | ||
46 | verity_setup() { | 50 | verity_setup() { |
diff --git a/recipes-core/images/dm-verity-image-initramfs.bb b/recipes-core/images/dm-verity-image-initramfs.bb index 8dd8543..e791c19 100644 --- a/recipes-core/images/dm-verity-image-initramfs.bb +++ b/recipes-core/images/dm-verity-image-initramfs.bb | |||
@@ -24,6 +24,6 @@ IMAGE_FSTYPES = "${INITRAMFS_FSTYPES}" | |||
24 | inherit core-image | 24 | inherit core-image |
25 | 25 | ||
26 | deploy_verity_hash() { | 26 | deploy_verity_hash() { |
27 | install -D -m 0644 ${DEPLOY_DIR_IMAGE}/${DM_VERITY_IMAGE}-${MACHINE}.${DM_VERITY_IMAGE_TYPE}.verity.env ${IMAGE_ROOTFS}/${datadir}/dm-verity.env | 27 | install -D -m 0644 ${STAGING_VERITY_DIR}/${DM_VERITY_IMAGE}.${DM_VERITY_IMAGE_TYPE}.verity.env ${IMAGE_ROOTFS}${datadir}/dm-verity.env |
28 | } | 28 | } |
29 | IMAGE_PREPROCESS_COMMAND += "deploy_verity_hash;" | 29 | IMAGE_PREPROCESS_COMMAND += "deploy_verity_hash;" |