mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0027-sysprep-Remove-DHCP_HOSTNAME-from-ifcfg-files-RHBZ-1.patch

90a56e
From db166d40204d854d852880c154ae55a18b6f8acf Mon Sep 17 00:00:00 2001
90a56e
From: "Richard W.M. Jones" <rjones@redhat.com>
90a56e
Date: Tue, 28 Feb 2017 15:48:18 +0000
90a56e
Subject: [PATCH] sysprep: Remove DHCP_HOSTNAME= from ifcfg-* files
90a56e
 (RHBZ#1427529).
90a56e
90a56e
(cherry picked from commit 0f99537cb69c88f7ceb6c69a9d9ae10baaaa3623)
90a56e
---
90a56e
 sysprep/sysprep_operation_net_hostname.ml | 8 +++++---
90a56e
 1 file changed, 5 insertions(+), 3 deletions(-)
90a56e
90a56e
diff --git a/sysprep/sysprep_operation_net_hostname.ml b/sysprep/sysprep_operation_net_hostname.ml
46ce2f
index 3824d42ae..7284d630f 100644
90a56e
--- a/sysprep/sysprep_operation_net_hostname.ml
90a56e
+++ b/sysprep/sysprep_operation_net_hostname.ml
90a56e
@@ -30,10 +30,12 @@ let net_hostname_perform (g : Guestfs.guestfs) root side_effects =
90a56e
     let filenames = g#glob_expand "/etc/sysconfig/network-scripts/ifcfg-*" in
90a56e
     Array.iter (
90a56e
       fun filename ->
90a56e
-        (* Replace HOSTNAME=... entry. *)
90a56e
+        (* Remove HOSTNAME=... and DHCP_HOSTNAME=... entries. *)
90a56e
         let lines = Array.to_list (g#read_lines filename) in
90a56e
         let lines = List.filter (
90a56e
-          fun line -> not (String.is_prefix line "HOSTNAME=")
90a56e
+          fun line ->
90a56e
+            not (String.is_prefix line "HOSTNAME=") &&
90a56e
+            not (String.is_prefix line "DHCP_HOSTNAME=")
90a56e
         ) lines in
90a56e
         let file = String.concat "\n" lines ^ "\n" in
90a56e
         g#write filename file;
90a56e
@@ -46,7 +48,7 @@ let op = {
90a56e
   defaults with
90a56e
     name = "net-hostname";
90a56e
     enabled_by_default = true;
90a56e
-    heading = s_"Remove HOSTNAME in network interface configuration";
90a56e
+    heading = s_"Remove HOSTNAME and DHCP_HOSTNAME in network interface configuration";
90a56e
     pod_description = Some (s_"\
90a56e
 For Fedora and Red Hat Enterprise Linux,
90a56e
 this is removed from C<ifcfg-*> files.");
90a56e
-- 
46ce2f
2.13.4
90a56e