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

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