@@ -20,14 +20,20 @@ func (config *YAML) Validate() error {
20
20
paths := reflect .ValueOf (& config .Paths ).Elem ()
21
21
pathsMap := make (map [string ]string , paths .NumField ())
22
22
var socketVMNetNotFound bool
23
+ var relaxedVerification = config .Paths .RelaxedVerification
23
24
for i := 0 ; i < paths .NumField (); i ++ {
24
25
// extract YAML name from struct tag; strip options like "omitempty"
25
26
name := paths .Type ().Field (i ).Tag .Get ("yaml" )
26
27
if i := strings .IndexRune (name , ',' ); i > - 1 {
27
28
name = name [:i ]
28
29
}
29
- path := paths .Field (i ).Interface ().(string )
30
- pathsMap [name ] = path
30
+ var path string
31
+ if path , ok := paths .Field (i ).Interface ().(string ); ok {
32
+ pathsMap [name ] = path
33
+ } else {
34
+ // we only validate strings from the config.Paths
35
+ continue
36
+ }
31
37
// varPath will be created securely, but any existing parent directories must already be secure
32
38
if name == "varRun" {
33
39
path = findBaseDirectory (path )
@@ -44,11 +50,19 @@ func (config *YAML) Validate() error {
44
50
continue
45
51
}
46
52
}
47
- return fmt .Errorf ("networks.yaml field `paths.%s` error: %w" , name , err )
53
+ if relaxedVerification {
54
+ fmt .Printf ("networks.yaml field `paths.%s` error: %v\n " , name , err )
55
+ } else {
56
+ return fmt .Errorf ("networks.yaml field `paths.%s` error: %w" , name , err )
57
+ }
48
58
}
49
59
}
50
60
if socketVMNetNotFound {
51
- return fmt .Errorf ("networks.yaml: %q (`paths.socketVMNet`) has to be installed" , pathsMap ["socketVMNet" ])
61
+ if relaxedVerification {
62
+ fmt .Printf ("networks.yaml: %q (`paths.socketVMNet`) has to be installed\n " , pathsMap ["socketVMNet" ])
63
+ } else {
64
+ return fmt .Errorf ("networks.yaml: %q (`paths.socketVMNet`) has to be installed" , pathsMap ["socketVMNet" ])
65
+ }
52
66
}
53
67
// TODO(jandubois): validate network definitions
54
68
return nil
@@ -126,7 +140,7 @@ func validatePath(path string, allowDaemonGroupWritable bool) error {
126
140
}
127
141
}
128
142
if ! ownerIsAdmin {
129
- return fmt .Errorf (`%s %q owner %dis not an admin` , file , path , stat .Uid )
143
+ return fmt .Errorf (`%s %q owner %d is not an admin` , file , path , stat .Uid )
130
144
}
131
145
if allowDaemonGroupWritable {
132
146
daemon , err := osutil .LookupUser ("daemon" )
0 commit comments