summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKenneth R Westerback <krw@cvs.openbsd.org>2005-08-29 17:47:56 +0000
committerKenneth R Westerback <krw@cvs.openbsd.org>2005-08-29 17:47:56 +0000
commit7e6986f4c4142360e2e4a81a04e417d105211a39 (patch)
treefd20665fc872a8c2c5235adbb227a93a2f9b70a0
parent2071a81380b25c89aa817b03d057e2004abaf408 (diff)
addhostent() shouldn't delete the hosts entry for the 'other' address
family. Specifying an IPv6 address will no longer remove an IPv4 entry from hosts, nor visa verse. Noted by mickey@. ok deraadt@.
-rw-r--r--distrib/miniroot/install.sub8
1 files changed, 5 insertions, 3 deletions
diff --git a/distrib/miniroot/install.sub b/distrib/miniroot/install.sub
index 5d828af2fa5..3c5ca3f40d9 100644
--- a/distrib/miniroot/install.sub
+++ b/distrib/miniroot/install.sub
@@ -1,4 +1,4 @@
-# $OpenBSD: install.sub,v 1.389 2005/08/09 00:46:12 deraadt Exp $
+# $OpenBSD: install.sub,v 1.390 2005/08/29 17:47:55 krw Exp $
# $NetBSD: install.sub,v 1.5.2.8 1996/09/02 23:25:02 pk Exp $
#
# Copyright (c) 1997-2005 Todd Miller, Theo de Raadt, Ken Westerback
@@ -460,9 +460,11 @@ makedev() {
# $1 - IP address (v6 if it contains ':', else v4)
# $2 - symbolic name
addhostent() {
- local _addr=$1 _name=$2
+ local _addr=$1 _name=$2 _delim="."
- sed "/^[0-9a-fA-F]*[:.].* $_name\$/d" /tmp/hosts >/tmp/hosts.new
+ [[ $_addr == *:* ]] && _delim=":"
+
+ sed "/^[0-9a-fA-F]*[$_delim].* $_name\$/d" /tmp/hosts >/tmp/hosts.new
mv /tmp/hosts.new /tmp/hosts
echo "$_addr $_name" >>/tmp/hosts