diff options
author | Bill Nottingham <notting@redhat.com> | 2005-06-09 18:46:57 +0000 |
---|---|---|
committer | Bill Nottingham <notting@redhat.com> | 2005-06-09 18:46:57 +0000 |
commit | 60899ae51bf662d92c8effe66ebe263117fd977a (patch) | |
tree | e685fbce6c971c1682201359103ce306c2b20b60 /sysconfig/network-scripts/network-functions | |
parent | ce1e0ad5ced357d270b54cdbec133c516f302dfe (diff) | |
download | initscripts-60899ae51bf662d92c8effe66ebe263117fd977a.tar initscripts-60899ae51bf662d92c8effe66ebe263117fd977a.tar.gz initscripts-60899ae51bf662d92c8effe66ebe263117fd977a.tar.bz2 initscripts-60899ae51bf662d92c8effe66ebe263117fd977a.tar.xz initscripts-60899ae51bf662d92c8effe66ebe263117fd977a.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.
Diffstat (limited to 'sysconfig/network-scripts/network-functions')
-rw-r--r-- | sysconfig/network-scripts/network-functions | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/sysconfig/network-scripts/network-functions b/sysconfig/network-scripts/network-functions index 249f224b..1b51a19a 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 @@ -158,7 +163,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) |