1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92
|
package main
import (
rspec "github.com/opencontainers/runtime-spec/specs-go"
"github.com/opencontainers/runtime-tools/validation/util"
)
func main() {
defaultOptions := []string{
"nosuid",
"strictatime",
"mode=755",
"size=1k",
}
// Different combinations of mount types, mount options, mount propagation modes
mounts := []rspec.Mount{
{
Destination: "/tmp/test-shared",
Type: "tmpfs",
Source: "tmpfs",
Options: []string{"shared"},
},
{
Destination: "/tmp/test-slave",
Type: "tmpfs",
Source: "tmpfs",
Options: []string{"slave"},
},
{
Destination: "/tmp/test-private",
Type: "tmpfs",
Source: "tmpfs",
Options: []string{"private"},
},
{
Destination: "/mnt/etc-shared",
Source: "/etc",
Options: []string{"bind", "shared"},
},
{
Destination: "/mnt/etc-rshared",
Source: "/etc",
Options: []string{"rbind", "rshared"},
},
{
Destination: "/mnt/etc-slave",
Source: "/etc",
Options: []string{"bind", "slave"},
},
{
Destination: "/mnt/etc-rslave",
Source: "/etc",
Options: []string{"rbind", "rslave"},
},
{
Destination: "/mnt/etc-private",
Source: "/etc",
Options: []string{"bind", "private"},
},
{
Destination: "/mnt/etc-rprivate",
Source: "/etc",
Options: []string{"rbind", "rprivate"},
},
{
Destination: "/mnt/etc-unbindable",
Source: "/etc",
Options: []string{"bind", "unbindable"},
},
{
Destination: "/mnt/etc-runbindable",
Source: "/etc",
Options: []string{"rbind", "runbindable"},
},
}
g, err := util.GetDefaultGenerator()
if err != nil {
util.Fatal(err)
}
for _, m := range mounts {
m.Options = append(defaultOptions, m.Options...)
g.AddMount(m)
}
err = util.RuntimeInsideValidate(g, nil, nil)
if err != nil {
util.Fatal(err)
}
}
|