Skip to content

Commit

Permalink
nvme_unlock: add flag to specify additional sysfs path.
Browse files Browse the repository at this point in the history
--eeprom-sysfs-path is a path relative to /sys/bus/ to search for
EEPROM containing the HSS secrets.

Signed-off-by: Jean-Marc Eurin <[email protected]>
  • Loading branch information
jmeurin committed Jan 10, 2025
1 parent 428c1b2 commit a7f29ab
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion cmds/exp/nvme_unlock/nvme_unlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ var (
noRereadPartitions = flag.Bool("no-reread-partitions", false, "Only attempt to unlock the disk, don't re-read the partition table.")
lock = flag.Bool("lock", false, "Lock instead of unlocking")
salt = flag.String("salt", hsskey.DefaultPasswordSalt, "Salt for password generation")
eepromSysfwPath = flag.String("eeprom-sysfs-path", "", "Additional path (relative to /sys/bus) used with eeprom-pattern to locate the Host Secret Seeds")
eepromPattern = flag.String("eeprom-pattern", "", "The pattern used to match EEPROM sysfs paths where the Host Secret Seeds are located")
hssFiles = flag.String("hss-files", "", "Comma deliminated list of files or directories containing additional Host Secret Seed (HSS)")
)
Expand Down Expand Up @@ -120,7 +121,14 @@ func run(disk string, verbose bool, verboseNoSanitize bool, noRereadPartitions b
}
defer diskFd.Close()

hssList, err := hsskey.GetAllHss(os.Stdout, verboseNoSanitize, *eepromPattern, *hssFiles)
sysfsPaths := []string{hsskey.BaseSysfsPattern}
if eepromSysfwPath != nil {
sysfsPaths = append(sysfsPaths, fmt.Sprintf("/sys/bus/%s", *eepromSysfwPath))
}

hssList, err := hsskey.GetAllHssWithPaths(os.Stdout, verboseNoSanitize,
sysfsPaths,
*eepromPattern, *hssFiles)
if err != nil {
return fmt.Errorf("error getting HSS: %w", err)
}
Expand Down

0 comments on commit a7f29ab

Please sign in to comment.