Skip to content

Certificate creation through dockerd-entrypoint.sh may create incorrect DNS SAN if /etc/hostname does not end with a new-line character #496

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

Closed
dagraff-cisco opened this issue May 16, 2024 · 4 comments

Comments

@dagraff-cisco
Copy link

cat /etc/hostname

I have encountered an issue working under podman where the /etc/hostname file does not contain a new-line after the configured container hostname.

Could _tls_san() in dockerd-entrypoint.sh be modified to account for this?

For example

_tls_san() {
	{
		ip -oneline address | awk '{ gsub(/\/.+$/, "", $4); print "IP:" $4 }'
		{
			echo $(cat /etc/hostname | tr -d '\n' -)
			echo 'docker'
			echo 'localhost'
			hostname -f
			hostname -s
		} | sed 's/^/DNS:/'
		[ -z "${DOCKER_TLS_SAN:-}" ] || echo "$DOCKER_TLS_SAN"
	} | sort -u | xargs printf '%s,' | sed "s/,\$//"
}
@yosifkit
Copy link
Member

The file should contain a single newline-terminated hostname string.

- https://manpages.debian.org/bookworm/systemd/hostname.5.en.html

I would say that podman has a bug. So, no, I don't think we should change to support an incorrectly formatted /etc/hostname.

@dagraff-cisco
Copy link
Author

Fair enough - I'll file with them.

@tianon
Copy link
Member

tianon commented May 16, 2024

Specifically, if I'm reading their code correctly, it probably needs to add \n in https://github.com/containers/podman/blob/f7a30461e06f6786b02fc44b5c48525d2ebbc482/libpod/container_internal_linux.go#L667

@dagraff-cisco
Copy link
Author

@tianon thank you for that - I'll file with the containers/podman project on that issue - seems trivial to fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants