Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Checking for protected dirs must be against mountPoint and not location #3201

Merged
merged 1 commit into from
Feb 7, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions pkg/limayaml/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,14 +152,6 @@ func Validate(y *LimaYAML, warn bool) error {
if err != nil {
return fmt.Errorf("field `mounts[%d].location` refers to an unexpandable path: %q: %w", i, f.Location, err)
}
switch loc {
case "/", "/bin", "/dev", "/etc", "/home", "/opt", "/sbin", "/tmp", "/usr", "/var":
return fmt.Errorf("field `mounts[%d].location` must not be a system path such as /etc or /usr", i)
// home directory defined in "cidata.iso:/user-data"
case *y.User.Home:
return fmt.Errorf("field `mounts[%d].location` is the reserved internal home directory", i)
}

st, err := os.Stat(loc)
if err != nil {
if !errors.Is(err, os.ErrNotExist) {
Expand All @@ -169,6 +161,14 @@ func Validate(y *LimaYAML, warn bool) error {
return fmt.Errorf("field `mounts[%d].location` refers to a non-directory path: %q: %w", i, f.Location, err)
}

switch *f.MountPoint {
case "/", "/bin", "/dev", "/etc", "/home", "/opt", "/sbin", "/tmp", "/usr", "/var":
return fmt.Errorf("field `mounts[%d].mountPoint` must not be a system path such as /etc or /usr", i)
// home directory defined in "cidata.iso:/user-data"
case *y.User.Home:
return fmt.Errorf("field `mounts[%d].mountPoint` is the reserved internal home directory %q", i, *y.User.Home)
}

if _, err := units.RAMInBytes(*f.NineP.Msize); err != nil {
return fmt.Errorf("field `msize` has an invalid value: %w", err)
}
Expand Down
Loading