mrc0mmand / rpms / libguestfs

Forked from rpms/libguestfs 3 years ago
Clone

Blame SOURCES/0073-sysprep-add-Kerberos-keytab-file-removal.patch

5ce0c7
From c8dc0b229b3cbcb72ca90ddf025087586a7d2e38 Mon Sep 17 00:00:00 2001
d60042
From: Pino Toscano <ptoscano@redhat.com>
d60042
Date: Thu, 7 May 2020 14:02:30 +0200
d60042
Subject: [PATCH] sysprep: add Kerberos keytab file removal
d60042
MIME-Version: 1.0
d60042
Content-Type: text/plain; charset=UTF-8
d60042
Content-Transfer-Encoding: 8bit
d60042
d60042
This new operation removes the Kerberos /etc/krb5.keytab file from the
d60042
guest.
d60042
d60042
Thanks to Christian Heimes and François Cami for the hints.
d60042
d60042
Related to RHBZ#1789592.
d60042
d60042
(cherry picked from commit faa5d8507f552e05435312f16d9e50f613a13615)
d60042
---
d60042
 sysprep/Makefile.am                           |  1 +
d60042
 .../sysprep_operation_kerberos_hostkeytab.ml  | 38 +++++++++++++++++++
d60042
 2 files changed, 39 insertions(+)
d60042
 create mode 100644 sysprep/sysprep_operation_kerberos_hostkeytab.ml
d60042
d60042
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
d60042
index 79266314b..a99957306 100644
d60042
--- a/sysprep/Makefile.am
d60042
+++ b/sysprep/Makefile.am
d60042
@@ -45,6 +45,7 @@ operations = \
d60042
 	fs_uuids \
d60042
 	ipa_client \
d60042
 	kerberos_data \
d60042
+	kerberos_hostkeytab \
d60042
 	lvm_uuids \
d60042
 	logfiles \
d60042
 	machine_id \
d60042
diff --git a/sysprep/sysprep_operation_kerberos_hostkeytab.ml b/sysprep/sysprep_operation_kerberos_hostkeytab.ml
d60042
new file mode 100644
d60042
index 000000000..cb3023353
d60042
--- /dev/null
d60042
+++ b/sysprep/sysprep_operation_kerberos_hostkeytab.ml
d60042
@@ -0,0 +1,38 @@
d60042
+(* virt-sysprep
d60042
+ * Copyright (C) 2020 Red Hat Inc.
d60042
+ *
d60042
+ * This program is free software; you can redistribute it and/or modify
d60042
+ * it under the terms of the GNU General Public License as published by
d60042
+ * the Free Software Foundation; either version 2 of the License, or
d60042
+ * (at your option) any later version.
d60042
+ *
d60042
+ * This program is distributed in the hope that it will be useful,
d60042
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
d60042
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d60042
+ * GNU General Public License for more details.
d60042
+ *
d60042
+ * You should have received a copy of the GNU General Public License along
d60042
+ * with this program; if not, write to the Free Software Foundation, Inc.,
d60042
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
d60042
+ *)
d60042
+
d60042
+open Sysprep_operation
d60042
+open Common_gettext.Gettext
d60042
+
d60042
+module G = Guestfs
d60042
+
d60042
+let kerberos_hostkeytab_perform (g : Guestfs.guestfs) root side_effects =
d60042
+  let typ = g#inspect_get_type root in
d60042
+  if typ <> "windows" then (
d60042
+    (try g#rm "/etc/krb5.keytab" with G.Error _ -> ())
d60042
+  )
d60042
+
d60042
+let op = {
d60042
+  defaults with
d60042
+    name = "kerberos-hostkeytab";
d60042
+    enabled_by_default = true;
d60042
+    heading = s_"Remove the Kerberos host keytab file in the guest";
d60042
+    perform_on_filesystems = Some kerberos_hostkeytab_perform;
d60042
+}
d60042
+
d60042
+let () = register_operation op
d60042
-- 
5ce0c7
2.18.4
d60042