diff options
author | Bill Nottingham <notting@redhat.com> | 2005-05-10 18:50:02 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2005-05-10 18:50:02 +0000 |
commit | 9de40c87dd6daa8d1e1727094e12b86406cc7948 (patch) | |
tree | eed3b0e962c746a0d0b8e9acc6053b4f9a4a4e8b | |
parent | b1ecc08916005ea51fef3e90a289f93105ba526e (diff) | |
download | initscripts-9de40c87dd6daa8d1e1727094e12b86406cc7948.tar initscripts-9de40c87dd6daa8d1e1727094e12b86406cc7948.tar.gz initscripts-9de40c87dd6daa8d1e1727094e12b86406cc7948.tar.bz2 initscripts-9de40c87dd6daa8d1e1727094e12b86406cc7948.tar.xz initscripts-9de40c87dd6daa8d1e1727094e12b86406cc7948.zip |
fix grep to always match the full hwaddr, as opposed to matching '0'
against '00:AA:BB:CC:DD:EE'. Take into account lines that end with
spaces, or with "# this is a comment", too. Also, put the grep in only
one place instead of 3. Fixes #157252, #153669.
-rwxr-xr-x | sysconfig/network-scripts/ifdown-eth | 2 | ||||
-rw-r--r-- | sysconfig/network-scripts/network-functions | 9 |
2 files changed, 8 insertions, 3 deletions
diff --git a/sysconfig/network-scripts/ifdown-eth b/sysconfig/network-scripts/ifdown-eth index 3ad86125..b7c1e770 100755 --- a/sysconfig/network-scripts/ifdown-eth +++ b/sysconfig/network-scripts/ifdown-eth @@ -37,7 +37,7 @@ check_device_down ${DEVICE} && [ "$BOOTPROTO" != "dhcp" -a "$BOOTPROTO" != "boot if [ -n "${HWADDR}" -a -z "${MACADDR}" ]; then FOUNDMACADDR=`get_hwaddr ${REALDEVICE}` if [ -n "${FOUNDMACADDR}" -a "${FOUNDMACADDR}" != "${HWADDR}" ]; then - NEWCONFIG=`LANG=C grep -il "^[[:space:]]*HWADDR=${HWADDR}" /etc/sysconfig/network-scripts/ifcfg-*` + NEWCONFIG=`get_config_by_hwaddr ${FOUNDMACADDR}` if [ -n "${NEWCONFIG}" -a "${NEWCONFIG##*/}" != "${CONFIG##*/}" ]; then exec /sbin/ifdown ${NEWCONFIG} else diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index e937afc2..7867dd4d 100644 --- a/sysconfig/network-scripts/network-functions +++ b/sysconfig/network-scripts/network-functions @@ -14,6 +14,11 @@ get_hwaddr () awk '{ print toupper($0) }' } +get_config_by_hwaddr () +{ + LANG=C grep -il "^[[:space:]]*HWADDR=${1}\([[:space:]]\+\|#\+\|$\)" /etc/sysconfig/network-scripts/ifcfg-* +} + need_config () { CONFIG="ifcfg-${1}" @@ -22,7 +27,7 @@ need_config () [ -f "${CONFIG}" ] && return local addr=`get_hwaddr ${1}` if [ -n "$addr" ]; then - local nconfig=`LANG=C grep -il "^[[:space:]]*HWADDR=$addr" /etc/sysconfig/network-scripts/ifcfg-*` + local nconfig=`get_config_by_hwaddr ${addr}` if [ -n "$nconfig" ] ; then CONFIG=$nconfig [ -f "${CONFIG}" ] && return @@ -155,7 +160,7 @@ rename_device() { /sbin/nameif "$1" "$2" || { local hw2=`get_hwaddr ${1}` - local nconfig=`LANG=C grep -il "^[[:space:]]*HWADDR=$hw2" /etc/sysconfig/network-scripts/ifcfg-*` + local nconfig=`get_config_by_hwaddr ${hw2}` local dev= if [ -n "$nconfig" ]; then dev=$(. $nconfig ; echo $DEVICE) |