summaryrefslogtreecommitdiff
path: root/etc
diff options
context:
space:
mode:
authorTheo de Raadt <deraadt@cvs.openbsd.org>2011-07-19 13:49:08 +0000
committerTheo de Raadt <deraadt@cvs.openbsd.org>2011-07-19 13:49:08 +0000
commita33d6281c661df04c2f5c1eb228d7621e6fb58b3 (patch)
treebfe52ad55ef2578c4b6dc63bf0c6454a70894316 /etc
parente7c29772cde50e3a8fb06a71ac2ebb1720036384 (diff)
Now that fill_baddynamic() is being called much earlier, it cannot use
grep in a NFS diskless environment. Found and fixed by Hugo Villeneuve
Diffstat (limited to 'etc')
-rw-r--r--etc/rc39
1 files changed, 20 insertions, 19 deletions
diff --git a/etc/rc b/etc/rc
index d203ed8cde0..1b8e57797ef 100644
--- a/etc/rc
+++ b/etc/rc
@@ -1,4 +1,4 @@
-# $OpenBSD: rc,v 1.387 2011/07/18 21:01:23 deraadt Exp $
+# $OpenBSD: rc,v 1.388 2011/07/19 13:49:07 deraadt Exp $
# System startup script run by init on autoboot
# or after single-user.
@@ -120,26 +120,27 @@ fill_baddynamic()
local _sysctl="net.inet.${_service}.baddynamic"
local _name _port _srv _junk _ban
local _i=0
- grep "/${_service}" /etc/services | {
- IFS=" /"
- while read _name _port _srv _junk; do
- [ "x${_srv}" = "x${_service}" ] || continue;
- if [ "x${_ban}" = "x" ]; then
- _ban="+${_port}"
- else
- _ban="${_ban},+${_port}"
- fi
- # Flush before argv gets too long
- if [ $((++_i)) -gt 128 ]; then
- sysctl ${_sysctl}=${_ban} >/dev/null
- _ban=""
- _i=0
- fi
- done;
- if [ "x${_ban}" != "x" ]; then
+ local _ifs="${IFS}"
+ IFS=" /"
+ while read _name _port _srv _junk; do
+ [ "x${_srv}" = "x${_service}" ] && \
+ [ "x${_name}" = "x${_name#\#}" ] || continue;
+ if [ "x${_ban}" = "x" ]; then
+ _ban="+${_port}"
+ else
+ _ban="${_ban},+${_port}"
+ fi
+ # Flush before argv gets too long
+ if [ $((++_i)) -gt 128 ]; then
sysctl ${_sysctl}=${_ban} >/dev/null
+ _ban=""
+ _i=0
fi
- }
+ done < /etc/services;
+ if [ "x${_ban}" != "x" ]; then
+ sysctl ${_sysctl}=${_ban} >/dev/null
+ fi
+ IFS="${_ifs}"
}
start_daemon()