Blob Blame History Raw
From db166d40204d854d852880c154ae55a18b6f8acf Mon Sep 17 00:00:00 2001
From: "Richard W.M. Jones" <rjones@redhat.com>
Date: Tue, 28 Feb 2017 15:48:18 +0000
Subject: [PATCH] sysprep: Remove DHCP_HOSTNAME= from ifcfg-* files
 (RHBZ#1427529).

(cherry picked from commit 0f99537cb69c88f7ceb6c69a9d9ae10baaaa3623)
---
 sysprep/sysprep_operation_net_hostname.ml | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/sysprep/sysprep_operation_net_hostname.ml b/sysprep/sysprep_operation_net_hostname.ml
index 3824d42..7284d63 100644
--- a/sysprep/sysprep_operation_net_hostname.ml
+++ b/sysprep/sysprep_operation_net_hostname.ml
@@ -30,10 +30,12 @@ let net_hostname_perform (g : Guestfs.guestfs) root side_effects =
     let filenames = g#glob_expand "/etc/sysconfig/network-scripts/ifcfg-*" in
     Array.iter (
       fun filename ->
-        (* Replace HOSTNAME=... entry. *)
+        (* Remove HOSTNAME=... and DHCP_HOSTNAME=... entries. *)
         let lines = Array.to_list (g#read_lines filename) in
         let lines = List.filter (
-          fun line -> not (String.is_prefix line "HOSTNAME=")
+          fun line ->
+            not (String.is_prefix line "HOSTNAME=") &&
+            not (String.is_prefix line "DHCP_HOSTNAME=")
         ) lines in
         let file = String.concat "\n" lines ^ "\n" in
         g#write filename file;
@@ -46,7 +48,7 @@ let op = {
   defaults with
     name = "net-hostname";
     enabled_by_default = true;
-    heading = s_"Remove HOSTNAME in network interface configuration";
+    heading = s_"Remove HOSTNAME and DHCP_HOSTNAME in network interface configuration";
     pod_description = Some (s_"\
 For Fedora and Red Hat Enterprise Linux,
 this is removed from C<ifcfg-*> files.");
-- 
2.9.4