[PATCH 1/5] sysprep: remove tmp files
This removes tmp files under /tmp and /var/tmp. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- sysprep/Makefile.am | 1 + sysprep/sysprep_operation_tmp_files.ml | 52 ++++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 sysprep/sysprep_operation_tmp_files.ml diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index fcd17fc..b89345a 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -65,6 +65,7 @@ operations = \ ssh_hostkeys \ ssh_userdir \ sssd_db_log \ + tmp_files \ udev_persistent_net \ user_account \ utmp yum_uuid diff --git a/sysprep/sysprep_operation_tmp_files.ml b/sysprep/sysprep_operation_tmp_files.ml new file mode 100644 index 0000000..a2187df --- /dev/null +++ b/sysprep/sysprep_operation_tmp_files.ml @@ -0,0 +1,52 @@ +(* virt-sysprep + * Copyright (C) 2013 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 Common_gettext.Gettext + +module G = Guestfs + +let tmp_files_perform g root = + let typ = g#inspect_get_type root in + if typ <> "windows" then ( + let paths = [ "/tmp/*"; + "/var/tmp/*"; ] in + List.iter ( + fun path -> + let files = g#glob_expand path in + Array.iter ( + fun file -> + g#rm_rf file; + ) files; + ) paths; + + [] + ) + else [] + +let op = { + defaults with + name = "tmp-files"; + enabled_by_default = true; + heading = s_"Remove the tmp files"; + pod_description = Some (s_"\ +This removes the temporary files under C</tmp> and C</var/tmp>."); + perform_on_filesystems = Some tmp_files_perform; +} + +let () = register_operation op -- 1.8.4.27.g0a41de8
This remove the NFS settings by removing /etc/export. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- sysprep/Makefile.am | 1 + sysprep/sysprep_operation_nfs_setting.ml | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 sysprep/sysprep_operation_nfs_setting.ml diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index b89345a..9894baf 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -51,6 +51,7 @@ operations = \ mail_spool \ net_hostname \ net_hwaddr \ + nfs_setting \ pacct_log \ package_manager_cache \ pam_data \ diff --git a/sysprep/sysprep_operation_nfs_setting.ml b/sysprep/sysprep_operation_nfs_setting.ml new file mode 100644 index 0000000..6d74cba --- /dev/null +++ b/sysprep/sysprep_operation_nfs_setting.ml @@ -0,0 +1,43 @@ +(* virt-sysprep + * Copyright (C) 2013 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 Common_gettext.Gettext + +module G = Guestfs + +let nfs_setting_perform g root = + let typ = g#inspect_get_type root in + if typ <> "windows" then ( + let path = "/etc/export" in + (try g#rm path with G.Error _ -> ()); + [] + ) + else [] + +let op = { + defaults with + name = "NFS-setting"; + enabled_by_default = false; + heading = s_"Remove the NFS settings"; + pod_description = Some (s_"\ +This removes the NFS settings by removing C</etc/export>."); + perform_on_filesystems = Some nfs_setting_perform; +} + +let () = register_operation op -- 1.8.4.27.g0a41de8
On Fri, Sep 06, 2013 at 03:52:39PM +0800, Wanlong Gao wrote:
This remove the NFS settings by removing /etc/export.
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- sysprep/Makefile.am | 1 + sysprep/sysprep_operation_nfs_setting.ml | 43 ++++++++++++++++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 sysprep/sysprep_operation_nfs_setting.ml
diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index b89345a..9894baf 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -51,6 +51,7 @@ operations = \ mail_spool \ net_hostname \ net_hwaddr \ + nfs_setting \
This needs to be called 'nfs_settings' and ...
+ name = "NFS-setting";
this should be "nfs-settings". 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://people.redhat.com/~rjones/virt-df/
This removes the custom kdump configurations by emptying the configuration file /etc/kdump.conf. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- sysprep/Makefile.am | 1 + sysprep/sysprep_operation_kdump_config.ml | 44 +++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+) create mode 100644 sysprep/sysprep_operation_kdump_config.ml diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index 9894baf..eb372aa 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -44,6 +44,7 @@ operations = \ firstboot \ fs_uuids \ hostname \ + kdump_config \ kerberos_data \ lvm_uuids \ logfiles \ diff --git a/sysprep/sysprep_operation_kdump_config.ml b/sysprep/sysprep_operation_kdump_config.ml new file mode 100644 index 0000000..358f97d --- /dev/null +++ b/sysprep/sysprep_operation_kdump_config.ml @@ -0,0 +1,44 @@ +(* virt-sysprep + * Copyright (C) 2013 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 Common_gettext.Gettext + +module G = Guestfs + +let kdump_config_perform g root = + let typ = g#inspect_get_type root in + if typ <> "windows" then ( + let path = "/etc/kdump.conf" in + (try g#rm path with G.Error _ -> ()); + (try g#touch path with G.Error _ -> ()); + [ `Created_files ] + ) + else [] + +let op = { + defaults with + name = "kdump-config"; + enabled_by_default = false; + heading = s_"Remove the kdump configurations"; + pod_description = Some (s_"\ +This removes the kdump configurations by emptying C</etc/kdump.conf>."); + perform_on_filesystems = Some kdump_config_perform; +} + +let () = register_operation op -- 1.8.4.27.g0a41de8
On Fri, Sep 06, 2013 at 03:52:40PM +0800, Wanlong Gao wrote:
+ kdump_config \
Better to call this one just "kdump" ? However I'm unclear why anyone would want to remove kdump config in a sysprep operation. Or TCP wrappers for that matter. There seems to be no useful point in having virt-sysprep start to remove random config files. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
On 09/06/2013 04:06 PM, Richard W.M. Jones wrote:
On Fri, Sep 06, 2013 at 03:52:40PM +0800, Wanlong Gao wrote:
+ kdump_config \
Better to call this one just "kdump" ?
However I'm unclear why anyone would want to remove kdump config in a sysprep operation. Or TCP wrappers for that matter. There seems to be no useful point in having virt-sysprep start to remove random config files.
Thought that these are most important and useful config files in a VM. Below is quoted from whom gave me these requirement: " Motivation virt-sysprep command is simple and useful command for deploying VMs. So, we hope its enchance. Though we know guestfish can be used for removing these files too, (by writing script, etc) currently it is not good for normal users by the following reasons. guestfish cannot handle errors appropriately. - When user uses interactive mode of guestfish, it may abort when error occurs. - When user uses batch mode of it, it may ignore error. - Its error message is too noisy (ex, when the specified file is not present.) " Thanks, Wanlong Gao
Rich.
On Fri, Sep 06, 2013 at 04:25:07PM +0800, Wanlong Gao wrote:
On 09/06/2013 04:06 PM, Richard W.M. Jones wrote:
On Fri, Sep 06, 2013 at 03:52:40PM +0800, Wanlong Gao wrote:
+ kdump_config \
Better to call this one just "kdump" ?
However I'm unclear why anyone would want to remove kdump config in a sysprep operation. Or TCP wrappers for that matter. There seems to be no useful point in having virt-sysprep start to remove random config files.
Thought that these are most important and useful config files in a VM. Below is quoted from whom gave me these requirement: " Motivation virt-sysprep command is simple and useful command for deploying VMs. So, we hope its enchance.
Though we know guestfish can be used for removing these files too, (by writing script, etc) currently it is not good for normal users by the following reasons.
guestfish cannot handle errors appropriately. - When user uses interactive mode of guestfish, it may abort when error occurs. - When user uses batch mode of it, it may ignore error. - Its error message is too noisy (ex, when the specified file is not present.) "
How about the 'virt-sysprep --script' parameter? http://libguestfs.org/virt-sysprep.1.html#script%2d Although this uses FUSE, which is also less than ideal, it is well-tested and the error behaviour is under user control. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
On 09/06/2013 05:23 PM, Richard W.M. Jones wrote:
On Fri, Sep 06, 2013 at 04:25:07PM +0800, Wanlong Gao wrote:
On 09/06/2013 04:06 PM, Richard W.M. Jones wrote:
On Fri, Sep 06, 2013 at 03:52:40PM +0800, Wanlong Gao wrote:
+ kdump_config \
Better to call this one just "kdump" ?
However I'm unclear why anyone would want to remove kdump config in a sysprep operation. Or TCP wrappers for that matter. There seems to be no useful point in having virt-sysprep start to remove random config files.
Thought that these are most important and useful config files in a VM. Below is quoted from whom gave me these requirement: " Motivation virt-sysprep command is simple and useful command for deploying VMs. So, we hope its enchance.
Though we know guestfish can be used for removing these files too, (by writing script, etc) currently it is not good for normal users by the following reasons.
guestfish cannot handle errors appropriately. - When user uses interactive mode of guestfish, it may abort when error occurs. - When user uses batch mode of it, it may ignore error. - Its error message is too noisy (ex, when the specified file is not present.) "
How about the 'virt-sysprep --script' parameter?
http://libguestfs.org/virt-sysprep.1.html#script%2d
Although this uses FUSE, which is also less than ideal, it is well-tested and the error behaviour is under user control.
Yes, sure. Then can you give some comments about following TODO list? For which is necessary to add for users and which is not? Although we know almost all of the features we have in sysprep can be done by "--script" feature, right? " add features to remove the following files or values if user required. B-1) Data files which are made by iscsi initiator. /var/lib/iscsi/* B-2) Definition files of iscsi target emulator. /etc/tgt/* B-3) Definition files of iptables /etc/sysconfig/iptables B-4) Definition of TCP Wrapper /etc/hosts.* B-5) Definition for hostname/DNS. /etc/resolv.conf /etc/hosts B-6) Definition of network routing /etc/sysconfig/network-scripts/route-* /etc/sysconfig/network-scripts/rule-* B-7) Temporary files /tmp/* /var/tmp/* B-8) kdump setting file /etc/kdump.conf B-9) NFS setting. /etc/exports B-10) Remove all files/directories under a directory which is specified by new virt-sysprep option (User may want to each directories depends on thier circumstance.) B-9) Remove or initialize value which is related specified users/groups. User can select a) or b) a) Remove specified users/groups - Remove definition for them from /etc/passwd and /etc/groups - Remove their home directories. (Don't remove the files /etc/passwd /etc/groups.) b) Initialize normal users/groups password Note: Original requirement is to remove/initaliaze all of normal UID/GID user's setting. But the definition of normal user is a bit confusable. RHEL6 : UID is 500 or more, RHEL7 : 1000 or more In addition, nfsnobody uses 65534. So, specifing concrete UID/GID by command option is desirable. For example, "--uid=500,5021000-60000" " Thanks, Wanlong Gao
Rich.
On Mon, Sep 09, 2013 at 04:09:14PM +0800, Wanlong Gao wrote:
Yes, sure. Then can you give some comments about following TODO list? For which is necessary to add for users and which is not? Although we know almost all of the features we have in sysprep can be done by "--script" feature, right?
" add features to remove the following files or values if user required.
B-1) Data files which are made by iscsi initiator. /var/lib/iscsi/*
Some of this is configuration apparently; ie. it is set up by the iscsiadm utility.
B-2) Definition files of iscsi target emulator. /etc/tgt/*
Configuration?
B-3) Definition files of iptables /etc/sysconfig/iptables
Although we added this already, I'm inclined to think it is configuration, not temporary data.
B-4) Definition of TCP Wrapper /etc/hosts.*
Configuration.
B-5) Definition for hostname/DNS. /etc/resolv.conf /etc/hosts
/etc/resolv.conf could be removed, definitely on guests which use dhcp, if there is a way to tell if a guest uses dhcp. /etc/hosts seems like configuration to me.
B-6) Definition of network routing /etc/sysconfig/network-scripts/route-* /etc/sysconfig/network-scripts/rule-*
Don't really know enough to comment on this.
B-7) Temporary files /tmp/* /var/tmp/*
Yes, it was good to remove this.
B-8) kdump setting file /etc/kdump.conf
B-9) NFS setting. /etc/exports
No.
B-10) Remove all files/directories under a directory which is specified by new virt-sysprep option
(User may want to each directories depends on thier circumstance.)
Yes, good idea. User should specify a wildcard / list of wildcards.
B-9) Remove or initialize value which is related specified users/groups.
User can select a) or b) a) Remove specified users/groups
- Remove definition for them from /etc/passwd and /etc/groups - Remove their home directories.
(Don't remove the files /etc/passwd /etc/groups.)
Yes -- already done ('user-account').
b) Initialize normal users/groups password
Note: Original requirement is to remove/initaliaze all of normal UID/GID user's setting.
But the definition of normal user is a bit confusable. RHEL6 : UID is 500 or more, RHEL7 : 1000 or more In addition, nfsnobody uses 65534.
So, specifing concrete UID/GID by command option is desirable. For example, "--uid=500,5021000-60000"
Unclear. ------ I think a better way to think about this: Suppose someone wants to use virt-sysprep to get back to the original configuration of the guest at installation. Wouldn't it be better (cleaner, safer) for them to install a new guest from scratch? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-top is 'top' for virtual machines. Tiny program with many powerful monitoring features, net stats, disk stats, logging, etc. http://people.redhat.com/~rjones/virt-top
On 09/09/2013 04:52 PM, Richard W.M. Jones wrote:
On Mon, Sep 09, 2013 at 04:09:14PM +0800, Wanlong Gao wrote:
Yes, sure. Then can you give some comments about following TODO list? For which is necessary to add for users and which is not? Although we know almost all of the features we have in sysprep can be done by "--script" feature, right?
" add features to remove the following files or values if user required.
B-1) Data files which are made by iscsi initiator. /var/lib/iscsi/*
Some of this is configuration apparently; ie. it is set up by the iscsiadm utility.
B-2) Definition files of iscsi target emulator. /etc/tgt/*
Configuration?
B-3) Definition files of iptables /etc/sysconfig/iptables
Although we added this already, I'm inclined to think it is configuration, not temporary data.
B-4) Definition of TCP Wrapper /etc/hosts.*
Configuration.
B-5) Definition for hostname/DNS. /etc/resolv.conf /etc/hosts
/etc/resolv.conf could be removed, definitely on guests which use dhcp, if there is a way to tell if a guest uses dhcp.
/etc/hosts seems like configuration to me.
B-6) Definition of network routing /etc/sysconfig/network-scripts/route-* /etc/sysconfig/network-scripts/rule-*
Don't really know enough to comment on this.
B-7) Temporary files /tmp/* /var/tmp/*
Yes, it was good to remove this.
B-8) kdump setting file /etc/kdump.conf
B-9) NFS setting. /etc/exports
No.
B-10) Remove all files/directories under a directory which is specified by new virt-sysprep option
(User may want to each directories depends on thier circumstance.)
Yes, good idea. User should specify a wildcard / list of wildcards.
B-9) Remove or initialize value which is related specified users/groups.
User can select a) or b) a) Remove specified users/groups
- Remove definition for them from /etc/passwd and /etc/groups - Remove their home directories.
(Don't remove the files /etc/passwd /etc/groups.)
Yes -- already done ('user-account').
b) Initialize normal users/groups password
Note: Original requirement is to remove/initaliaze all of normal UID/GID user's setting.
But the definition of normal user is a bit confusable. RHEL6 : UID is 500 or more, RHEL7 : 1000 or more In addition, nfsnobody uses 65534.
So, specifing concrete UID/GID by command option is desirable. For example, "--uid=500,5021000-60000"
Unclear.
------
I think a better way to think about this: Suppose someone wants to use virt-sysprep to get back to the original configuration of the guest at installation. Wouldn't it be better (cleaner, safer) for them to install a new guest from scratch?
Hi Rich, According to our discussion, we thought that these configurations are necessary to be removed or reinitialized, that all caused by security reasons. For example, if we are providing user A a cloud environment GuestA, then we want to clone this environment to user B. We should give user B a clean guest, but these configurations may include some secure information of user A, if the administrator didn't erase them, user B may get some information of user A. This security problem is a real problem in cloud evrionments, we should find a way to erase or reinitialize some important configurations which may leak a cloud user's information to another user. Yes, "--script" can do these things by administrator, but we all know that it is hard, since there are many user who does not have expirence writing these scripts, then they may think this virt-sysprep tool is hard to use, throw it away. Above all, we think that we should add some features to help remove the configurations which may leak security informations. What do you think? Thanks, Wanlong Gao
Rich.
On Thu, Oct 10, 2013 at 04:00:32PM +0800, Wanlong Gao wrote:
On 09/09/2013 04:52 PM, Richard W.M. Jones wrote:
On Mon, Sep 09, 2013 at 04:09:14PM +0800, Wanlong Gao wrote:
Yes, sure. Then can you give some comments about following TODO list? For which is necessary to add for users and which is not? Although we know almost all of the features we have in sysprep can be done by "--script" feature, right?
" add features to remove the following files or values if user required.
B-1) Data files which are made by iscsi initiator. /var/lib/iscsi/*
Some of this is configuration apparently; ie. it is set up by the iscsiadm utility.
B-2) Definition files of iscsi target emulator. /etc/tgt/*
Configuration?
B-3) Definition files of iptables /etc/sysconfig/iptables
Although we added this already, I'm inclined to think it is configuration, not temporary data.
B-4) Definition of TCP Wrapper /etc/hosts.*
Configuration.
B-5) Definition for hostname/DNS. /etc/resolv.conf /etc/hosts
/etc/resolv.conf could be removed, definitely on guests which use dhcp, if there is a way to tell if a guest uses dhcp.
/etc/hosts seems like configuration to me.
B-6) Definition of network routing /etc/sysconfig/network-scripts/route-* /etc/sysconfig/network-scripts/rule-*
Don't really know enough to comment on this.
B-7) Temporary files /tmp/* /var/tmp/*
Yes, it was good to remove this.
B-8) kdump setting file /etc/kdump.conf
B-9) NFS setting. /etc/exports
No.
B-10) Remove all files/directories under a directory which is specified by new virt-sysprep option
(User may want to each directories depends on thier circumstance.)
Yes, good idea. User should specify a wildcard / list of wildcards.
B-9) Remove or initialize value which is related specified users/groups.
User can select a) or b) a) Remove specified users/groups
- Remove definition for them from /etc/passwd and /etc/groups - Remove their home directories.
(Don't remove the files /etc/passwd /etc/groups.)
Yes -- already done ('user-account').
b) Initialize normal users/groups password
Note: Original requirement is to remove/initaliaze all of normal UID/GID user's setting.
But the definition of normal user is a bit confusable. RHEL6 : UID is 500 or more, RHEL7 : 1000 or more In addition, nfsnobody uses 65534.
So, specifing concrete UID/GID by command option is desirable. For example, "--uid=500,5021000-60000"
Unclear.
------
I think a better way to think about this: Suppose someone wants to use virt-sysprep to get back to the original configuration of the guest at installation. Wouldn't it be better (cleaner, safer) for them to install a new guest from scratch?
By the way, since I wrote all of that above, some things have changed a bit. virt-builder exists: http://rwmj.wordpress.com/2013/10/05/new-tool-virt-builder/#content http://libguestfs.org/virt-builder.1.html and it shares some code with virt-sysprep. And that means that there's more potential to share "configuration" operations (like virt-builder --hostname & --root-password) with virt-sysprep.
According to our discussion, we thought that these configurations are necessary to be removed or reinitialized, that all caused by security reasons.
For example, if we are providing user A a cloud environment GuestA, then we want to clone this environment to user B. We should give user B a clean guest, but these configurations may include some secure information of user A, if the administrator didn't erase them, user B may get some information of user A. This security problem is a real problem in cloud evrionments, we should find a way to erase or reinitialize some important configurations which may leak a cloud user's information to another user.
Yes, "--script" can do these things by administrator, but we all know that it is hard, since there are many user who does not have expirence writing these scripts, then they may think this virt-sysprep tool is hard to use, throw it away.
Above all, we think that we should add some features to help remove the configurations which may leak security informations. What do you think?
But going back to some of the things you mentioned, for example:
B-8) kdump setting file /etc/kdump.conf
B-9) NFS setting. /etc/exports
I said "> > No." I think I still say no. The reason is we can't end up writing an entire configuration system for Linux guests. Configuration systems for Linux guests already exist: Puppet/ Chef/Ansible (and more). It's a lot better to use those to do general configuration. How about this for example? http://rwmj.wordpress.com/2013/10/05/new-tool-virt-builder/#comment-7539 That pushes the problem to well-established tools which have existed for years that have plenty of good quality documentation. Perhaps we could make those easier to use or more integrated with virt-sysprep/virt-builder? Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones virt-p2v converts physical machines to virtual machines. Boot with a live CD or over the network (PXE) and turn machines into KVM guests. http://libguestfs.org/virt-v2v
This removes the custom tcp wrappers by emptying the /etc/hosts.* configuration files. Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- sysprep/Makefile.am | 1 + sysprep/sysprep_operation_tcp_wrapper.ml | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 sysprep/sysprep_operation_tcp_wrapper.ml diff --git a/sysprep/Makefile.am b/sysprep/Makefile.am index eb372aa..aa49605 100644 --- a/sysprep/Makefile.am +++ b/sysprep/Makefile.am @@ -67,6 +67,7 @@ operations = \ ssh_hostkeys \ ssh_userdir \ sssd_db_log \ + tcp_wrapper \ tmp_files \ udev_persistent_net \ user_account \ diff --git a/sysprep/sysprep_operation_tcp_wrapper.ml b/sysprep/sysprep_operation_tcp_wrapper.ml new file mode 100644 index 0000000..77f1e0a --- /dev/null +++ b/sysprep/sysprep_operation_tcp_wrapper.ml @@ -0,0 +1,52 @@ +(* virt-sysprep + * Copyright (C) 2013 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 Common_gettext.Gettext + +module G = Guestfs + +let tcp_wrapper_perform g root = + let typ = g#inspect_get_type root in + if typ <> "windows" then ( + let paths = [ "/etc/hosts.atm"; + "/etc/hosts.allow"; + "/etc/hosts.deny"; ] in + List.iter ( + fun path -> + (try g#rm path with G.Error _ -> ()); + (try g#touch path with G.Error _ -> ()); + ) paths; + [ `Created_files ] + ) + else [] + +let op = { + defaults with + name = "tcp-wrapper"; + enabled_by_default = false; + heading = s_"Remove the custom tcp wrappers"; + pod_description = Some (s_"\ +This removes the custom tcp wrappers by emptying C</etc/hosts.*>. + +Note this is I<not> enabled by default since it may expose guests +to exploits. Use with care."); + perform_on_filesystems = Some tcp_wrapper_perform; +} + +let () = register_operation op -- 1.8.4.27.g0a41de8
On Fri, Sep 06, 2013 at 03:52:41PM +0800, Wanlong Gao wrote:
+ let paths = [ "/etc/hosts.atm";
I don't suppose anyone uses it these days, but '/etc/hosts.atm' contains ATM settings. It's got nothing to do with TCP wrappers. 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://people.redhat.com/~rjones/virt-df/
Signed-off-by: Wanlong Gao <gaowanlong@cn.fujitsu.com> --- po/POTFILES-ml | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/po/POTFILES-ml b/po/POTFILES-ml index 1edca86..7bf6e1c 100644 --- a/po/POTFILES-ml +++ b/po/POTFILES-ml @@ -24,6 +24,7 @@ sysprep/sysprep_operation_firstboot.ml sysprep/sysprep_operation_flag_reconfiguration.ml sysprep/sysprep_operation_fs_uuids.ml sysprep/sysprep_operation_hostname.ml +sysprep/sysprep_operation_kdump_config.ml sysprep/sysprep_operation_kerberos_data.ml sysprep/sysprep_operation_logfiles.ml sysprep/sysprep_operation_lvm_uuids.ml @@ -31,6 +32,7 @@ sysprep/sysprep_operation_machine_id.ml sysprep/sysprep_operation_mail_spool.ml sysprep/sysprep_operation_net_hostname.ml sysprep/sysprep_operation_net_hwaddr.ml +sysprep/sysprep_operation_nfs_setting.ml sysprep/sysprep_operation_pacct_log.ml sysprep/sysprep_operation_package_manager_cache.ml sysprep/sysprep_operation_pam_data.ml @@ -45,6 +47,8 @@ sysprep/sysprep_operation_smolt_uuid.ml sysprep/sysprep_operation_ssh_hostkeys.ml sysprep/sysprep_operation_ssh_userdir.ml sysprep/sysprep_operation_sssd_db_log.ml +sysprep/sysprep_operation_tcp_wrapper.ml +sysprep/sysprep_operation_tmp_files.ml sysprep/sysprep_operation_udev_persistent_net.ml sysprep/sysprep_operation_user_account.ml sysprep/sysprep_operation_utmp.ml -- 1.8.4.27.g0a41de8
participants (2)
-
Richard W.M. Jones -
Wanlong Gao