diff options
author | Matthew Heon <mheon@redhat.com> | 2021-01-05 11:48:37 -0500 |
---|---|---|
committer | Matthew Heon <mheon@redhat.com> | 2021-01-06 09:46:21 -0500 |
commit | 8f844a66d5d144eeb92870c27171dc8b35788d4f (patch) | |
tree | 5c6f85c34ad04d05eab23d0730298f92964739a7 /pkg | |
parent | 1b9366d650200d0f2029d628fa00d1fd318631aa (diff) | |
download | podman-8f844a66d5d144eeb92870c27171dc8b35788d4f.tar.gz podman-8f844a66d5d144eeb92870c27171dc8b35788d4f.tar.bz2 podman-8f844a66d5d144eeb92870c27171dc8b35788d4f.zip |
Ensure that user-specified HOSTNAME is honored
When adding the HOSTNAME environment variable, only do so if it
is not already present in the spec. If it is already present, it
was likely added by the user, and we should honor their requested
value.
Fixes #8886
Signed-off-by: Matthew Heon <mheon@redhat.com>
Diffstat (limited to 'pkg')
-rw-r--r-- | pkg/specgen/generate/namespaces.go | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/pkg/specgen/generate/namespaces.go b/pkg/specgen/generate/namespaces.go index 036c7b7a1..3cd5a3c9c 100644 --- a/pkg/specgen/generate/namespaces.go +++ b/pkg/specgen/generate/namespaces.go @@ -364,7 +364,9 @@ func specConfigureNamespaces(s *specgen.SpecGenerator, g *generate.Generator, rt // namespaces? g.SetHostname(hostname) } - g.AddProcessEnv("HOSTNAME", hostname) + if _, ok := s.Env["HOSTNAME"]; !ok && s.Hostname != "" { + g.AddProcessEnv("HOSTNAME", hostname) + } // User switch s.UserNS.NSMode { |