Source-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[src/trunk]: src/etc add a dotted alias for localhost so that sendmail doesn'...



details:   https://anonhg.NetBSD.org/src/rev/c69640a2446b
branches:  trunk
changeset: 569679:c69640a2446b
user:      chs <chs%NetBSD.org@localhost>
date:      Sun Aug 29 13:26:17 2004 +0000

description:
add a dotted alias for localhost so that sendmail doesn't pause on startup
if a system's hostname is not set.  PR 26550.

diffstat:

 etc/hosts       |   6 +++---
 etc/postinstall |  45 ++++++++++++++++++++++++++++++++++++++++++++-
 2 files changed, 47 insertions(+), 4 deletions(-)

diffs (81 lines):

diff -r bb98baabb8cf -r c69640a2446b etc/hosts
--- a/etc/hosts Sun Aug 29 10:13:48 2004 +0000
+++ b/etc/hosts Sun Aug 29 13:26:17 2004 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: hosts,v 1.6 2000/08/15 09:33:05 itojun Exp $
+#      $NetBSD: hosts,v 1.7 2004/08/29 13:26:17 chs Exp $
 #
 # Host Database
 # This file should contain the addresses and aliases
@@ -7,8 +7,8 @@
 # before the nameserver is started.
 #
 #
-::1                    localhost
-127.0.0.1              localhost
+::1                    localhost localhost.
+127.0.0.1              localhost localhost.
 #
 # RFC 1918 specifies that these networks are "internal".
 # 10.0.0.0     10.255.255.255
diff -r bb98baabb8cf -r c69640a2446b etc/postinstall
--- a/etc/postinstall   Sun Aug 29 10:13:48 2004 +0000
+++ b/etc/postinstall   Sun Aug 29 13:26:17 2004 +0000
@@ -1,6 +1,6 @@
 #!/bin/sh
 #
-# $NetBSD: postinstall,v 1.80 2004/08/12 13:32:37 lukem Exp $
+# $NetBSD: postinstall,v 1.81 2004/08/29 13:26:17 chs Exp $
 #
 # Copyright (c) 2002-2004 The NetBSD Foundation, Inc.
 # All rights reserved.
@@ -995,6 +995,49 @@
        return ${failed}
 }
 
+#
+#      hosts
+#
+additem hosts "/etc/hosts being up to date"
+do_hosts()
+{
+       [ -n "$1" ] || err 2 "USAGE: do_hosts  fix|check"
+       op=$1
+
+       failed=0
+       h=${DEST_DIR}/hosts
+       if ! grep ^127 $h | sed 's/^[^  ]*//' | grep '\.' > /dev/null; then
+               msg "/etc/hosts entry for localhost (ipv4) missing dotted alias"
+
+               if [ "${op}" = "fix" ]; then
+                       if ! sed 's/^\(127.*\)$/\1 localhost./' < $h \
+                           > ${SCRATCHDIR}/hosts ||
+                           ! mv ${SCRATCHDIR}/hosts $h; then
+                               msg "Can't update /etc/hosts"
+                               failed=1
+                       fi
+               else
+                       failed=1
+               fi
+       fi
+       if ! grep ^::1 $h | sed 's/^[^  ]*//' | grep '\.' > /dev/null; then
+               msg "/etc/hosts entry for localhost (ipv6) missing dotted alias"
+
+               if [ "${op}" = "fix" ]; then
+                       if ! sed 's/^\(::1.*\)$/\1 localhost./' < $h \
+                           > ${SCRATCHDIR}/hosts ||
+                           ! mv ${SCRATCHDIR}/hosts $h; then
+                               msg "Can't update /etc/hosts"
+                               failed=1
+                       fi
+               else
+                       failed=1
+               fi
+       fi
+
+       return ${failed}
+}
+
 
 #
 #      end of items



Home | Main Index | Thread Index | Old Index