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 · 10 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 · 10 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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.

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
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.

Signed-off-by: David Graff <[email protected]>
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 <[email protected]>
@dagraff-cisco
Copy link
Author

This issue was closed in June - however was not included into 5.1 - what is the process to request inclusion?

@Luap99
Copy link
Member

Luap99 commented Jul 11, 2024

It will be part of 5.2 which will be released in the next few weeks.

@dagraff-cisco
Copy link
Author

@Luap99 thank you very much for the super fast response. Truly appreciate the work y'all do!

@stale-locking-app stale-locking-app bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Oct 10, 2024
@stale-locking-app stale-locking-app bot locked as resolved and limited conversation to collaborators Oct 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
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. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants