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

nixos/networking: add fqdn to /etc/hosts #72077

Closed
wants to merge 1 commit into from
Closed

Conversation

@sylv-io
Copy link
Contributor

sylv-io commented Oct 27, 2019

Motivation for this change

Referring to the manpage hosts(5), the fully qualified domain name (fqdn) is used to be included to the static lookup table for hostnames in case it is defined.
Some modules in different programming languages refer to it. (e.g. python socket.gethostname())

Things done

If networking.domain is defined, it will be added to /etc/hosts.

  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @oxij

Signed-off-by: Marcello Sylvester Bauer <sylv@sylv.io>
@sylv-io
Copy link
Contributor Author

sylv-io commented Oct 27, 2019

@zimbatm
Copy link
Member

zimbatm commented Oct 29, 2019

/cc @fpletz and @flokli

@flokli
Copy link
Contributor

flokli commented Oct 29, 2019

@zimbatm
Copy link
Member

zimbatm commented Oct 29, 2019

Yeah that's why I wanted you to be involved. In my experience it's best not to use FQDN as the machine hostname but it's certainly a possibility.

@sylv-io
Copy link
Contributor Author

sylv-io commented Oct 29, 2019

What about cases where /etc/hostname itself is a fqdn?

Referring to the man-page hostname(5), it should only includes the hostname.
But we could add fqdn detection, so it does not add fqdn with duplicated domain suffix. (e.g.: foo.bar.com.bar.com)

How does this sound for you?

@zimbatm
Copy link
Member

zimbatm commented Oct 29, 2019

In that case it might be even better to disallow it entirely. Fail if the hostname is not valid.

@sylv-io
Copy link
Contributor Author

sylv-io commented Oct 29, 2019

In that case it might be even better to disallow it entirely. Fail if the hostname is not valid.

I just see there are some distros like Fedora, who add the fqdn to the /etc/hostname file.
Maybe we should keep it optional, so it does not annoy some users.

@flokli
Copy link
Contributor

flokli commented Oct 30, 2019

Hm, I also had a fqdn in /etc/hostname, which required me to set the services.avahi.hostName to the non-fqdn'-ed variant to get it to work.

Reading a bit on the internet, this is probably a bad idea. Can we raise a warning if networking.hostName contains a dot, and maybe still have the code here handle it gracefully?

@woffs
woffs approved these changes Nov 3, 2019
Copy link
Contributor

woffs left a comment

This fixes the problem of a non-qualified domain name for a lot of e-mail tools (alpine, GNU Mailutils)

@zimbatm
Copy link
Member

zimbatm commented Nov 3, 2019

If networking.hostName could disallow the fqdn notation it would also allow to finally get rid of the confusion. A long long time ago, it made sense to map 1 host to 1 fqdn, but these days are long gone.

@zimbatm
Copy link
Member

zimbatm commented Nov 3, 2019

feel free to cherry-pick my strict hostName change: fc7a9b8

@flokli
Copy link
Contributor

flokli commented Nov 3, 2019

I agree with @zimbatm, but this would need some release notes, and maybe a better error message too.

@sylv-io
Copy link
Contributor Author

sylv-io commented Nov 4, 2019

feel free to cherry-pick my strict hostName change: fc7a9b8

Thx, I did cherry-pick this commit but I agree with @flokli.
Maybe it should be a warning first, until everyone adapted to the strict hostname annotation.

e.g.: networking.hostName = foo.bar.org; ->
warning: networking.hostName as fqdn is deprecated and should be separated by host and domain name. Please use following entries instead: networking.hostName=foo; networking.domain=bar.org;

@flokli
Copy link
Contributor

flokli commented Nov 18, 2019

@sylv-io can you add the warning and release notes?

@sylv-io
Copy link
Contributor Author

sylv-io commented Nov 19, 2019

@sylv-io can you add the warning and release notes?

Already started to work on it 👍
Do you know if there is any reference or documentation how to do it?

@flokli
Copy link
Contributor

flokli commented Nov 21, 2019

I assume you can just wrap networking.hostName with a warn if it contains a dot, like done in lib/types.nix for string.

@flokli flokli mentioned this pull request Jan 1, 2020
7 of 14 tasks complete
@primeos
Copy link
Member

primeos commented May 22, 2020

Unfortunately I didn't notice this PR before I've opened #76542. I've read through the comments and added some (optional) TODOs to my PR.

@sylv-io I hope you don't mind if I close your PR in favour of #76542.

@primeos primeos closed this May 22, 2020
@sylv-io
Copy link
Contributor Author

sylv-io commented May 23, 2020

@primeos don't worry. my bad that i didn't continued to work on it 👍

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

Successfully merging this pull request may close these issues.

None yet

6 participants
You can’t perform that action at this time.