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:
Bo Wang
2024-06-04 15:19:49 +08:00
parent 6417fa7b0f
commit 7243c7109c
2 changed files with 2 additions and 2 deletions

View File

@ -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)
}