diff options
author | fenner <fenner@FreeBSD.org> | 2001-11-07 00:33:56 +0000 |
---|---|---|
committer | fenner <fenner@FreeBSD.org> | 2001-11-07 00:33:56 +0000 |
commit | 178d6888d63728d377fd8046bc4f60db2fee864e (patch) | |
tree | 9b03037ae141daba056125f55d2c329fdf790c14 /etc/rc.d/netoptions | |
parent | a53b61e772f8606cd8a338c0298ccd3691135569 (diff) | |
download | FreeBSD-src-178d6888d63728d377fd8046bc4f60db2fee864e.zip FreeBSD-src-178d6888d63728d377fd8046bc4f60db2fee864e.tar.gz |
Update the nsswitch.conf -> host.conf generator to handle criteria,
continuation lines, extra whitespace, and to use the last matching
line in the file. This syncs the host.conf generation with how
the nsswitch.conf is parsed.
Only print " host.conf" instead of a multi-line message, since this
happens on every boot.
Diffstat (limited to 'etc/rc.d/netoptions')
-rw-r--r-- | etc/rc.d/netoptions | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/etc/rc.d/netoptions b/etc/rc.d/netoptions index 1ca57d5..db56699 100644 --- a/etc/rc.d/netoptions +++ b/etc/rc.d/netoptions @@ -41,8 +41,7 @@ network_pass1() { # Generate host.conf for compatibility # if [ -f "/etc/nsswitch.conf" ]; then - echo '' - echo 'Generating /etc/host.conf for compatibility' + echo -n ' host.conf' generate_host_conf /etc/nsswitch.conf /etc/host.conf fi @@ -880,16 +879,23 @@ BEGIN { xlat["files"] = "hosts"; xlat["dns"] = "bind"; xlat["nis"] = "nis"; + cont = 0; } -/^hosts:/ { - print "# Auto-generated, do not edit"; - for (n = 2; n <= NF; ++n) - if ($n in xlat) - print xlat[$n]; - quit; +sub(/^[\t ]*hosts:/, "") || cont { + if (!cont) + srcs = "" + sub(/#.*/, "") + gsub(/[][]/, " & ") + cont = sub(/\\$/, "") + srcs = srcs " " $0 } -// { - next; +END { + print "# Auto-generated from nsswitch.conf, do not edit" + ns = split(srcs, s) + for (n = 1; n <= ns; ++n) { + if (s[n] in xlat) + print xlat[s[n]] + } } ' <$nsswitch_conf >$host_conf } |