From c806f43881223a85ad888f434e078dcc68de028d Mon Sep 17 00:00:00 2001 From: Ophestra Date: Thu, 10 Apr 2025 18:54:25 +0900 Subject: 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 --- fst/sandbox.go | 22 +++------------------- 1 file changed, 3 insertions(+), 19 deletions(-) (limited to 'fst') 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 -- cgit v1.3.1