Skip to content

Commit

Permalink
Get label only if needed (#46)
Browse files Browse the repository at this point in the history
  • Loading branch information
Itxaka authored Jan 24, 2024
1 parent 7cf3646 commit ee41939
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions pkg/lib/unlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,21 +44,21 @@ 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 {
fmt.Printf("Unlocking failed: '%s'\n", err.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())
Expand Down

0 comments on commit ee41939

Please sign in to comment.