mirror of
https://github.com/containers/podman.git
synced 2025-08-06 11:32:07 +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
|
||||
// This should never change, so no need to recreate if it exists
|
||||
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 {
|
||||
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.WaitWithDefaultTimeout()
|
||||
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.WaitWithDefaultTimeout()
|
||||
|
Reference in New Issue
Block a user