aboutsummaryrefslogtreecommitdiffhomepage
path: root/internal/app/container.go
diff options
context:
space:
mode:
authorOphestra <cat@gensokyo.uk>2025-09-29 02:33:10 +0900
committerOphestra <cat@gensokyo.uk>2025-09-29 06:11:47 +0900
commit46cd3a28c83e93b5d66c52d06a8366c11910d5c0 (patch)
tree6e25c5078b5cd9de78b7a6c9b253f1132358812b /internal/app/container.go
parentad1bc6794f0053c3e63eab408a0d530d53e8b51c (diff)
container: remove global msg
This frees all container instances of side effects. Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'internal/app/container.go')
-rw-r--r--internal/app/container.go21
1 files changed, 11 insertions, 10 deletions
diff --git a/internal/app/container.go b/internal/app/container.go
index d406d211..ae9dbf33 100644
--- a/internal/app/container.go
+++ b/internal/app/container.go
@@ -20,6 +20,7 @@ const preallocateOpsCount = 1 << 5
// newContainer initialises [container.Params] via [hst.ContainerConfig].
// Note that remaining container setup must be queued by the caller.
func newContainer(
+ msg container.Msg,
k syscallDispatcher,
s *hst.ContainerConfig,
prefix string,
@@ -73,8 +74,8 @@ func newContainer(
params.Gid = k.getgid()
*gid = params.Gid
} else {
- *uid = k.overflowUid()
- *gid = k.overflowGid()
+ *uid = k.overflowUid(msg)
+ *gid = k.overflowGid(msg)
}
filesystem := s.Filesystem
@@ -126,11 +127,11 @@ func newContainer(
// get parent dir of socket
dir := path.Dir(pair[1])
if dir == "." || dir == container.FHSRoot {
- k.verbosef("dbus socket %q is in an unusual location", pair[1])
+ msg.Verbosef("dbus socket %q is in an unusual location", pair[1])
}
hidePaths = append(hidePaths, dir)
} else {
- k.verbosef("dbus socket %q is not absolute", pair[1])
+ msg.Verbosef("dbus socket %q is not absolute", pair[1])
}
}
}
@@ -138,7 +139,7 @@ func newContainer(
}
hidePathMatch := make([]bool, len(hidePaths))
for i := range hidePaths {
- if err := evalSymlinks(k, &hidePaths[i]); err != nil {
+ if err := evalSymlinks(msg, k, &hidePaths[i]); err != nil {
return nil, nil, err
}
}
@@ -178,7 +179,7 @@ func newContainer(
if autoroot != nil {
for _, ent := range autoRootEntries {
name := ent.Name()
- if container.IsAutoRootBindable(name) {
+ if container.IsAutoRootBindable(msg, name) {
hidePathSource = append(hidePathSource, autoroot.Source.Append(name))
}
}
@@ -193,7 +194,7 @@ func newContainer(
}
hidePathSourceEval[i] = [2]string{a.String(), a.String()}
- if err := evalSymlinks(k, &hidePathSourceEval[i][0]); err != nil {
+ if err := evalSymlinks(msg, k, &hidePathSourceEval[i][0]); err != nil {
return nil, nil, err
}
}
@@ -209,7 +210,7 @@ func newContainer(
return nil, nil, err
} else if ok {
hidePathMatch[i] = true
- k.verbosef("hiding path %q from %q", hidePaths[i], p[1])
+ msg.Verbosef("hiding path %q from %q", hidePaths[i], p[1])
}
}
}
@@ -241,12 +242,12 @@ func newContainer(
}
// evalSymlinks calls syscallDispatcher.evalSymlinks but discards errors unwrapping to [fs.ErrNotExist].
-func evalSymlinks(k syscallDispatcher, v *string) error {
+func evalSymlinks(msg container.Msg, k syscallDispatcher, v *string) error {
if p, err := k.evalSymlinks(*v); err != nil {
if !errors.Is(err, fs.ErrNotExist) {
return err
}
- k.verbosef("path %q does not yet exist", *v)
+ msg.Verbosef("path %q does not yet exist", *v)
} else {
*v = p
}