diskimage-builder/diskimage_builder/lib
Julia Kreger 4633da7750 Correct boot path to cover FIPS usage cases
When your booting a Linux system using dracut, i.e. with any
redhat style distribution, dracut's internal code looks to validate
the kernel hmac signature in before proceeding to userspace.

It does this by looking at the /boot/ folder file for the kernel
hmac file.

And it normally does this with the root filesystem. Except if the
kernel is not on the root filesystem and is instead on a /boot
filesystem, this breaks horribly. This is compounded because
DIB enables the operator to restructure the OS image/layout
to fit their needs. In order for this to be navigated, as dracut
is written, we need to pass a "boot=" argument to the kernel.

So now we attempt to purge any prior boot entry in the disk image
content, which is good because any filesystem operations invalidate
it, and then we attempt to identify the boot filesystem, and save a
boot kernel command line parameter so the resulting image can
boot properly if FIPS was enabled in the prior image.

Regex developed with https://sed.js.org utilizing stdin:

VAR="quiet boot=UUID=173c759f-1302-48a3-9d51-a17784c21e03 text"
VAR="quiet boot=PARTUUID=173c759f-1302-48a3-9d51-a17784c21e03"
VAR="quiet boot=PARTUUID=173c759f-1302-48a3-9d51-a17784c21e03 reboot=meow"
VAR="quiet boot=UUID=/dev/sda1 text"
VAR="quiet boot=/dev/sda1"
VAR="quiet boot=/dev/sda1 reboot=meow"
VAR="quiet after_boot=1 reboot=meow boot=/dev/sda1"
VAR="quiet after_boot=1 reboot=meow"

Which resulted in stdout:

VAR="quiet text"
VAR="quiet"
VAR="quiet reboot=meow"
VAR="quiet text"
VAR="quiet"
VAR="quiet reboot=meow"
VAR="quiet after_boot=1 reboot=meow"
VAR="quiet after_boot=1 reboot=meow"

Change-Id: I9034c21e84deda2ba2c0ec0d1d6d6595ed10bed4
2023-03-15 11:25:21 -07:00
..
common-defaults Support for Cloud Images on ppc64le for rhel7 and centos7 2017-06-29 15:44:26 +10:00
common-functions Merge "Add element block-device-efi-lvm" 2021-07-08 01:08:26 +00:00
dib-block-device.py Remove dib-block-device console entrypoint 2020-11-09 16:43:19 +11:00
dib-run-parts dib-run-parts: stop leaving PROFILE_DIR behind 2021-04-21 10:42:30 +10:00
die Move elements & lib relative to diskimage_builder package 2016-11-01 17:27:41 -07:00
disk-image-create Correct boot path to cover FIPS usage cases 2023-03-15 11:25:21 -07:00
element-info.py Remove entry-point for element-info 2020-11-09 16:39:35 +11:00
img-defaults Remove the rhel 8 check for xfs 2019-06-12 07:01:36 -07:00
img-functions Fix: IPA image buidling with OpenSuse. 2021-03-29 13:46:04 +03:00
outfilter.py Fix DIB scripts python version 2020-07-07 12:53:51 -07:00
ramdisk-defaults Move elements & lib relative to diskimage_builder package 2016-11-01 17:27:41 -07:00
ramdisk-functions Remove use of 'which'. 2017-05-19 12:43:36 -07:00
ramdisk-image-create Move diskimage-image-create to an entry point 2016-11-02 05:12:11 +00:00