Browse Source

re-add support for $if expansion; hamajima@nagoya.ydc.co.jp

OPENBSD_3_1
deraadt 22 years ago
parent
commit
395e4e2058
1 changed files with 14 additions and 13 deletions
  1. +14
    -13
      src/etc/netstart

+ 14
- 13
src/etc/netstart View File

@ -1,6 +1,6 @@
#!/bin/sh - #!/bin/sh -
# #
# $OpenBSD: netstart,v 1.83 2002/02/21 02:32:01 miod Exp $
# $OpenBSD: netstart,v 1.84 2002/02/23 01:55:24 deraadt Exp $
# Returns true if $1 contains only alphanumerics # Returns true if $1 contains only alphanumerics
isalphanumeric() { isalphanumeric() {
@ -18,13 +18,14 @@ isalphanumeric() {
# Start the $1 interface # Start the $1 interface
ifstart() { ifstart() {
if=$1
# Interface names must be alphanumeric only. We check to avoid # Interface names must be alphanumeric only. We check to avoid
# configuring backup or temp files, and to catch the "*" case. # configuring backup or temp files, and to catch the "*" case.
if ! isalphanumeric "$1"; then
if ! isalphanumeric "$if"; then
return return
fi fi
ifconfig $1 > /dev/null 2>&1
ifconfig $if > /dev/null 2>&1
if [ "$?" != "0" ]; then if [ "$?" != "0" ]; then
return return
fi fi
@ -55,24 +56,24 @@ ifstart() {
cmd="${af#*!} ${name} ${mask} ${bcaddr} ${ext1} ${ext2}" cmd="${af#*!} ${name} ${mask} ${bcaddr} ${ext1} ${ext2}"
;; ;;
"bridge") "bridge")
cmd="echo /etc/hostname.$1: bridges now supported via bridgename.* files"
cmd="echo /etc/hostname.$if: bridges now supported via bridgename.* files"
;; ;;
"dhcp") "dhcp")
[ "$name" = "NONE" ] && name= [ "$name" = "NONE" ] && name=
[ "$mask" = "NONE" ] && mask= [ "$mask" = "NONE" ] && mask=
[ "$bcaddr" = "NONE" ] && bcaddr= [ "$bcaddr" = "NONE" ] && bcaddr=
ifconfig $1 $name $mask $bcaddr $ext1 $ext2 down
cmd="dhclient $1"
ifconfig $if $name $mask $bcaddr $ext1 $ext2 down
cmd="dhclient $if"
;; ;;
"rtsol") "rtsol")
ifconfig $1 $name $mask $bcaddr $ext1 $ext2 up
rtsolif="$rtsolif $1"
ifconfig $if $name $mask $bcaddr $ext1 $ext2 up
rtsolif="$rtsolif $if"
cmd= cmd=
;; ;;
"up") "up")
# The only one of these guaranteed to be set is $1.
# The only one of these guaranteed to be set is $if.
# The remaining ones exist so that media controls work. # The remaining ones exist so that media controls work.
cmd="ifconfig $1 $name $mask $bcaddr $ext1 $ext2 up"
cmd="ifconfig $if $name $mask $bcaddr $ext1 $ext2 up"
;; ;;
*) *)
read dt dtaddr read dt dtaddr
@ -87,7 +88,7 @@ ifstart() {
else else
alias= alias=
fi fi
cmd="ifconfig $1 $af $alias $name "
cmd="ifconfig $if $af $alias $name "
case "$dt" in case "$dt" in
dest) dest)
cmd="$cmd $dtaddr" cmd="$cmd $dtaddr"
@ -97,7 +98,7 @@ ifstart() {
;; ;;
esac esac
if [ ! -n "$name" ]; then if [ ! -n "$name" ]; then
echo "/etc/hostname.$1: invalid network configuration file"
echo "/etc/hostname.$if: invalid network configuration file"
return return
fi fi
case $af in case $af in
@ -119,7 +120,7 @@ ifstart() {
;; ;;
esac esac
eval "$cmd" eval "$cmd"
done < /etc/hostname.$1
done < /etc/hostname.$if
} }
# Start the $1 bridge # Start the $1 bridge


Loading…
Cancel
Save