container/autoroot: filter dentry with empty name
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m12s
Test / Hakurei (push) Successful in 3m5s
Test / Hpkg (push) Successful in 4m9s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Successful in 1m28s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m12s
Test / Hakurei (push) Successful in 3m5s
Test / Hpkg (push) Successful in 4m9s
Test / Sandbox (race detector) (push) Successful in 4m24s
Test / Hakurei (race detector) (push) Successful in 5m1s
Test / Flake checks (push) Successful in 1m28s
This is unreachable, but nice to have just in case. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
13c7083bc0
commit
e0533aaa68
@ -89,6 +89,8 @@ func IsAutoRootBindable(name string) bool {
|
|||||||
case "mnt":
|
case "mnt":
|
||||||
case "etc":
|
case "etc":
|
||||||
|
|
||||||
|
case "": // guard against accidentally binding /
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
26
container/autoroot_test.go
Normal file
26
container/autoroot_test.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package container
|
||||||
|
|
||||||
|
import "testing"
|
||||||
|
|
||||||
|
func TestIsAutoRootBindable(t *testing.T) {
|
||||||
|
testCases := []struct {
|
||||||
|
name string
|
||||||
|
want bool
|
||||||
|
}{
|
||||||
|
{"proc", false},
|
||||||
|
{"dev", false},
|
||||||
|
{"tmp", false},
|
||||||
|
{"mnt", false},
|
||||||
|
{"etc", false},
|
||||||
|
{"", false},
|
||||||
|
|
||||||
|
{"var", true},
|
||||||
|
}
|
||||||
|
for _, tc := range testCases {
|
||||||
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
if got := IsAutoRootBindable(tc.name); got != tc.want {
|
||||||
|
t.Errorf("IsAutoRootBindable: %v, want %v", got, tc.want)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user