]> code.delx.au - pulseaudio/commitdiff
core: Look up /etc/machine-id if D-Bus machine-id is not found
authorArun Raghavan <arun.raghavan@collabora.co.uk>
Mon, 14 Nov 2011 08:12:21 +0000 (13:42 +0530)
committerArun Raghavan <arun.raghavan@collabora.co.uk>
Tue, 15 Nov 2011 07:21:31 +0000 (12:51 +0530)
It appears that this is currently the fallback for early boot and other
such cases where /var might not be available. Relevant upstream commit:

http://cgit.freedesktop.org/dbus/dbus/commit/?id=66e52541d5bdd4927a5c702963749760643313f4

Thanks to Samuli Suominen <ssuominen@gentoo.org> for pointing this out
in https://bugs.gentoo.org/show_bug.cgi?id=390287

configure.ac
src/pulsecore/core-util.c

index 324e32ec4ba08071679bfaf85d5ef604895621e8..1f65dd5d33dcd5850862110ee7db55131f149fe6 100644 (file)
@@ -935,6 +935,9 @@ AS_IF([test "x$HAVE_DBUS" = "x1"], AC_DEFINE([HAVE_DBUS], 1, [Have D-Bus.]))
 
 PA_MACHINE_ID="${localstatedir}/lib/dbus/machine-id"
 AX_DEFINE_DIR(PA_MACHINE_ID, PA_MACHINE_ID, [D-Bus machine-id file])
+PA_MACHINE_ID_FALLBACK="${sysconfdir}/machine-id"
+AX_DEFINE_DIR(PA_MACHINE_ID_FALLBACK, PA_MACHINE_ID_FALLBACK,
+             [Fallback machine-id file])
 
 #### HAL support (optional), dependant on D-Bus ####
 
index 79c8e0820e7d902f8fcd41b8612762b69535a21f..01731350d4819535cff8dfee500851644a0bbb7c 100644 (file)
@@ -2717,7 +2717,8 @@ char *pa_machine_id(void) {
      * since it fits perfectly our needs and is not as volatile as the
      * hostname which might be set from dhcp. */
 
-    if ((f = pa_fopen_cloexec(PA_MACHINE_ID, "r"))) {
+    if ((f = pa_fopen_cloexec(PA_MACHINE_ID, "r")) ||
+        (f = pa_fopen_cloexec(PA_MACHINE_ID_FALLBACK, "r"))) {
         char ln[34] = "", *r;
 
         r = fgets(ln, sizeof(ln)-1, f);