mirror of
https://github.com/containers/podman.git
synced 2025-08-06 19:44:14 +08:00
fix(libpod): add newline character to the end of container's hostname file
debian's man (5) hostname page states "The file should contain a single newline-terminated hostname string." [NO NEW TESTS NEEDED] fix #22729 Signed-off-by: Bo Wang <wangbob@uniontech.com>
This commit is contained in:
@ -664,7 +664,7 @@ func (c *Container) makePlatformBindMounts() error {
|
|||||||
// Make /etc/hostname
|
// Make /etc/hostname
|
||||||
// This should never change, so no need to recreate if it exists
|
// This should never change, so no need to recreate if it exists
|
||||||
if _, ok := c.state.BindMounts["/etc/hostname"]; !ok {
|
if _, ok := c.state.BindMounts["/etc/hostname"]; !ok {
|
||||||
hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname())
|
hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname()+"\n")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("creating hostname file for container %s: %w", c.ID(), err)
|
return fmt.Errorf("creating hostname file for container %s: %w", c.ID(), err)
|
||||||
}
|
}
|
||||||
|
@ -60,7 +60,7 @@ var _ = Describe("Podman run dns", func() {
|
|||||||
session := podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "cat", "/etc/hostname"})
|
session := podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "cat", "/etc/hostname"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
Expect(session).Should(ExitCleanly())
|
Expect(session).Should(ExitCleanly())
|
||||||
Expect(session.OutputToString()).To(Equal("foobar"))
|
Expect(string(session.Out.Contents())).To(Equal("foobar\n"))
|
||||||
|
|
||||||
session = podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "hostname"})
|
session = podmanTest.Podman([]string{"run", "--hostname=foobar", ALPINE, "hostname"})
|
||||||
session.WaitWithDefaultTimeout()
|
session.WaitWithDefaultTimeout()
|
||||||
|
Reference in New Issue
Block a user