Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hostname written to /etc/hostname does not include new-line at end #22729

Closed
dagraff-cisco opened this issue May 16, 2024 · 7 comments · Fixed by #22859
Closed

Hostname written to /etc/hostname does not include new-line at end #22729

dagraff-cisco opened this issue May 16, 2024 · 7 comments · Fixed by #22859
Assignees
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug.

Comments

@dagraff-cisco
Copy link

As noted in docker, the hostname written to /etc/hostname does not include a new-line at the end.

As per debian's hostname (5) man page:

The file should contain a single newline-terminated hostname string. Comments (lines starting with a "#") are ignored. The hostname should be composed of up to 64 7-bit ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any dots. Invalid characters will be filtered out in an attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this filtering.

The code in question: is here

hostnamePath, err := c.writeStringToRundir("hostname", c.Hostname())

This should be amended to read

hostnamePath, err := c.writeStringToRundir("hostname", fmt.Sprintf("%s\n", c.Hostname()))
@Luap99 Luap99 added kind/bug Categorizes issue or PR as related to a bug. Good First Issue This issue would be a good issue for a first time contributor to undertake. labels May 17, 2024
@raghavgh
Copy link

@Luap99 Can i pick this up?

@rhatdan
Copy link
Member

rhatdan commented May 17, 2024

You got it.

@ut-wangbo
Copy link
Contributor

@rhatdan
I noticed that this issue has not been closed for two weeks. And I wanna try to make my first contribution for containers/podman . ^_^

@raghavgh
Copy link

raghavgh commented May 31, 2024 via email

@rhatdan rhatdan assigned ut-wangbo and unassigned raghavgh May 31, 2024
@rhatdan
Copy link
Member

rhatdan commented May 31, 2024

@ut-wangbo you got it.

dagraff-cisco added a commit to dagraff-cisco/containers-podman that referenced this issue May 31, 2024
As noted in containers#22729:

As per debian's hostname (5) man page:
> The file should contain a single newline-terminated hostname string. Comments (lines starting with a "#") are ignored. The hostname should be composed of up to 64 7-bit ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any dots. Invalid characters will be filtered out in an attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this filtering.

I have made the change noted in the issue and provided a unit test to ensure that the value written is correct.
@dagraff-cisco
Copy link
Author

I have created a branch to address this in a forked repository - if you would like me to proceed with a PR for this please let me know.

@rhatdan
Copy link
Member

rhatdan commented Jun 1, 2024

If you have a fix, please open a PR.

dagraff-cisco added a commit to dagraff-cisco/containers-podman that referenced this issue Jun 1, 2024
As noted in containers#22729:

As per debian's hostname (5) man page:
> The file should contain a single newline-terminated hostname string. Comments (lines starting with a "#") are ignored. The hostname should be composed of up to 64 7-bit ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any dots. Invalid characters will be filtered out in an attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this filtering.

I have made the change noted in the issue and provided a unit test to ensure that the value written is correct.
dagraff-cisco added a commit to dagraff-cisco/containers-podman that referenced this issue Jun 1, 2024
As noted in containers#22729:

As per debian's hostname (5) man page:
> The file should contain a single newline-terminated hostname string. Comments (lines starting with a "#") are ignored. The hostname should be composed of up to 64 7-bit ASCII lower-case alphanumeric characters or hyphens forming a valid DNS domain name. It is recommended that this name contains only a single label, i.e. without any dots. Invalid characters will be filtered out in an attempt to make the name valid, but obviously it is recommended to use a valid name and not rely on this filtering.

I have made the change noted in the issue and provided a unit test to ensure that the value written is correct.

Signed-off-by: David Graff <dagraff@cisco.com>
ut-wangbo added a commit to ut-wangbo/podman that referenced this issue Jun 3, 2024
… file

debian's man (5) hostname page states "The file should contain a single newline-terminated hostname
string."
[NO NEW TESTS NEEDED]

fix containers#22729

Signed-off-by: Bo Wang <wangbob@uniontech.com>
ut-wangbo added a commit to ut-wangbo/podman that referenced this issue Jun 4, 2024
… file

debian's man (5) hostname page states "The file should contain a single newline-terminated hostname
string."
[NO NEW TESTS NEEDED]

fix containers#22729

Signed-off-by: Bo Wang <wangbob@uniontech.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Good First Issue This issue would be a good issue for a first time contributor to undertake. kind/bug Categorizes issue or PR as related to a bug.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants