sandbox: implement autoetc as setup op
All checks were successful
Test / Create distribution (push) Successful in 27s
Test / Sandbox (push) Successful in 1m48s
Test / Fortify (push) Successful in 2m42s
Test / Sandbox (race detector) (push) Successful in 2m51s
Test / Fpkg (push) Successful in 3m37s
Test / Fortify (race detector) (push) Successful in 4m9s
Test / Flake checks (push) Successful in 1m4s
All checks were successful
Test / Create distribution (push) Successful in 27s
Test / Sandbox (push) Successful in 1m48s
Test / Fortify (push) Successful in 2m42s
Test / Sandbox (race detector) (push) Successful in 2m51s
Test / Fpkg (push) Successful in 3m37s
Test / Fortify (race detector) (push) Successful in 4m9s
Test / Flake checks (push) Successful in 1m4s
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>
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user