On Fri, May 18, 2012 at 05:20:04PM +0800, Wanlong Gao wrote:
Remove the generated kerberos data in the guest.
Signed-off-by: Wanlong Gao <gaowanlong(a)cn.fujitsu.com>
---
sysprep/Makefile.am | 2 ++
sysprep/sysprep_operation_kerberos_data.ml | 52 ++++++++++++++++++++++++++++
2 files changed, 54 insertions(+)
create mode 100644 sysprep/sysprep_operation_kerberos_data.ml
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am
index d24ce13..4f49ad3 100644
--- a/sysprep/Makefile.am
+++ b/sysprep/Makefile.am
@@ -43,6 +43,7 @@ SOURCES = \
sysprep_operation_dovecot_data.ml \
sysprep_operation_flag_reconfiguration.ml \
sysprep_operation_hostname.ml \
+ sysprep_operation_kerberos_data.ml \
sysprep_operation_logfiles.ml \
sysprep_operation_mail_spool.ml \
sysprep_operation_net_hwaddr.ml \
@@ -79,6 +80,7 @@ OBJECTS = \
sysprep_operation_dovecot_data.cmx \
sysprep_operation_flag_reconfiguration.cmx \
sysprep_operation_hostname.cmx \
+ sysprep_operation_kerberos_data.cmx \
sysprep_operation_logfiles.cmx \
sysprep_operation_mail_spool.cmx \
sysprep_operation_net_hwaddr.cmx \
diff --git a/sysprep/sysprep_operation_kerberos_data.ml
b/sysprep/sysprep_operation_kerberos_data.ml
new file mode 100644
index 0000000..911b9e9
--- /dev/null
+++ b/sysprep/sysprep_operation_kerberos_data.ml
@@ -0,0 +1,52 @@
+(* virt-sysprep
+ * Copyright (C) 2012 FUJITSU LIMITED
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *)
+
+open Sysprep_operation
+open Sysprep_gettext.Gettext
+
+module StringSet = Set.Make (String)
+module G = Guestfs
+
+let kerberos_data_perform g root =
+ let typ = g#inspect_get_type root in
+ if typ <> "windows" then (
+ let excepts = [ "/var/kerberos/krb5kdc/kadm5.acl";
+ "/var/kerberos/krb5kdc/kdc.conf"; ] in
+ let paths = Array.to_list (g#glob_expand "/var/kerberos/krb5kdc/*") in
+ let set = List.fold_right StringSet.add paths StringSet.empty in
+ let excepts = List.fold_right StringSet.add excepts StringSet.empty in
+ let set = StringSet.diff set excepts in
+ StringSet.iter (
+ fun filename ->
+ try g#rm filename with G.Error _ -> ()
+ ) set;
+
+ []
+ )
+ else []
+
+let kerberos_data_op = {
+ name = "kerberos-data";
+ enabled_by_default = false;
+ heading = s_"Remove Kerberos data in the guest";
+ pod_description = None;
+ extra_args = [];
+ perform = kerberos_data_perform;
+}
+
+let () = register_operation kerberos_data_op
--
1.7.10
ACK.
Rich.
--
Richard Jones, Virtualization Group, Red Hat
http://people.redhat.com/~rjones
virt-df lists disk usage of guests without needing to install any
software inside the virtual machine. Supports Linux and Windows.
http://et.redhat.com/~rjones/virt-df/