Skip to content

add option to relax socket_vmnet validation #2662

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

Closed
Closed
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ jobs:
run: brew install qemu bash coreutils iperf3
- name: Install socket_vmnet
env:
SOCKET_VMNET_VERSION: v1.1.1
SOCKET_VMNET_VERSION: v1.1.4
run: |
(
cd ~
Expand Down
1 change: 1 addition & 0 deletions pkg/networks/networks.TEMPLATE.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ paths:
socketVMNet: "{{.SocketVMNet}}"
varRun: /private/var/run/lima
sudoers: /private/etc/sudoers.d/lima
relaxedVerification: true

group: everyone

Expand Down
7 changes: 4 additions & 3 deletions pkg/networks/networks.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,10 @@ type YAML struct {
}

type Paths struct {
SocketVMNet string `yaml:"socketVMNet"`
VarRun string `yaml:"varRun"`
Sudoers string `yaml:"sudoers,omitempty"`
SocketVMNet string `yaml:"socketVMNet"`
VarRun string `yaml:"varRun"`
Sudoers string `yaml:"sudoers,omitempty"`
RelaxedVerification bool `yaml:"relaxedVerification,omitempty"`
}

const (
Expand Down
24 changes: 19 additions & 5 deletions pkg/networks/validate.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,14 +20,20 @@ func (config *YAML) Validate() error {
paths := reflect.ValueOf(&config.Paths).Elem()
pathsMap := make(map[string]string, paths.NumField())
var socketVMNetNotFound bool
relaxedVerification := config.Paths.RelaxedVerification
for i := 0; i < paths.NumField(); i++ {
// extract YAML name from struct tag; strip options like "omitempty"
name := paths.Type().Field(i).Tag.Get("yaml")
if i := strings.IndexRune(name, ','); i > -1 {
name = name[:i]
}
path := paths.Field(i).Interface().(string)
pathsMap[name] = path
var path string
if path, ok := paths.Field(i).Interface().(string); ok {
pathsMap[name] = path
} else {
// we only validate strings from the config.Paths
continue
}
// varPath will be created securely, but any existing parent directories must already be secure
if name == "varRun" {
path = findBaseDirectory(path)
Expand All @@ -44,11 +50,19 @@ func (config *YAML) Validate() error {
continue
}
}
return fmt.Errorf("networks.yaml field `paths.%s` error: %w", name, err)
if relaxedVerification {
fmt.Printf("networks.yaml field `paths.%s` error: %v\n", name, err)
} else {
return fmt.Errorf("networks.yaml field `paths.%s` error: %w", name, err)
}
}
}
if socketVMNetNotFound {
return fmt.Errorf("networks.yaml: %q (`paths.socketVMNet`) has to be installed", pathsMap["socketVMNet"])
if relaxedVerification {
fmt.Printf("networks.yaml: %q (`paths.socketVMNet`) has to be installed\n", pathsMap["socketVMNet"])
} else {
return fmt.Errorf("networks.yaml: %q (`paths.socketVMNet`) has to be installed", pathsMap["socketVMNet"])
}
}
// TODO(jandubois): validate network definitions
return nil
Expand Down Expand Up @@ -126,7 +140,7 @@ func validatePath(path string, allowDaemonGroupWritable bool) error {
}
}
if !ownerIsAdmin {
return fmt.Errorf(`%s %q owner %dis not an admin`, file, path, stat.Uid)
return fmt.Errorf(`%s %q owner %d is not an admin`, file, path, stat.Uid)
}
if allowDaemonGroupWritable {
daemon, err := osutil.LookupUser("daemon")
Expand Down
Loading