libgslutil  1.2.3
Macros | Functions
Machine ID

Macros

#define GSL_MACHINE_ID_LEN   (33)
 Length for null-terminated machine ID string.
 
#define GSL_MACHINE_UUID_LEN   (16)
 Length for raw machine ID bytes.
 

Functions

void gsl_get_machine_id (char *strbuf, uint8_t *uuid, int *was_generated)
 Read machine ID. More...
 

Detailed Description

dbus and, more latterly, systemd define a useful concept: a machine ID. Underneath the hood this is a UUID.

See also
http://0pointer.de/public/systemd-man/machine-id.html .

Function Documentation

◆ gsl_get_machine_id()

void gsl_get_machine_id ( char *  strbuf,
uint8_t *  uuid,
int *  was_generated 
)

Read machine ID.

Parameters
[out]strbufString buffer, containing ASCII machine ID.
[out]uuidRaw hex digits of UUID.
[out]was_generatedTrue if result generated by this function.

Reads the machine ID from /etc/machine-id (if present). If not present, or the contents of the file are invalid, generates a machine ID locally. Such local generation will result in a different UUID on each call, and will result in *was_generated being set to a non-zero value (if not null), and the UUID will be a v4 (random) UUID.

If strbuf is not null, it must point to a buffer of at least GSL_MACHINE_ID_LEN bytes (which includes space for a terminating null). If uuid is not null, it must point to a buffer of GSL_MACHINE_UUID_LEN bytes.