Crate machine_uid[−][src]
Get os native machine id without root permission.
About machine id
In Linux, machine id is a single newline-terminated, hexadecimal, 32-character, lowercase ID. When decoded from hexadecimal, this corresponds to a 16-byte/128-bit value. This ID may not be all zeros. This ID uniquely identifies the host. It should be considered "confidential", and must not be exposed in untrusted environments. And do note that the machine id can be re-generated by root.
Usage
extern crate machine_uid;
fn main() {
let id: String = machine_uid::get().unwrap();
println!("{}", id);
}
How it works
It get machine id from following source:
Linux or who use systemd:
cat /var/lib/dbus/machine-id # or /etc/machine-id
BSD:
cat /etc/hostid # or kenv -q smbios.system.uuid
OSX:
ioreg -rd1 -c IOPlatformExpertDevice | grep IOPlatformUUID
Supported Platform
I have tested in following platform:
- Debian 8
- OS X 10.6
- FeeBSD 10.4
- Fedora 28
current not support windows.
Re-exports
pub use machine_id::get_machine_id as get; |
Modules
machine_id |