container: make resolv.conf and hosts accessible in userns

when running in a new userns, make sure the resolv.conf and hosts
files bind mounted from another container are accessible to root in
the userns.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
Giuseppe Scrivano
2020-06-10 14:45:11 +02:00
parent 63468464e8
commit a389eab8d1

View File

@ -1171,6 +1171,15 @@ func (c *Container) makeBindMounts() error {
// finally, save it in the new container
c.state.BindMounts["/etc/hosts"] = hostsPath
}
if !hasCurrentUserMapped(c) {
if err := makeAccessible(resolvPath, c.RootUID(), c.RootGID()); err != nil {
return err
}
if err := makeAccessible(hostsPath, c.RootUID(), c.RootGID()); err != nil {
return err
}
}
} else {
if !c.config.UseImageResolvConf {
newResolv, err := c.generateResolvConf()