Skip to content

Commit

Permalink
Exit if we are given a partition label/uuid
Browse files Browse the repository at this point in the history
Signed-off-by: Itxaka <itxaka@kairos.io>
  • Loading branch information
Itxaka committed Sep 20, 2024
1 parent 38a7e64 commit 80f2e83
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion pkg/types/v1/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,11 @@ type InstallSpec struct {
// if unsolvable inconsistencies are found
func (i *InstallSpec) Sanitize() error {
// Accept that the target can be a /dev/disk/by-{label,uuid,path,etc..} and resolve it into a /dev/device
if strings.HasPrefix("/dev/disk/by-", i.Target) {
if strings.HasPrefix(i.Target, "/dev/disk/by-") {
// we dont accept partitions as target so check and fail earlier for those that are partuuid or parlabel
if strings.Contains(i.Target, "parlabel") || strings.Contains(i.Target, "partuuid") {
return fmt.Errorf("target contains 'parlabel' or 'partuuid', looks like its a partition instead of a disk: %s", i.Target)
}
device, err := os.Readlink(i.Target)
if err != nil {
return fmt.Errorf("failed to read device link for %s: %w", i.Target, err)
Expand Down

0 comments on commit 80f2e83

Please sign in to comment.