aboutsummaryrefslogtreecommitdiff
path: root/etc/rc.d/network3
diff options
context:
space:
mode:
authorJacques Vidrine <nectar@FreeBSD.org>2000-09-06 18:16:48 +0000
committerJacques Vidrine <nectar@FreeBSD.org>2000-09-06 18:16:48 +0000
commit248aee623cc3e95cadc710fe1668269b841e171b (patch)
treeb144d034dc9f7c786d7dfcedd59cee6c9a125418 /etc/rc.d/network3
parent57a12c8e24b4d67ccc12561633419985ab64985d (diff)
downloadsrc-248aee623cc3e95cadc710fe1668269b841e171b.tar.gz
src-248aee623cc3e95cadc710fe1668269b841e171b.zip
Add nsswitch support. By creating an /etc/nsswitch.conf file, you can
configure FreeBSD so that various databases such as passwd and group can be looked up using flat files, NIS, or Hesiod. = Hesiod has been added to libc (see hesiod(3)). = A library routine for parsing nsswitch.conf and invoking callback functions as specified has been added to libc (see nsdispatch(3)). = The following C library functions have been modified to use nsdispatch: . getgrent, getgrnam, getgrgid . getpwent, getpwnam, getpwuid . getusershell . getaddrinfo . gethostbyname, gethostbyname2, gethostbyaddr . getnetbyname, getnetbyaddr . getipnodebyname, getipnodebyaddr, getnodebyname, getnodebyaddr = host.conf has been removed from src/etc. rc.network has been modified to warn that host.conf is no longer used at boot time. In addition, if there is a host.conf but no nsswitch.conf, the latter is created at boot time from the former. Obtained from: NetBSD
Notes
Notes: svn path=/head/; revision=65532
Diffstat (limited to 'etc/rc.d/network3')
-rw-r--r--etc/rc.d/network329
1 files changed, 29 insertions, 0 deletions
diff --git a/etc/rc.d/network3 b/etc/rc.d/network3
index 51e02cd0787c..168f3bda209b 100644
--- a/etc/rc.d/network3
+++ b/etc/rc.d/network3
@@ -13,6 +13,18 @@
network_pass1() {
echo -n 'Doing initial network setup:'
+ # Convert host.conf to nsswitch.conf if necessary
+ if [ -f "/etc/host.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
+ fi
+
# Set the host name if it is not already set
#
if [ -z "`hostname -s`" ]; then
@@ -681,3 +693,20 @@ network_pass4() {
echo '.'
network_pass4_done=YES
}
+
+convert_host_conf() {
+ host_conf=$1; shift;
+ nsswitch_conf=$1; shift;
+ awk ' \
+ /^[:blank:]*#/ { next } \
+ /(hosts|local|file)/ { nsswitch[c] = "files"; c++; next } \
+ /(dns|bind)/ { nsswitch[c] = "dns"; c++; next } \
+ /nis/ { nsswitch[c] = "nis"; c++; next } \
+ { printf "Warning: unrecognized line [%s]", $0 > "/dev/stderr" } \
+ END { \
+ printf "hosts: "; \
+ for (i in nsswitch) printf "%s ", nsswitch[i]; \
+ printf "\n"; \
+ }' < $host_conf > $nsswitch_conf
+}
+