summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPeter Meerwald <pmeerw@pmeerw.net>2015-06-09 21:56:36 +0200
committerArun Raghavan <git@arunraghavan.net>2015-09-25 17:29:02 +0530
commitbb88d9095052cd1af7cc7d68c8fc2d47c63ec1e0 (patch)
tree805effb9a4e96beb675847300ae5e5c308cbafd1
parentb727dd540b96ecf62fc0ef411dcea1049f235093 (diff)
core: Fallbacks for machine-id in filesystem
see https://bugs.freedesktop.org/show_bug.cgi?id=88834 Signed-off-by: Peter Meerwald <pmeerw@pmeerw.net>
-rw-r--r--src/pulsecore/core-util.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/src/pulsecore/core-util.c b/src/pulsecore/core-util.c
index ba3122143..f5857e0c2 100644
--- a/src/pulsecore/core-util.c
+++ b/src/pulsecore/core-util.c
@@ -3060,12 +3060,21 @@ char *pa_machine_id(void) {
/* The returned value is supposed be some kind of ascii identifier
* that is unique and stable across reboots. */
- /* First we try the /etc/machine-id, which is the best option we
- * have, since it fits perfectly our needs and is not as volatile
+ /* First we try ${sysconfdir}/etc/machine-id, with fallbacks to
+ * ${localstatedir}/lib/dbus/machine-id, /etc/machine-id and
+ * /var/lib/dbus/machine-id, which are the best option we
+ * have, since they fit perfectly our needs and are not as volatile
* as the hostname which might be set from dhcp. */
if ((f = pa_fopen_cloexec(PA_MACHINE_ID, "r")) ||
- (f = pa_fopen_cloexec(PA_MACHINE_ID_FALLBACK, "r"))) {
+ (f = pa_fopen_cloexec(PA_MACHINE_ID_FALLBACK, "r")) ||
+#if !defined(OS_IS_WIN32)
+ (f = pa_fopen_cloexec("/etc/machine-id", "r")) ||
+ (f = pa_fopen_cloexec("/var/lib/dbus/machine-id", "r"))
+#else
+ false
+#endif
+ ) {
char ln[34] = "", *r;
r = fgets(ln, sizeof(ln)-1, f);