Fix uki mode detection (#198)

This commit is contained in:
Itxaka
2024-01-10 10:38:31 +01:00
committed by GitHub
parent 174d69c3ea
commit 53f49169b1
3 changed files with 21 additions and 5 deletions

View File

@@ -9,6 +9,7 @@ import (
"github.com/kairos-io/kairos-sdk/machine"
"github.com/kairos-io/kairos-sdk/utils"
kcrypt "github.com/kairos-io/kcrypt/pkg/lib"
"os"
"strconv"
"strings"
"time"
@@ -41,6 +42,15 @@ func (k KcryptUKI) Run(c config.Config, _ v1.Spec) error {
return nil
}
// Check for a TPM 2.0 device as its needed to encrypt
// Exposed by the kernel to userspace as /dev/tpmrm0 since kernel 4.12
// https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=fdc915f7f71939ad5a3dda3389b8d2d7a7c5ee66
_, err = os.Stat("/dev/tpmrm0")
if err != nil {
c.Logger.Warnf("Skipping partition encryption, could not find TPM 2.0 device at /dev/tpmrm0")
return nil
}
// We always encrypt OEM and PERSISTENT under UKI
// If mounted, unmount it
_ = machine.Umount(constants.OEMDir) //nolint:errcheck