container/autoroot: remove prefix field
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m9s
Test / Hakurei (push) Successful in 3m12s
Test / Hpkg (push) Successful in 4m14s
Test / Sandbox (race detector) (push) Successful in 5m23s
Test / Hakurei (race detector) (push) Successful in 3m2s
Test / Flake checks (push) Successful in 1m23s
All checks were successful
Test / Create distribution (push) Successful in 34s
Test / Sandbox (push) Successful in 2m9s
Test / Hakurei (push) Successful in 3m12s
Test / Hpkg (push) Successful in 4m14s
Test / Sandbox (race detector) (push) Successful in 5m23s
Test / Hakurei (race detector) (push) Successful in 3m2s
Test / Flake checks (push) Successful in 1m23s
This field has been a noop for a long time. Remove it to prevent further confusion. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
33d2dcce1b
commit
cedfceded5
@ -10,14 +10,13 @@ func init() { gob.Register(new(AutoRootOp)) }
|
|||||||
|
|
||||||
// Root appends an [Op] that expands a directory into a toplevel bind mount mirror on container root.
|
// Root appends an [Op] that expands a directory into a toplevel bind mount mirror on container root.
|
||||||
// This is not a generic setup op. It is implemented here to reduce ipc overhead.
|
// This is not a generic setup op. It is implemented here to reduce ipc overhead.
|
||||||
func (f *Ops) Root(host *Absolute, prefix string, flags int) *Ops {
|
func (f *Ops) Root(host *Absolute, flags int) *Ops {
|
||||||
*f = append(*f, &AutoRootOp{host, prefix, flags, nil})
|
*f = append(*f, &AutoRootOp{host, flags, nil})
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
type AutoRootOp struct {
|
type AutoRootOp struct {
|
||||||
Host *Absolute
|
Host *Absolute
|
||||||
Prefix string
|
|
||||||
// passed through to bindMount
|
// passed through to bindMount
|
||||||
Flags int
|
Flags int
|
||||||
|
|
||||||
@ -71,12 +70,11 @@ func (r *AutoRootOp) Is(op Op) bool {
|
|||||||
vr, ok := op.(*AutoRootOp)
|
vr, ok := op.(*AutoRootOp)
|
||||||
return ok && r.Valid() && vr.Valid() &&
|
return ok && r.Valid() && vr.Valid() &&
|
||||||
r.Host.Is(vr.Host) &&
|
r.Host.Is(vr.Host) &&
|
||||||
r.Prefix == vr.Prefix &&
|
|
||||||
r.Flags == vr.Flags
|
r.Flags == vr.Flags
|
||||||
}
|
}
|
||||||
func (*AutoRootOp) prefix() string { return "setting up" }
|
func (*AutoRootOp) prefix() string { return "setting up" }
|
||||||
func (r *AutoRootOp) String() string {
|
func (r *AutoRootOp) String() string {
|
||||||
return fmt.Sprintf("auto root %q prefix %s flags %#x", r.Host, r.Prefix, r.Flags)
|
return fmt.Sprintf("auto root %q flags %#x", r.Host, r.Flags)
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsAutoRootBindable returns whether a dir entry name is selected for AutoRoot.
|
// IsAutoRootBindable returns whether a dir entry name is selected for AutoRoot.
|
||||||
|
@ -10,24 +10,22 @@ import (
|
|||||||
func TestAutoRootOp(t *testing.T) {
|
func TestAutoRootOp(t *testing.T) {
|
||||||
t.Run("nonrepeatable", func(t *testing.T) {
|
t.Run("nonrepeatable", func(t *testing.T) {
|
||||||
wantErr := msg.WrapErr(fs.ErrInvalid, "autoroot is not repeatable")
|
wantErr := msg.WrapErr(fs.ErrInvalid, "autoroot is not repeatable")
|
||||||
if err := (&AutoRootOp{Prefix: "81ceabb30d37bbdb3868004629cb84e9"}).apply(&setupState{nonrepeatable: nrAutoRoot}, nil); !errors.Is(err, wantErr) {
|
if err := new(AutoRootOp).apply(&setupState{nonrepeatable: nrAutoRoot}, nil); !errors.Is(err, wantErr) {
|
||||||
t.Errorf("apply: error = %v, want %v", err, wantErr)
|
t.Errorf("apply: error = %v, want %v", err, wantErr)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
checkOpBehaviour(t, []opBehaviourTestCase{
|
checkOpBehaviour(t, []opBehaviourTestCase{
|
||||||
{"readdir", &Params{ParentPerm: 0750}, &AutoRootOp{
|
{"readdir", &Params{ParentPerm: 0750}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: "81ceabb30d37bbdb3868004629cb84e9",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, []kexpect{
|
}, []kexpect{
|
||||||
{"readdir", expectArgs{"/"}, stubDir(), errUnique},
|
{"readdir", expectArgs{"/"}, stubDir(), errUnique},
|
||||||
}, wrapErrSelf(errUnique), nil, nil},
|
}, wrapErrSelf(errUnique), nil, nil},
|
||||||
|
|
||||||
{"early", &Params{ParentPerm: 0750}, &AutoRootOp{
|
{"early", &Params{ParentPerm: 0750}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: "81ceabb30d37bbdb3868004629cb84e9",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, []kexpect{
|
}, []kexpect{
|
||||||
{"readdir", expectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
{"readdir", expectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
||||||
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
||||||
@ -35,9 +33,8 @@ func TestAutoRootOp(t *testing.T) {
|
|||||||
}, wrapErrSelf(errUnique), nil, nil},
|
}, wrapErrSelf(errUnique), nil, nil},
|
||||||
|
|
||||||
{"apply", &Params{ParentPerm: 0750}, &AutoRootOp{
|
{"apply", &Params{ParentPerm: 0750}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: "81ceabb30d37bbdb3868004629cb84e9",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, []kexpect{
|
}, []kexpect{
|
||||||
{"readdir", expectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
{"readdir", expectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
||||||
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
||||||
@ -58,9 +55,8 @@ func TestAutoRootOp(t *testing.T) {
|
|||||||
}, wrapErrSelf(errUnique)},
|
}, wrapErrSelf(errUnique)},
|
||||||
|
|
||||||
{"success pd", &Params{ParentPerm: 0750}, &AutoRootOp{
|
{"success pd", &Params{ParentPerm: 0750}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: "81ceabb30d37bbdb3868004629cb84e9",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, []kexpect{
|
}, []kexpect{
|
||||||
{"readdir", expectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
{"readdir", expectArgs{"/"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
||||||
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
||||||
@ -90,8 +86,7 @@ func TestAutoRootOp(t *testing.T) {
|
|||||||
}, nil},
|
}, nil},
|
||||||
|
|
||||||
{"success", &Params{ParentPerm: 0750}, &AutoRootOp{
|
{"success", &Params{ParentPerm: 0750}, &AutoRootOp{
|
||||||
Host: MustAbs("/var/lib/planterette/base/debian:f92c9052"),
|
Host: MustAbs("/var/lib/planterette/base/debian:f92c9052"),
|
||||||
Prefix: "81ceabb30d37bbdb3868004629cb84e9",
|
|
||||||
}, []kexpect{
|
}, []kexpect{
|
||||||
{"readdir", expectArgs{"/var/lib/planterette/base/debian:f92c9052"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
{"readdir", expectArgs{"/var/lib/planterette/base/debian:f92c9052"}, stubDir("bin", "dev", "etc", "home", "lib64",
|
||||||
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
"lost+found", "mnt", "nix", "proc", "root", "run", "srv", "sys", "tmp", "usr", "var"), nil},
|
||||||
@ -128,11 +123,10 @@ func TestAutoRootOp(t *testing.T) {
|
|||||||
})
|
})
|
||||||
|
|
||||||
checkOpsBuilder(t, []opsBuilderTestCase{
|
checkOpsBuilder(t, []opsBuilderTestCase{
|
||||||
{"pd", new(Ops).Root(MustAbs("/"), "048090b6ed8f9ebb10e275ff5d8c0659", BindWritable), Ops{
|
{"pd", new(Ops).Root(MustAbs("/"), BindWritable), Ops{
|
||||||
&AutoRootOp{
|
&AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: "048090b6ed8f9ebb10e275ff5d8c0659",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
},
|
},
|
||||||
}},
|
}},
|
||||||
})
|
})
|
||||||
@ -141,63 +135,44 @@ func TestAutoRootOp(t *testing.T) {
|
|||||||
{"zero", new(AutoRootOp), new(AutoRootOp), false},
|
{"zero", new(AutoRootOp), new(AutoRootOp), false},
|
||||||
|
|
||||||
{"internal ne", &AutoRootOp{
|
{"internal ne", &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, &AutoRootOp{
|
}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
|
||||||
Flags: BindWritable,
|
Flags: BindWritable,
|
||||||
resolved: []Op{new(BindMountOp)},
|
resolved: []Op{new(BindMountOp)},
|
||||||
}, true},
|
}, true},
|
||||||
|
|
||||||
{"prefix differs", &AutoRootOp{
|
|
||||||
Host: MustAbs("/"),
|
|
||||||
Prefix: "\x00",
|
|
||||||
Flags: BindWritable,
|
|
||||||
}, &AutoRootOp{
|
|
||||||
Host: MustAbs("/"),
|
|
||||||
Prefix: ":3",
|
|
||||||
Flags: BindWritable,
|
|
||||||
}, false},
|
|
||||||
|
|
||||||
{"flags differs", &AutoRootOp{
|
{"flags differs", &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable | BindDevice,
|
||||||
Flags: BindWritable | BindDevice,
|
|
||||||
}, &AutoRootOp{
|
}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, false},
|
}, false},
|
||||||
|
|
||||||
{"host differs", &AutoRootOp{
|
{"host differs", &AutoRootOp{
|
||||||
Host: MustAbs("/tmp/"),
|
Host: MustAbs("/tmp/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, &AutoRootOp{
|
}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, false},
|
}, false},
|
||||||
|
|
||||||
{"equals", &AutoRootOp{
|
{"equals", &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, &AutoRootOp{
|
}, &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
|
||||||
}, true},
|
}, true},
|
||||||
})
|
})
|
||||||
|
|
||||||
checkOpMeta(t, []opMetaTestCase{
|
checkOpMeta(t, []opMetaTestCase{
|
||||||
{"root", &AutoRootOp{
|
{"root", &AutoRootOp{
|
||||||
Host: MustAbs("/"),
|
Host: MustAbs("/"),
|
||||||
Prefix: ":3",
|
Flags: BindWritable,
|
||||||
Flags: BindWritable,
|
}, "setting up", `auto root "/" flags 0x2`},
|
||||||
}, "setting up", `auto root "/" prefix :3 flags 0x2`},
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -43,7 +43,7 @@ var testCasesPd = []sealTestCase{
|
|||||||
"XDG_SESSION_TYPE=tty",
|
"XDG_SESSION_TYPE=tty",
|
||||||
},
|
},
|
||||||
Ops: new(container.Ops).
|
Ops: new(container.Ops).
|
||||||
Root(m("/"), "4a450b6596d7bc15bd01780eb9a607ac", container.BindWritable).
|
Root(m("/"), container.BindWritable).
|
||||||
Proc(m("/proc/")).
|
Proc(m("/proc/")).
|
||||||
Tmpfs(hst.AbsTmp, 4096, 0755).
|
Tmpfs(hst.AbsTmp, 4096, 0755).
|
||||||
DevWritable(m("/dev/"), true).
|
DevWritable(m("/dev/"), true).
|
||||||
@ -179,7 +179,7 @@ var testCasesPd = []sealTestCase{
|
|||||||
"XDG_SESSION_TYPE=tty",
|
"XDG_SESSION_TYPE=tty",
|
||||||
},
|
},
|
||||||
Ops: new(container.Ops).
|
Ops: new(container.Ops).
|
||||||
Root(m("/"), "ebf083d1b175911782d413369b64ce7c", container.BindWritable).
|
Root(m("/"), container.BindWritable).
|
||||||
Proc(m("/proc/")).
|
Proc(m("/proc/")).
|
||||||
Tmpfs(hst.AbsTmp, 4096, 0755).
|
Tmpfs(hst.AbsTmp, 4096, 0755).
|
||||||
DevWritable(m("/dev/"), true).
|
DevWritable(m("/dev/"), true).
|
||||||
|
@ -75,7 +75,7 @@ func newContainer(s *hst.ContainerConfig, os sys.State, prefix string, uid, gid
|
|||||||
}
|
}
|
||||||
|
|
||||||
if s.AutoRoot != nil {
|
if s.AutoRoot != nil {
|
||||||
params.Root(s.AutoRoot, prefix, s.RootFlags)
|
params.Root(s.AutoRoot, s.RootFlags)
|
||||||
}
|
}
|
||||||
|
|
||||||
params.
|
params.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user