|
|
c7c347 |
From 6f8c270b3fb7b5b3109d2553fef38f128b6137ac Mon Sep 17 00:00:00 2001
|
|
|
c7c347 |
From: Laszlo Ersek <lersek@redhat.com>
|
|
|
c7c347 |
Date: Thu, 2 Dec 2021 14:10:06 +0100
|
|
|
c7c347 |
Subject: [PATCH] sysprep: remove system-local NetworkManager connection
|
|
|
c7c347 |
profiles (keyfiles)
|
|
|
c7c347 |
|
|
|
c7c347 |
Add a simple (default) operation to remove
|
|
|
c7c347 |
|
|
|
c7c347 |
/etc/NetworkManager/system-connections/*.nmconnection
|
|
|
c7c347 |
|
|
|
c7c347 |
which arguably carry stale information after the initial creation of the
|
|
|
c7c347 |
system disk image.
|
|
|
c7c347 |
|
|
|
c7c347 |
Note: no side effect callback is invoked. Before commit 576f1541a20c
|
|
|
c7c347 |
("sysprep: Use customize module for customizing the guest after
|
|
|
c7c347 |
sysprepping.", 2014-03-25), the "delete" operation had been native to
|
|
|
c7c347 |
virt-sysprep ("sysprep/sysprep_operation_delete.ml"), and it didn't invoke
|
|
|
c7c347 |
side effects. In said commit, "delete" was delegated to virt-customize,
|
|
|
c7c347 |
and that was when "side_effects#created_file" was introduced (most likely)
|
|
|
c7c347 |
as a catch-all. (We still have the "XXX Did we?" comment today.)
|
|
|
c7c347 |
|
|
|
c7c347 |
Bugzilla: https://bugzilla.redhat.com/show_bug.cgi?id=1980922
|
|
|
c7c347 |
Signed-off-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
c7c347 |
Message-Id: <20211202131006.12774-1-lersek@redhat.com>
|
|
|
c7c347 |
Acked-by: Richard W.M. Jones <rjones@redhat.com>
|
|
|
c7c347 |
(cherry picked from commit 903819ecf480bcefec108bdbd7e9bdec1b3b5a49)
|
|
|
c7c347 |
---
|
|
|
c7c347 |
sysprep/Makefile.am | 1 +
|
|
|
c7c347 |
sysprep/sysprep_operation_net_nmconn.ml | 43 +++++++++++++++++++++++++
|
|
|
c7c347 |
2 files changed, 44 insertions(+)
|
|
|
c7c347 |
create mode 100644 sysprep/sysprep_operation_net_nmconn.ml
|
|
|
c7c347 |
|
|
|
c7c347 |
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
|
|
|
c7c347 |
index d32ab20e..561a71ae 100644
|
|
|
c7c347 |
--- a/sysprep/Makefile.am
|
|
|
c7c347 |
+++ b/sysprep/Makefile.am
|
|
|
c7c347 |
@@ -52,6 +52,7 @@ operations = \
|
|
|
c7c347 |
mail_spool \
|
|
|
c7c347 |
net_hostname \
|
|
|
c7c347 |
net_hwaddr \
|
|
|
c7c347 |
+ net_nmconn \
|
|
|
c7c347 |
pacct_log \
|
|
|
c7c347 |
package_manager_cache \
|
|
|
c7c347 |
pam_data \
|
|
|
c7c347 |
diff --git a/sysprep/sysprep_operation_net_nmconn.ml b/sysprep/sysprep_operation_net_nmconn.ml
|
|
|
c7c347 |
new file mode 100644
|
|
|
c7c347 |
index 00000000..2d8667f1
|
|
|
c7c347 |
--- /dev/null
|
|
|
c7c347 |
+++ b/sysprep/sysprep_operation_net_nmconn.ml
|
|
|
c7c347 |
@@ -0,0 +1,43 @@
|
|
|
c7c347 |
+(* virt-sysprep
|
|
|
c7c347 |
+ * Copyright (C) 2012-2021 Red Hat Inc.
|
|
|
c7c347 |
+ *
|
|
|
c7c347 |
+ * This program is free software; you can redistribute it and/or modify
|
|
|
c7c347 |
+ * it under the terms of the GNU General Public License as published by
|
|
|
c7c347 |
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
c7c347 |
+ * (at your option) any later version.
|
|
|
c7c347 |
+ *
|
|
|
c7c347 |
+ * This program is distributed in the hope that it will be useful,
|
|
|
c7c347 |
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
c7c347 |
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
c7c347 |
+ * GNU General Public License for more details.
|
|
|
c7c347 |
+ *
|
|
|
c7c347 |
+ * You should have received a copy of the GNU General Public License along
|
|
|
c7c347 |
+ * with this program; if not, write to the Free Software Foundation, Inc.,
|
|
|
c7c347 |
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
|
|
c7c347 |
+ *)
|
|
|
c7c347 |
+
|
|
|
c7c347 |
+open Common_gettext.Gettext
|
|
|
c7c347 |
+open Sysprep_operation
|
|
|
c7c347 |
+
|
|
|
c7c347 |
+let glob = "/etc/NetworkManager/system-connections/*.nmconnection"
|
|
|
c7c347 |
+
|
|
|
c7c347 |
+let net_nmconn_perform (g : Guestfs.guestfs) root side_effects =
|
|
|
c7c347 |
+ let typ = g#inspect_get_type root in
|
|
|
c7c347 |
+ let distro = g#inspect_get_distro root in
|
|
|
c7c347 |
+ match typ, distro with
|
|
|
c7c347 |
+ | "linux", ("fedora"|"rhel"|"centos"|"scientificlinux"|"oraclelinux"|
|
|
|
c7c347 |
+ "redhat-based") -> Array.iter g#rm_f (g#glob_expand glob)
|
|
|
c7c347 |
+ | _ -> ()
|
|
|
c7c347 |
+
|
|
|
c7c347 |
+let op = {
|
|
|
c7c347 |
+ defaults with
|
|
|
c7c347 |
+ name = "net-nmconn";
|
|
|
c7c347 |
+ enabled_by_default = true;
|
|
|
c7c347 |
+ heading = s_"Remove system-local NetworkManager connection profiles \
|
|
|
c7c347 |
+ (keyfiles)";
|
|
|
c7c347 |
+ pod_description = Some (s_"On Fedora and Red Hat Enterprise Linux, remove \
|
|
|
c7c347 |
+ the C<" ^ glob ^ "> files.");
|
|
|
c7c347 |
+ perform_on_filesystems = Some net_nmconn_perform;
|
|
|
c7c347 |
+}
|
|
|
c7c347 |
+
|
|
|
c7c347 |
+let () = register_operation op
|
|
|
c7c347 |
--
|
|
|
c7c347 |
2.31.1
|
|
|
c7c347 |
|