From 5f5f051f7e1ee40cae98749b313b6624415243e2 Mon Sep 17 00:00:00 2001 From: des Date: Thu, 1 Nov 2001 12:39:01 +0000 Subject: Modify the way host.conf and nsswitch.conf are treated at boot time: - if nsswitch.conf exists, host.conf is auto-generated for compatibility with legacy applications and libraries. - if host.conf exists but nsswitch.conf does not, nsswitch.conf is auto- generated as usual. --- etc/network.subr | 41 ++++++++++++++++++++++++++++++++++------- etc/rc.d/netoptions | 41 ++++++++++++++++++++++++++++++++++------- etc/rc.d/network1 | 41 ++++++++++++++++++++++++++++++++++------- etc/rc.d/network2 | 41 ++++++++++++++++++++++++++++++++++------- etc/rc.d/network3 | 41 ++++++++++++++++++++++++++++++++++------- etc/rc.d/routing | 41 ++++++++++++++++++++++++++++++++++------- etc/rc.network | 41 ++++++++++++++++++++++++++++++++++------- 7 files changed, 238 insertions(+), 49 deletions(-) diff --git a/etc/network.subr b/etc/network.subr index 1f50bea..1ca57d5 100644 --- a/etc/network.subr +++ b/etc/network.subr @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} diff --git a/etc/rc.d/netoptions b/etc/rc.d/netoptions index 1f50bea..1ca57d5 100644 --- a/etc/rc.d/netoptions +++ b/etc/rc.d/netoptions @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} diff --git a/etc/rc.d/network1 b/etc/rc.d/network1 index 1f50bea..1ca57d5 100644 --- a/etc/rc.d/network1 +++ b/etc/rc.d/network1 @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} diff --git a/etc/rc.d/network2 b/etc/rc.d/network2 index 1f50bea..1ca57d5 100644 --- a/etc/rc.d/network2 +++ b/etc/rc.d/network2 @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} diff --git a/etc/rc.d/network3 b/etc/rc.d/network3 index 1f50bea..1ca57d5 100644 --- a/etc/rc.d/network3 +++ b/etc/rc.d/network3 @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} diff --git a/etc/rc.d/routing b/etc/rc.d/routing index 1f50bea..1ca57d5 100644 --- a/etc/rc.d/routing +++ b/etc/rc.d/routing @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} diff --git a/etc/rc.network b/etc/rc.network index 1f50bea..1ca57d5 100644 --- a/etc/rc.network +++ b/etc/rc.network @@ -38,16 +38,21 @@ network_pass1() { echo -n 'Doing initial network setup:' + # Generate host.conf for compatibility + # + if [ -f "/etc/nsswitch.conf" ]; then + echo '' + echo 'Generating /etc/host.conf for compatibility' + generate_host_conf /etc/nsswitch.conf /etc/host.conf + fi + # Convert host.conf to nsswitch.conf if necessary - if [ -f "/etc/host.conf" ]; then + # + if [ -f "/etc/host.conf" -a ! -f "/etc/nsswitch.conf" ]; then echo '' echo 'Warning: /etc/host.conf is no longer used' - if [ -f "/etc/nsswitch.conf" ]; then - echo ' /etc/nsswitch.conf will be used instead' - else - echo ' /etc/nsswitch.conf will be created for you' - convert_host_conf /etc/host.conf /etc/nsswitch.conf - fi + echo ' /etc/nsswitch.conf will be created for you' + convert_host_conf /etc/host.conf /etc/nsswitch.conf fi # Set the host name if it is not already set @@ -866,3 +871,25 @@ convert_host_conf() { }' < $host_conf > $nsswitch_conf } +generate_host_conf() { + nsswitch_conf=$1; shift; + host_conf=$1; shift; + + awk ' +BEGIN { + xlat["files"] = "hosts"; + xlat["dns"] = "bind"; + xlat["nis"] = "nis"; +} +/^hosts:/ { + print "# Auto-generated, do not edit"; + for (n = 2; n <= NF; ++n) + if ($n in xlat) + print xlat[$n]; + quit; +} +// { + next; +} +' <$nsswitch_conf >$host_conf +} -- cgit v1.1