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

Remove networking.hostConf option #74032

Merged
merged 2 commits into from Dec 5, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
17 changes: 3 additions & 14 deletions nixos/modules/config/networking.nix
Expand Up @@ -41,19 +41,6 @@ in
'';
};

networking.hostConf = lib.mkOption {
type = types.lines;
default = "multi on";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't we add an /etc/host.conf with this value by default?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. Will update the PR.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is host.conf honoured in the nsswitch.conf world?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

AFAICT yes as long as you use glibc's resolver directly. It might by another story when using dnsmasq or systemd-resolvd .

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should happen inside the file part of nsswitch.conf, so before and regardless of which resolver is used to do DNS lookups.

For context, this was introduced during #19148, and seems to be the default on ArchLinux.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@flokli I've studied the man pages but got still no clue about how this should be expressed in nsswitch.conf. Could you provide an example?

example = ''
multi on
reorder on
trim lan
'';
description = ''
The contents of <filename>/etc/host.conf</filename>. See also <citerefentry><refentrytitle>host.conf</refentrytitle><manvolnum>5</manvolnum></citerefentry>.
'';
};

networking.timeServers = mkOption {
default = [
"0.nixos.pool.ntp.org"
Expand Down Expand Up @@ -186,7 +173,9 @@ in
'';

# /etc/host.conf: resolver configuration file
"host.conf".text = cfg.hostConf;
"host.conf".text = ''
multi on
'';

} // optionalAttrs (pkgs.stdenv.hostPlatform.libc == "glibc") {
# /etc/rpc: RPC program numbers.
Expand Down
1 change: 1 addition & 0 deletions nixos/modules/rename.nix
Expand Up @@ -239,6 +239,7 @@ with lib;
(mkRemovedOptionModule [ "systemd" "generator-packages" ] "Use systemd.packages instead.")
(mkRemovedOptionModule [ "fonts" "enableCoreFonts" ] "Use fonts.fonts = [ pkgs.corefonts ]; instead.")
(mkRemovedOptionModule [ "networking" "vpnc" ] "Use environment.etc.\"vpnc/service.conf\" instead.")
(mkRemovedOptionModule [ "networking" "hostConf" ] "Use environment.etc.\"host.conf\" instead.")

# ZSH
(mkRenamedOptionModule [ "programs" "zsh" "enableSyntaxHighlighting" ] [ "programs" "zsh" "syntaxHighlighting" "enable" ])
Expand Down
46 changes: 46 additions & 0 deletions nixos/tests/resolv.nix
@@ -0,0 +1,46 @@
# Test whether DNS resolving returns multiple records and all address families.
import ./make-test-python.nix ({ pkgs, ... } : {
name = "resolv";
meta = with pkgs.stdenv.lib.maintainers; {
maintainers = [ ckauhaus ];
};

nodes.resolv = { ... }: {
networking.extraHosts = ''
# IPv4 only
192.0.2.1 host-ipv4.example.net
192.0.2.2 host-ipv4.example.net
# IP6 only
2001:db8::2:1 host-ipv6.example.net
2001:db8::2:2 host-ipv6.example.net
# dual stack
192.0.2.1 host-dual.example.net
192.0.2.2 host-dual.example.net
2001:db8::2:1 host-dual.example.net
2001:db8::2:2 host-dual.example.net
'';
};

testScript = ''
def addrs_in(hostname, addrs):
res = resolv.succeed("getent ahosts {}".format(hostname))
for addr in addrs:
assert addr in res, "Expected output '{}' not found in\n{}".format(addr, res)


start_all()
resolv.wait_for_unit("nscd")

ipv4 = ["192.0.2.1", "192.0.2.2"]
ipv6 = ["2001:db8::2:1", "2001:db8::2:2"]

with subtest("IPv4 resolves"):
addrs_in("host-ipv4.example.net", ipv4)

with subtest("IPv6 resolves"):
addrs_in("host-ipv6.example.net", ipv6)

with subtest("Dual stack resolves"):
addrs_in("host-dual.example.net", ipv4 + ipv6)
'';
})