mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

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

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