We currently look for the string 'dhcp' in a network-scripts
configuration file, but this could potentially be found in a comment
line.  The variable that controls whether DHCPv4 is used is BOOTPROTO,
so check for that variable name as well as the value 'dhcp'.

Also quote the interface name when constructing the configuration
filename, just in case it contains a special character.

Signed-off-by: Ben Hutchings <b...@debian.org>
---
 tools/hv/hv_get_dhcp_info.sh | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/hv/hv_get_dhcp_info.sh b/tools/hv/hv_get_dhcp_info.sh
index 310b16a2f734..7815d55a9295 100755
--- a/tools/hv/hv_get_dhcp_info.sh
+++ b/tools/hv/hv_get_dhcp_info.sh
@@ -75,10 +75,10 @@ check_ifupdown() {
 }
 
 check_network_scripts() {
-    local if_file="/etc/sysconfig/network-scripts/ifcfg-"$1
+    local if_file="/etc/sysconfig/network-scripts/ifcfg-$1"
 
     if [ -f "$if_file" ]; then
-       grep -q dhcp "$if_file"
+       grep -q '^\s*BOOTPROTO=.*dhcp' "$if_file"
        report
     else
        return 1

Attachment: signature.asc
Description: PGP signature

Reply via email to