container: enforce nonrepeatable autoetc and autoroot
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m6s
Test / Hakurei (push) Successful in 3m4s
Test / Hpkg (push) Successful in 4m2s
Test / Sandbox (race detector) (push) Successful in 4m18s
Test / Hakurei (race detector) (push) Successful in 4m57s
Test / Flake checks (push) Successful in 1m21s
All checks were successful
Test / Create distribution (push) Successful in 33s
Test / Sandbox (push) Successful in 2m6s
Test / Hakurei (push) Successful in 3m4s
Test / Hpkg (push) Successful in 4m2s
Test / Sandbox (race detector) (push) Successful in 4m18s
Test / Hakurei (race detector) (push) Successful in 4m57s
Test / Flake checks (push) Successful in 1m21s
These keep track of some internal state, and they don't make sense to have multiple instances of anyway, so instead of dealing with that, just make them nonrepetable. Signed-off-by: Ophestra <cat@gensokyo.uk>
This commit is contained in:
parent
8aa65f28c6
commit
9c1a5d43ba
@ -4,6 +4,7 @@ import (
|
|||||||
"encoding/gob"
|
"encoding/gob"
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() { gob.Register(new(AutoEtcOp)) }
|
func init() { gob.Register(new(AutoEtcOp)) }
|
||||||
@ -21,7 +22,12 @@ func (f *Ops) Etc(host *Absolute, prefix string) *Ops {
|
|||||||
type AutoEtcOp struct{ Prefix string }
|
type AutoEtcOp struct{ Prefix string }
|
||||||
|
|
||||||
func (e *AutoEtcOp) early(*setupState) error { return nil }
|
func (e *AutoEtcOp) early(*setupState) error { return nil }
|
||||||
func (e *AutoEtcOp) apply(*setupState) error {
|
func (e *AutoEtcOp) apply(state *setupState) error {
|
||||||
|
if state.nonrepeatable&nrAutoEtc != 0 {
|
||||||
|
return msg.WrapErr(syscall.EINVAL, "autoetc is not repeatable")
|
||||||
|
}
|
||||||
|
state.nonrepeatable |= nrAutoEtc
|
||||||
|
|
||||||
const target = sysrootPath + FHSEtc
|
const target = sysrootPath + FHSEtc
|
||||||
rel := e.hostRel() + "/"
|
rel := e.hostRel() + "/"
|
||||||
|
|
||||||
|
@ -56,6 +56,11 @@ func (r *AutoRootOp) early(state *setupState) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (r *AutoRootOp) apply(state *setupState) error {
|
func (r *AutoRootOp) apply(state *setupState) error {
|
||||||
|
if state.nonrepeatable&nrAutoRoot != 0 {
|
||||||
|
return msg.WrapErr(syscall.EINVAL, "autoroot is not repeatable")
|
||||||
|
}
|
||||||
|
state.nonrepeatable |= nrAutoRoot
|
||||||
|
|
||||||
for _, op := range r.resolved {
|
for _, op := range r.resolved {
|
||||||
msg.Verbosef("%s %s", op.prefix(), op)
|
msg.Verbosef("%s %s", op.prefix(), op)
|
||||||
if err := op.apply(state); err != nil {
|
if err := op.apply(state); err != nil {
|
||||||
|
@ -24,6 +24,11 @@ const (
|
|||||||
intermediatePatternTmpfile = "tmp.*"
|
intermediatePatternTmpfile = "tmp.*"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
nrAutoEtc = 1 << iota
|
||||||
|
nrAutoRoot
|
||||||
|
)
|
||||||
|
|
||||||
type (
|
type (
|
||||||
Ops []Op
|
Ops []Op
|
||||||
|
|
||||||
@ -41,6 +46,7 @@ type (
|
|||||||
}
|
}
|
||||||
|
|
||||||
setupState struct {
|
setupState struct {
|
||||||
|
nonrepeatable uintptr
|
||||||
*Params
|
*Params
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user