aboutsummaryrefslogtreecommitdiff
blob: a943104068df7d0b219a6e33e0c862764e324961 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
commit 42881d277014d3bf3bb1b4e660c80378b4081a52
Author: Arun Raghavan <arun.raghavan@collabora.co.uk>
Date:   Mon Nov 14 13:42:21 2011 +0530

    core: Look up /etc/machine-id if D-Bus machine-id is not found
    
    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

diff --git a/configure.ac b/configure.ac
index 324e32e..1f65dd5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -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 ####
 
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index 79c8e08..0173135 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -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);