Order of the machine-id files

Yang Chengwei chengwei.yang at intel.com
Wed Jan 8 17:58:04 PST 2014


On Wed, Jan 08, 2014 at 09:12:35AM +0100, Fridrich Strba wrote:
> Hello, good people,
> 
> I had a number of bug reports with some software not working really
> well when the DBUS_MACHINE_UUID_FILE and the /etc/machine-id files
> differ in their content. I don't know how it comes to be, since I

Is there any bugzilla used to track the issue?

Or at least you can open one on freedesktop.org for dbus upstream.

> cannot reproduce on any of my machines of virtual machines, but real
> users have the two files diverging. I would like to propose an
> attached patch that might actually solve that issue, since the
> /etc/machine-id would be looked for first and only if it does not
> exist, the /var/lib/dbus/machine-id would be considered.

I think if it's the difference between /etc/machine-id and
%localstatedir/lib/dbus/machine-id which cause problem, only change the
read sequence isn't a real fix I think.

For example, if A will fail because read
%localstatedir/lib/dbus/machine-id first then B may fail because read
/etc/machine-id first.

I think probably this is a distro issue,
%localstatedir/lib/dbus/machine-id should be generated by dbus-uuidgen
at first, then not bother on /etc/machine-id.

See tools/dbus-uuidgen.c also. Your patch does change the well-known
behavior of dbus-uuidgen too.

--
Thanks,
Chengwei

> 
> I am just not sure whether I did not oversee any problematic
> side-effect that this change would have.
> 
> Please, advise
> 
> Fridrich

> >From 1ef685e116a9c8b963e365b98a9510aa68b9701e Mon Sep 17 00:00:00 2001
> From: =?UTF-8?q?Fridrich=20=C5=A0trba?= <fridrich.strba at bluewin.ch>
> Date: Wed, 8 Jan 2014 09:10:07 +0100
> Subject: [PATCH] Consider the system machine ID first if it exists
> 
> ---
>  dbus/dbus-sysdeps-unix.c | 11 ++++++-----
>  1 file changed, 6 insertions(+), 5 deletions(-)
> 
> diff --git a/dbus/dbus-sysdeps-unix.c b/dbus/dbus-sysdeps-unix.c
> index ae42f56..aac27e5 100644
> --- a/dbus/dbus-sysdeps-unix.c
> +++ b/dbus/dbus-sysdeps-unix.c
> @@ -3577,17 +3577,18 @@ _dbus_read_local_machine_uuid (DBusGUID   *machine_id,
>    DBusString filename;
>    dbus_bool_t b;
>  
> -  _dbus_string_init_const (&filename, DBUS_MACHINE_UUID_FILE);
> +  /* First try to use the system machine ID if it exists */
> +  _dbus_string_init_const (&filename, "/etc/machine-id");
>  
> -  b = _dbus_read_uuid_file (&filename, machine_id, create_if_not_found, error);
> +  b = _dbus_read_uuid_file (&filename, machine_id, FALSE, error)
>    if (b)
>      return TRUE;
>  
>    dbus_error_free (error);
>  
> -  /* Fallback to the system machine ID */
> -  _dbus_string_init_const (&filename, "/etc/machine-id");
> -  return _dbus_read_uuid_file (&filename, machine_id, FALSE, error);
> +  /* Fallback to the DBUS_MACHINE_UUID_FILE */
> +  _dbus_string_init_const (&filename, DBUS_MACHINE_UUID_FILE);
> +  return _dbus_read_uuid_file (&filename, machine_id, create_if_not_found, error);
>  }
>  
>  /**
> -- 
> 1.8.5.2
> 
> 

> _______________________________________________
> dbus mailing list
> dbus at lists.freedesktop.org
> http://lists.freedesktop.org/mailman/listinfo/dbus

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 490 bytes
Desc: Digital signature
URL: <http://lists.freedesktop.org/archives/dbus/attachments/20140109/1ec8ed53/attachment.pgp>


More information about the dbus mailing list