diff options
| author | Eric Biggers <ebiggers@google.com> | 2021-06-27 13:13:10 -0700 |
|---|---|---|
| committer | Eric Biggers <ebiggers3@gmail.com> | 2021-06-27 15:00:51 -0700 |
| commit | e248d2a99aff5bef7611ac0596b0aa2d1eda6629 (patch) | |
| tree | 622e53b8ce51e2e347d35ee039d03fabfdbbe4d9 /cmd | |
| parent | 13a8aa8801a9f485867fde997c7a1542a284c1c1 (diff) | |
cmd/fscrypt: fix detection of GRUB installation
Fix the GRUB detection logic to take into account that
MOUNTPOINT/boot/grub might not be on the same filesystem as MOUNTPOINT,
due to MOUNTPOINT/boot being another mountpoint. The warning is only
appropriate when GRUB is installed on the same filesystem that
encryption is going to be enabled on.
Diffstat (limited to 'cmd')
| -rw-r--r-- | cmd/fscrypt/errors.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/cmd/fscrypt/errors.go b/cmd/fscrypt/errors.go index 10d744a..bcf5b59 100644 --- a/cmd/fscrypt/errors.go +++ b/cmd/fscrypt/errors.go @@ -106,6 +106,12 @@ func getFullName(c *cli.Context) string { return c.App.HelpName } +func isGrubInstalledOnFilesystem(mnt *filesystem.Mount) bool { + dir := filepath.Join(mnt.Path, "boot/grub") + grubDirMount, _ := filesystem.FindMount(dir) + return grubDirMount == mnt +} + func suggestEnablingEncryption(mnt *filesystem.Mount) string { kconfig := "CONFIG_FS_ENCRYPTION=y" switch mnt.FilesystemType { @@ -136,7 +142,7 @@ func suggestEnablingEncryption(mnt *filesystem.Mount) string { > sudo tune2fs -O encrypt %q `, mnt.Device) - if _, err := os.Stat(filepath.Join(mnt.Path, "boot/grub")); err == nil { + if isGrubInstalledOnFilesystem(mnt) { s += ` WARNING: you seem to have GRUB installed on this filesystem. Before doing the above, make sure you are |