mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +08:00
container: do not set hostname when joining uts
do not set the hostname when joining an UTS namespace, as it could be owned by a different userns. Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
This commit is contained in:
@ -392,7 +392,7 @@ func (c *Container) generateSpec(ctx context.Context) (*spec.Spec, error) {
|
||||
}
|
||||
|
||||
for _, i := range c.config.Spec.Linux.Namespaces {
|
||||
if i.Type == spec.UTSNamespace {
|
||||
if i.Type == spec.UTSNamespace && i.Path == "" {
|
||||
hostname := c.Hostname()
|
||||
g.SetHostname(hostname)
|
||||
g.AddProcessEnv("HOSTNAME", hostname)
|
||||
@ -591,7 +591,8 @@ func (c *Container) addNamespaceContainer(g *generate.Generator, ns LinuxNS, ctr
|
||||
|
||||
if specNS == spec.UTSNamespace {
|
||||
hostname := nsCtr.Hostname()
|
||||
g.SetHostname(hostname)
|
||||
// Joining an existing namespace, cannot set the hostname
|
||||
g.SetHostname("")
|
||||
g.AddProcessEnv("HOSTNAME", hostname)
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user