diff options
author | Wanlong Gao <gaowanlong@cn.fujitsu.com> | 2012-04-12 16:27:16 +0800 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2012-04-12 09:38:35 +0100 |
commit | 6c276606d7cd124b2a0fcf50526bfa89142144d5 (patch) | |
tree | e005e264ca70c185104afb7920cf50a873246a3d /sysprep | |
parent | ed2a06708ce2527256581abc44ce2e0edaaa3147 (diff) | |
download | libguestfs-6c276606d7cd124b2a0fcf50526bfa89142144d5.tar.gz libguestfs-6c276606d7cd124b2a0fcf50526bfa89142144d5.tar.xz libguestfs-6c276606d7cd124b2a0fcf50526bfa89142144d5.zip |
sysprep: remove the bash history of users
Remove the bash history of users in home directory,
and history of root.
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com>
Diffstat (limited to 'sysprep')
-rw-r--r-- | sysprep/Makefile.am | 2 | ||||
-rw-r--r-- | sysprep/sysprep_operation_bash_history.ml | 46 |
2 files changed, 48 insertions, 0 deletions
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index 8730bc0c..3a487023 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -33,6 +33,7 @@ SOURCES = \ main.ml \ sysprep_operation.ml \ sysprep_operation.mli \ + sysprep_operation_bash_history.ml \ sysprep_operation_cron_spool.ml \ sysprep_operation_dhcp_client_state.ml \ sysprep_operation_dhcp_server_state.ml \ @@ -56,6 +57,7 @@ if HAVE_OCAML OBJECTS = \ utils.cmx \ sysprep_operation.cmx \ + sysprep_operation_bash_history.cmx \ sysprep_operation_cron_spool.cmx \ sysprep_operation_dhcp_client_state.cmx \ sysprep_operation_dhcp_server_state.cmx \ diff --git a/sysprep/sysprep_operation_bash_history.ml b/sysprep/sysprep_operation_bash_history.ml new file mode 100644 index 00000000..891c1377 --- /dev/null +++ b/sysprep/sysprep_operation_bash_history.ml @@ -0,0 +1,46 @@ +(* virt-sysprep + * Copyright (C) 2012 Fujitsu Inc. + * + * 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 + +module G = Guestfs + +let bash_history_perform g root = + let typ = g#inspect_get_type root in + if typ <> "windows" then ( + let files = g#glob_expand "/home/*/.bash_history" in + Array.iter ( + fun file -> try g#rm file with G.Error _ -> (); + ) files; + (try g#rm "/root/.bash_history" with G.Error _ -> ()); + [] + ) + else [] + +let bash_history_op = { + name = "bash-history"; + pod_description = "\ +Remove the bash history in the guest. + +Remove the bash history of user \"root\" and any other users +who have a C<.bash_history> file in their home directory."; + extra_args = []; + perform = bash_history_perform; +} + +let () = register_operation bash_history_op |