aboutsummaryrefslogtreecommitdiffhomepage
path: root/container/autoetc.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-08-17 01:43:11 +0900
committerOphestra <cat@gensokyo.uk>2025-08-17 01:43:11 +0900
commit9c1a5d43bad802aa0ad717ea603c51f7b0408cdd (patch)
tree2127e3b73a91fe1cd5cfa8583a6a1c145f2c37bd /container/autoetc.go
parent8aa65f28c68815db9dd1f246ee2656759574c3bb (diff)
container: enforce nonrepeatable autoetc and autoroot
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>
Diffstat (limited to 'container/autoetc.go')
-rw-r--r--container/autoetc.go8
1 files changed, 7 insertions, 1 deletions
diff --git a/container/autoetc.go b/container/autoetc.go
index f494d75c..23b1a86c 100644
--- a/container/autoetc.go
+++ b/container/autoetc.go
@@ -4,6 +4,7 @@ import (
"encoding/gob"
"fmt"
"os"
+ "syscall"
)
func init() { gob.Register(new(AutoEtcOp)) }
@@ -21,7 +22,12 @@ func (f *Ops) Etc(host *Absolute, prefix string) *Ops {
type AutoEtcOp struct{ Prefix string }
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
rel := e.hostRel() + "/"