diff options
| author | Ophestra <cat@gensokyo.uk> | 2025-04-10 18:54:25 +0900 |
|---|---|---|
| committer | Ophestra <cat@gensokyo.uk> | 2025-04-10 18:54:25 +0900 |
| commit | c806f43881223a85ad888f434e078dcc68de028d (patch) | |
| tree | 29e84efa3bc6466ad4f395d2f931d2d2e2468c28 /fst | |
| parent | 584405f7ccd4c8c0e63762e113f4650f2abd469e (diff) | |
sandbox: implement autoetc as setup op
This significantly reduces setup op count and the readdir call now happens in the context of the init process.
Signed-off-by: Ophestra <cat@gensokyo.uk>
Diffstat (limited to 'fst')
| -rw-r--r-- | fst/sandbox.go | 22 |
1 files changed, 3 insertions, 19 deletions
diff --git a/fst/sandbox.go b/fst/sandbox.go index 716e303b..cc98ec82 100644 --- a/fst/sandbox.go +++ b/fst/sandbox.go @@ -245,29 +245,13 @@ func (s *SandboxConfig) ToContainer(sys SandboxSys, uid, gid *int) (*sandbox.Par container.Bind(s.Etc, "/etc", 0) } } else { + const hostEtc = Tmp + "/etc" + etcPath := s.Etc if etcPath == "" { etcPath = "/etc" } - container.Bind(etcPath, Tmp+"/etc", 0) - - // link host /etc contents to prevent dropping passwd/group bind mounts - if d, err := sys.ReadDir(etcPath); err != nil { - return nil, nil, err - } else { - for _, ent := range d { - n := ent.Name() - switch n { - case "passwd": - case "group": - - case "mtab": - container.Link("/proc/mounts", "/etc/"+n) - default: - container.Link(Tmp+"/etc/"+n, "/etc/"+n) - } - } - } + container.Bind(etcPath, hostEtc, 0).Etc(hostEtc) } return container, maps.Clone(s.Env), nil |
