Commit 75eb4aa
unix-ffi/machine: Retrieve a unique identifier if one is known.
This commit adds a proper implementation for "machine.unique_id" for
selected systems, as opposed to returning a fixed value in every case.
On a Unix system there are several incompatible ways to retrieve
something that can be called an unique machine identifier. However, the
only semblance of a specification comes from freedesktop.org, which says
that a file called "/etc/machine-id" has to exist and must contain a
32-digits long hexadecimal identifier.
Given that the current specification is the DBus unique identifier
retrieval mechanism made official, if the identifier file is not found
the code will attempt to read the file provided by DBus.
These changes only apply to Linux and recent BSD systems. On other
systems the old, fixed value for the machine identifier will be returned
instead - to avoid breaking compatibility with existing code.
The specification used in this commit is available at
https://www.freedesktop.org/software/systemd/man/latest/machine-id.html.
Signed-off-by: Alessandro Gatti <a.gatti@frob.it>1 parent 47fec41 commit 75eb4aa
2 files changed
+10
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
7 | 16 | | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | | - | |
| 1 | + | |
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| |||
0 commit comments