Pino Toscano
2015-Jul-29 11:48 UTC
[Libguestfs] [PATCH 1/2] sysprep: machine_id: simplify implementation
Instead of rm + touch, just truncate the file if existing. In case there was no file previously, now nothing is created, as most probably the system was fine even without it. Also, turn the single path into a list, so more machine-id files can be handled at once. --- sysprep/sysprep_operation_machine_id.ml | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/sysprep/sysprep_operation_machine_id.ml b/sysprep/sysprep_operation_machine_id.ml index fbcc692..190ca5b 100644 --- a/sysprep/sysprep_operation_machine_id.ml +++ b/sysprep/sysprep_operation_machine_id.ml @@ -21,15 +21,12 @@ open Common_gettext.Gettext module G = Guestfs -let machine_id_perform g root side_effects +let machine_id_perform (g : Guestfs.guestfs) root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( - let path = "/etc/machine-id" in - (try g#rm path with G.Error _ -> ()); - (try - g#touch path; - side_effects#created_file () - with G.Error _ -> ()); + let paths = [ "/etc/machine-id"; ] in + let paths = List.filter g#is_file paths in + List.iter g#truncate paths ) let op = { -- 2.1.0
Pino Toscano
2015-Jul-29 11:48 UTC
[Libguestfs] [PATCH 2/2] sysprep: machine_id: handle /var/lib/dbus/machine-id
Another machine-id file, used by D-Bus. --- sysprep/sysprep_operation_machine_id.ml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/sysprep/sysprep_operation_machine_id.ml b/sysprep/sysprep_operation_machine_id.ml index 190ca5b..dbf8ce2 100644 --- a/sysprep/sysprep_operation_machine_id.ml +++ b/sysprep/sysprep_operation_machine_id.ml @@ -24,7 +24,8 @@ module G = Guestfs let machine_id_perform (g : Guestfs.guestfs) root side_effects let typ = g#inspect_get_type root in if typ <> "windows" then ( - let paths = [ "/etc/machine-id"; ] in + let paths = [ "/etc/machine-id"; + "/var/lib/dbus/machine-id"; ] in let paths = List.filter g#is_file paths in List.iter g#truncate paths ) -- 2.1.0
Richard W.M. Jones
2015-Jul-29 16:26 UTC
Re: [Libguestfs] [PATCH 2/2] sysprep: machine_id: handle /var/lib/dbus/machine-id
On Wed, Jul 29, 2015 at 01:48:16PM +0200, Pino Toscano wrote:> Another machine-id file, used by D-Bus. > --- > sysprep/sysprep_operation_machine_id.ml | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/sysprep/sysprep_operation_machine_id.ml b/sysprep/sysprep_operation_machine_id.ml > index 190ca5b..dbf8ce2 100644 > --- a/sysprep/sysprep_operation_machine_id.ml > +++ b/sysprep/sysprep_operation_machine_id.ml > @@ -24,7 +24,8 @@ module G = Guestfs > let machine_id_perform (g : Guestfs.guestfs) root side_effects > let typ = g#inspect_get_type root in > if typ <> "windows" then ( > - let paths = [ "/etc/machine-id"; ] in > + let paths = [ "/etc/machine-id"; > + "/var/lib/dbus/machine-id"; ] in > let paths = List.filter g#is_file paths in > List.iter g#truncate paths > ) > -- > 2.1.0Looks good - ACK series. Rich. -- Richard Jones, Virtualization Group, Red Hat http://people.redhat.com/~rjones Read my programming and virtualization blog: http://rwmj.wordpress.com Fedora Windows cross-compiler. Compile Windows programs, test, and build Windows installers. Over 100 libraries supported. http://fedoraproject.org/wiki/MinGW
Seemingly Similar Threads
- [PATCH 1/2] sysprep: machine_id: simplify implementation
- Re: [PATCH 1/3] sysprep, get-kernel: explicit the Guestfs parameter
- [PATCH 3/4] ocaml tools: Use global variables to store trace (-x) and verbose (-v) flags.
- [PATCH 1/3] sysprep, get-kernel: explicit the Guestfs parameter
- [PATCH] sysprep: remove hostname from ifcfg-*