[kexec-tools] Rectify the get_host_ip implementation

Baoquan He baoquan at fedoraproject.org
Wed Feb 20 02:34:09 UTC 2013


commit 01bb9af7ed4aab6abc0ae3e18cbc2849f060306d
Author: Baoquan He <bhe at redhat.com>
Date:   Fri Feb 1 15:40:26 2013 +0800

    Rectify the get_host_ip implementation
    
    In previous implementation of get_host_ip, global variable HOST_IP
    is used to be a intermediate variable. In this case, if finally
    failed to get HOST_IP, the original default value is also overwritten.
    It's buggy.
    
    Eg. in ssh case, when faied to get host ip, the default local host ip
    "127.0.0.1" is lost too. that's not expected.
    
    Change it by adding a local variable as intermediate variable.
    
    Signed-off-by: Baoquan He <bhe at redhat.com>
    Acked-by: Dave Young <dyoung at redhat.com>

 dracut-kdump.sh |   10 ++++++----
 1 files changed, 6 insertions(+), 4 deletions(-)
---
diff --git a/dracut-kdump.sh b/dracut-kdump.sh
index d81ebc8..d46e728 100755
--- a/dracut-kdump.sh
+++ b/dracut-kdump.sh
@@ -125,15 +125,17 @@ is_raw_dump_target()
 
 get_host_ip()
 {
+    local _host
     if is_nfs_dump_target || is_ssh_dump_target
     then
         kdumpnic=$(getarg kdumpnic=)
         [ -z "$kdumpnic" ] && echo "failed to get kdumpnic!" && return 1
-        HOST_IP=`ip addr show dev $kdumpnic|grep 'inet '`
+        _host=`ip addr show dev $kdumpnic|grep 'inet '`
         [ $? -ne 0 ] && echo "Wrong kdumpnic: $kdumpnic" && return 1
-        HOST_IP="${HOST_IP##*inet }"
-        HOST_IP="${HOST_IP%%/*}"
-        [ -z "$HOST_IP" ] && echo "Wrong kdumpnic: $kdumpnic" && return 1
+        _host="${_host##*inet }"
+        _host="${_host%%/*}"
+        [ -z "$_host" ] && echo "Wrong kdumpnic: $kdumpnic" && return 1
+        HOST_IP=$_host
     fi
     return 0
 }


More information about the scm-commits mailing list