From ee419393cda4ec84d0bac6e5f42f268743202030 Mon Sep 17 00:00:00 2001 From: Itxaka Date: Wed, 24 Jan 2024 10:00:17 +0100 Subject: [PATCH] Get label only if needed (#46) --- pkg/lib/unlock.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pkg/lib/unlock.go b/pkg/lib/unlock.go index f9b612d..ff4b55f 100644 --- a/pkg/lib/unlock.go +++ b/pkg/lib/unlock.go @@ -44,14 +44,10 @@ func UnlockAll(tpm bool) error { fmt.Printf("No uuid for %s, skipping\n", p.Name) continue } - p.FilesystemLabel, err = config.GetLabelForUUID(volumeUUID) - if err != nil { - return err - } // Check if device is already mounted // We mount it under /dev/mapper/DEVICE, so It's pretty easy to check if !utils.Exists(filepath.Join("/dev", "mapper", p.Name)) { - fmt.Printf("Unmounted Luks found at '%s' LABEL '%s' \n", filepath.Join("/dev", p.Name), p.FilesystemLabel) + fmt.Printf("Unmounted Luks found at '%s' \n", filepath.Join("/dev", p.Name)) if tpm { out, err := utils.SH(fmt.Sprintf("/usr/lib/systemd/systemd-cryptsetup attach %s %s - tpm2-device=auto", p.Name, filepath.Join("/dev", p.Name))) if err != nil { @@ -59,6 +55,10 @@ func UnlockAll(tpm bool) error { fmt.Printf("Unlocking failed, command output: '%s'\n", out) } } else { + p.FilesystemLabel, err = config.GetLabelForUUID(volumeUUID) + if err != nil { + return err + } err = UnlockDisk(p) if err != nil { fmt.Printf("Unlocking failed: '%s'\n", err.Error())