1
0
mirror of https://github.com/systemd/systemd synced 2026-03-26 08:44:55 +01:00

Compare commits

..

No commits in common. "72fba0c4e5cd159259010b71a1c1bb72393251c8" and "dc131951b5f903b698f624a0234560d7a822ff21" have entirely different histories.

45 changed files with 216 additions and 185 deletions

View File

@ -61,7 +61,7 @@ manpages = [
['org.freedesktop.resolve1', '5', [], 'ENABLE_RESOLVE'], ['org.freedesktop.resolve1', '5', [], 'ENABLE_RESOLVE'],
['org.freedesktop.systemd1', '5', [], ''], ['org.freedesktop.systemd1', '5', [], ''],
['org.freedesktop.timedate1', '5', [], 'ENABLE_TIMEDATED'], ['org.freedesktop.timedate1', '5', [], 'ENABLE_TIMEDATED'],
['os-release', '5', ['extension-release', 'initrd-release'], ''], ['os-release', '5', ['initrd-release'], ''],
['pam_systemd', '8', [], 'HAVE_PAM'], ['pam_systemd', '8', [], 'HAVE_PAM'],
['pam_systemd_home', '8', [], 'ENABLE_PAM_HOME'], ['pam_systemd_home', '8', [], 'ENABLE_PAM_HOME'],
['portablectl', '1', [], 'ENABLE_PORTABLED'], ['portablectl', '1', [], 'ENABLE_PORTABLED'],
@ -633,10 +633,7 @@ manpages = [
'sd_id128_get_machine_app_specific'], 'sd_id128_get_machine_app_specific'],
''], ''],
['sd_id128_randomize', '3', [], ''], ['sd_id128_randomize', '3', [], ''],
['sd_id128_to_string', ['sd_id128_to_string', '3', ['sd_id128_from_string'], ''],
'3',
['SD_ID128_STRING_MAX', 'SD_ID128_TO_STRING', 'sd_id128_from_string'],
''],
['sd_is_fifo', ['sd_is_fifo',
'3', '3',
['sd_is_mq', ['sd_is_mq',

View File

@ -90,10 +90,7 @@
<programlisting>#define SD_MESSAGE_COREDUMP SD_ID128_MAKE(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)</programlisting> <programlisting>#define SD_MESSAGE_COREDUMP SD_ID128_MAKE(fc,2e,22,bc,6e,e6,47,b6,b9,07,29,ab,34,a2,50,b1)</programlisting>
<para><constant>SD_ID128_NULL</constant> may be used to refer to the 128-bit ID consisting of only <para><constant>SD_ID128_NULL</constant> may be used to refer to the 128-bit ID consisting of only
<constant>NUL</constant> bytes (i.e. all bits off).</para> <constant>NUL</constant> bytes.</para>
<para><constant>SD_ID128_ALLF</constant> may be used to refer to the 128-bit ID consisting of only
<constant>0xFF</constant> bytes (i.e. all bits on).</para>
<para><function>SD_ID128_MAKE_STR()</function> is similar to <function>SD_ID128_MAKE()</function>, but creates a <para><function>SD_ID128_MAKE_STR()</function> is similar to <function>SD_ID128_MAKE()</function>, but creates a
<type>const char*</type> expression that can be conveniently used in message formats and such:</para> <type>const char*</type> expression that can be conveniently used in message formats and such:</para>

View File

@ -35,11 +35,12 @@
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para><function>sd_id128_randomize()</function> generates a new randomized 128-bit ID and returns it in <para><function>sd_id128_randomize()</function> generates a new
<parameter>ret</parameter>. Every invocation returns a new randomly generated ID. This uses the randomized 128-bit ID and returns it in
<citerefentry <parameter>ret</parameter>. Every invocation returns a new
project='man-pages'><refentrytitle>getrandom</refentrytitle><manvolnum>2</manvolnum></citerefentry> randomly generated ID. This uses the
kernel random number generator.</para> <filename>/dev/urandom</filename> kernel random number
generator.</para>
<para>Note that <function>sd_id128_randomize()</function> always returns a UUID Variant 1 Version 4 <para>Note that <function>sd_id128_randomize()</function> always returns a UUID Variant 1 Version 4
compatible ID. It is hence guaranteed that this function will never return the ID consisting of all zero compatible ID. It is hence guaranteed that this function will never return the ID consisting of all zero
@ -71,8 +72,7 @@
<citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>, <citerefentry><refentrytitle>systemd</refentrytitle><manvolnum>1</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>, <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>,
<citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>, <citerefentry><refentrytitle>machine-id</refentrytitle><manvolnum>5</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>getrandom</refentrytitle><manvolnum>2</manvolnum></citerefentry>, <citerefentry><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry>,
<citerefentry project='man-pages'><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry>,
<citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry> <citerefentry><refentrytitle>sd_id128_get_machine</refentrytitle><manvolnum>3</manvolnum></citerefentry>
</para> </para>
</refsect1> </refsect1>

View File

@ -17,9 +17,7 @@
<refnamediv> <refnamediv>
<refname>sd_id128_to_string</refname> <refname>sd_id128_to_string</refname>
<refname>SD_ID128_TO_STRING</refname>
<refname>sd_id128_from_string</refname> <refname>sd_id128_from_string</refname>
<refname>SD_ID128_STRING_MAX</refname>
<refpurpose>Format or parse 128-bit IDs as strings</refpurpose> <refpurpose>Format or parse 128-bit IDs as strings</refpurpose>
</refnamediv> </refnamediv>
@ -27,13 +25,9 @@
<funcsynopsis> <funcsynopsis>
<funcsynopsisinfo>#include &lt;systemd/sd-id128.h&gt;</funcsynopsisinfo> <funcsynopsisinfo>#include &lt;systemd/sd-id128.h&gt;</funcsynopsisinfo>
<funcsynopsisinfo>#define SD_ID128_STRING_MAX 33U</funcsynopsisinfo>
<funcsynopsisinfo>#define SD_ID128_TO_STRING(id) …</funcsynopsisinfo>
<funcprototype> <funcprototype>
<funcdef>char *<function>sd_id128_to_string</function></funcdef> <funcdef>char *<function>sd_id128_to_string</function></funcdef>
<paramdef>sd_id128_t <parameter>id</parameter>, char <parameter>s</parameter>[static SD_ID128_STRING_MAX]</paramdef> <paramdef>sd_id128_t <parameter>id</parameter>, char <parameter>s</parameter>[33]</paramdef>
</funcprototype> </funcprototype>
<funcprototype> <funcprototype>
@ -47,48 +41,47 @@
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para><function>sd_id128_to_string()</function> formats a 128-bit ID as a character string. It expects <para><function>sd_id128_to_string()</function> formats a 128-bit
the ID and a string array capable of storing 33 characters ID as a character string. It expects the ID and a string array
(<constant>SD_ID128_STRING_MAX</constant>). The ID will be formatted as 32 lowercase hexadecimal digits capable of storing 33 characters. The ID will be formatted as 32
and be terminated by a <constant>NUL</constant> byte.</para> lowercase hexadecimal digits and be terminated by a
<constant>NUL</constant> byte.</para>
<para><function>SD_ID128_TO_STRING()</function> is a macro that wraps <para><function>sd_id128_from_string()</function> implements the reverse operation: it takes a 33 character string
<function>sd_id128_to_string()</function> and passes an appropriately sized buffer as second argument, with 32 hexadecimal digits (either lowercase or uppercase, terminated by <constant>NUL</constant>) and parses them
allocated as C99 compound literal. Each use will thus implicitly acquire a suitable buffer on the stack back into a 128-bit ID returned in <parameter>ret</parameter>. Alternatively, this call can also parse a
which remains valid until the end of the current code block. This is usually the simplest way to acquire 37-character string with a 128-bit ID formatted as RFC UUID. If <parameter>ret</parameter> is passed as
a string representation of a 128-bit ID in a buffer that is valid in the current code block.</para> <constant>NULL</constant> the function will validate the passed ID string, but not actually return it in parsed
form.</para>
<para><function>sd_id128_from_string()</function> implements the reverse operation: it takes a 33
character string with 32 hexadecimal digits (either lowercase or uppercase, terminated by
<constant>NUL</constant>) and parses them back into a 128-bit ID returned in
<parameter>ret</parameter>. Alternatively, this call can also parse a 37-character string with a 128-bit
ID formatted as RFC UUID. If <parameter>ret</parameter> is passed as <constant>NULL</constant> the
function will validate the passed ID string, but not actually return it in parsed form.</para>
<para>Note that when parsing 37 character UUIDs this is done strictly in Big Endian byte order, <para>Note that when parsing 37 character UUIDs this is done strictly in Big Endian byte order,
i.e. according to <ulink url="https://tools.ietf.org/html/rfc4122">RFC4122</ulink> Variant 1 rules, even i.e. according to <ulink url="https://tools.ietf.org/html/rfc4122">RFC4122</ulink> Variant 1
if the UUID encodes a different variant. This matches behaviour in various other Linux userspace rules, even if the UUID encodes a different variant. This matches behaviour in various other Linux
tools. It's probably wise to avoid UUIDs of other variant types.</para> userspace tools. It's probably wise to avoid UUIDs of other variant types.</para>
<para>For more information about the <literal>sd_id128_t</literal> type see <para>For more information about the <literal>sd_id128_t</literal>
<citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Note that type see
these calls operate the same way on all architectures, i.e. the results do not depend on <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
endianness.</para> Note that these calls operate the same way on all architectures,
i.e. the results do not depend on endianness.</para>
<para>When formatting a 128-bit ID into a string, it is often easier to use a format string for <para>When formatting a 128-bit ID into a string, it is often
<citerefentry easier to use a format string for
project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>. This <citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>.
is easily done using the <constant>SD_ID128_FORMAT_STR</constant> and This is easily done using the
<function>SD_ID128_FORMAT_VAL()</function> macros. For more information see <constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> macros. For
more information see
<citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para> <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>.</para>
</refsect1> </refsect1>
<refsect1> <refsect1>
<title>Return Value</title> <title>Return Value</title>
<para><function>sd_id128_to_string()</function> always succeeds and returns a pointer to the string array <para><function>sd_id128_to_string()</function> always succeeds
passed in. <function>sd_id128_from_string()</function> returns 0 on success, in which case and returns a pointer to the string array passed in.
<parameter>ret</parameter> is filled in, or a negative errno-style error code.</para> <function>sd_id128_from_string()</function> returns 0 on success, in
which case <parameter>ret</parameter> is filled in, or a negative
errno-style error code.</para>
</refsect1> </refsect1>
<xi:include href="libsystemd-pkgconfig.xml" /> <xi:include href="libsystemd-pkgconfig.xml" />

View File

@ -2265,14 +2265,6 @@ IPv6Token=prefixstable:2002:da8:1::</programlisting></para>
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term><varname>UseMTU=</varname></term>
<listitem>
<para>Takes a boolean. When true, the MTU received in the Router Advertisement will be
used. Defaults to true.</para>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term><varname>UseAutonomousPrefix=</varname></term> <term><varname>UseAutonomousPrefix=</varname></term>
<listitem> <listitem>

View File

@ -918,6 +918,7 @@ static int remove_subdirs(const char *root, const char *const *subdirs) {
static int remove_machine_id_directory(const char *root) { static int remove_machine_id_directory(const char *root) {
sd_id128_t machine_id; sd_id128_t machine_id;
char buf[SD_ID128_STRING_MAX];
int r; int r;
assert(root); assert(root);
@ -930,7 +931,7 @@ static int remove_machine_id_directory(const char *root) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m"); return log_error_errno(r, "Failed to get machine id: %m");
return rmdir_one(root, SD_ID128_TO_STRING(machine_id)); return rmdir_one(root, sd_id128_to_string(machine_id, buf));
} }
static int remove_binaries(const char *esp_path) { static int remove_binaries(const char *esp_path) {
@ -1019,6 +1020,8 @@ static int install_loader_config(const char *esp_path) {
_cleanup_(unlink_and_freep) char *t = NULL; _cleanup_(unlink_and_freep) char *t = NULL;
_cleanup_fclose_ FILE *f = NULL; _cleanup_fclose_ FILE *f = NULL;
_cleanup_close_ int fd = -1; _cleanup_close_ int fd = -1;
sd_id128_t machine_id;
char machine_string[SD_ID128_STRING_MAX];
const char *p; const char *p;
int r; int r;
@ -1038,15 +1041,12 @@ static int install_loader_config(const char *esp_path) {
fprintf(f, "#timeout 3\n" fprintf(f, "#timeout 3\n"
"#console-mode keep\n"); "#console-mode keep\n");
if (arg_make_machine_id_directory) { if (arg_make_machine_id_directory) {
sd_id128_t machine_id;
r = sd_id128_get_machine(&machine_id); r = sd_id128_get_machine(&machine_id);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m"); return log_error_errno(r, "Failed to get machine id: %m");
fprintf(f, "default %s-*\n", SD_ID128_TO_STRING(machine_id)); fprintf(f, "default %s-*\n", sd_id128_to_string(machine_id, machine_string));
} }
r = fflush_sync_and_check(f); r = fflush_sync_and_check(f);
@ -1065,6 +1065,7 @@ static int install_loader_config(const char *esp_path) {
static int install_machine_id_directory(const char *root) { static int install_machine_id_directory(const char *root) {
sd_id128_t machine_id; sd_id128_t machine_id;
char buf[SD_ID128_STRING_MAX];
int r; int r;
assert(root); assert(root);
@ -1077,7 +1078,7 @@ static int install_machine_id_directory(const char *root) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get machine id: %m"); return log_error_errno(r, "Failed to get machine id: %m");
return mkdir_one(root, SD_ID128_TO_STRING(machine_id)); return mkdir_one(root, sd_id128_to_string(machine_id, buf));
} }
static int help(int argc, char *argv[], void *userdata) { static int help(int argc, char *argv[], void *userdata) {

View File

@ -27,7 +27,7 @@ static VOID linux_efi_handover(EFI_HANDLE image, struct boot_params *params) {
handover(image, ST, params); handover(image, ST, params);
} }
EFI_STATUS linux_exec(EFI_HANDLE image, EFI_STATUS linux_exec(EFI_HANDLE *image,
CHAR8 *cmdline, UINTN cmdline_len, CHAR8 *cmdline, UINTN cmdline_len,
UINTN linux_addr, UINTN linux_addr,
UINTN initrd_addr, UINTN initrd_size) { UINTN initrd_addr, UINTN initrd_size) {

View File

@ -84,7 +84,7 @@ struct boot_params {
UINT8 _pad9[276]; UINT8 _pad9[276];
} _packed_; } _packed_;
EFI_STATUS linux_exec(EFI_HANDLE image, EFI_STATUS linux_exec(EFI_HANDLE *image,
CHAR8 *cmdline, UINTN cmdline_size, CHAR8 *cmdline, UINTN cmdline_size,
UINTN linux_addr, UINTN linux_addr,
UINTN initrd_addr, UINTN initrd_size); UINTN initrd_addr, UINTN initrd_size);

View File

@ -339,7 +339,9 @@ static int list_bus_names(int argc, char **argv, void *userdata) {
if (r < 0) if (r < 0)
log_debug_errno(r, "Failed to acquire credentials of service %s, ignoring: %m", k); log_debug_errno(r, "Failed to acquire credentials of service %s, ignoring: %m", k);
else { else {
r = table_add_cell(table, NULL, TABLE_ID128, &mid); char m[SD_ID128_STRING_MAX];
r = table_add_cell(table, NULL, TABLE_STRING, sd_id128_to_string(mid, m));
if (r < 0) if (r < 0)
return table_log_add_error(r); return table_log_add_error(r);

View File

@ -738,6 +738,7 @@ void cgroup_oomd_xattr_apply(Unit *u, const char *cgroup_path) {
} }
static void cgroup_xattr_apply(Unit *u) { static void cgroup_xattr_apply(Unit *u) {
char ids[SD_ID128_STRING_MAX];
int r; int r;
assert(u); assert(u);
@ -748,7 +749,7 @@ static void cgroup_xattr_apply(Unit *u) {
if (!sd_id128_is_null(u->invocation_id)) { if (!sd_id128_is_null(u->invocation_id)) {
r = cg_set_xattr(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path, r = cg_set_xattr(SYSTEMD_CGROUP_CONTROLLER, u->cgroup_path,
"trusted.invocation_id", "trusted.invocation_id",
SD_ID128_TO_STRING(u->invocation_id), 32, sd_id128_to_string(u->invocation_id, ids), 32,
0); 0);
if (r < 0) if (r < 0)
log_unit_debug_errno(u, r, "Failed to set invocation ID on control group %s, ignoring: %m", empty_to_root(u->cgroup_path)); log_unit_debug_errno(u, r, "Failed to set invocation ID on control group %s, ignoring: %m", empty_to_root(u->cgroup_path));

View File

@ -2497,6 +2497,7 @@ static int make_tmp_prefix(const char *prefix) {
static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, char **tmp_path) { static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, char **tmp_path) {
_cleanup_free_ char *x = NULL; _cleanup_free_ char *x = NULL;
_cleanup_free_ char *y = NULL; _cleanup_free_ char *y = NULL;
char bid[SD_ID128_STRING_MAX];
sd_id128_t boot_id; sd_id128_t boot_id;
bool rw = true; bool rw = true;
int r; int r;
@ -2512,7 +2513,7 @@ static int setup_one_tmp_dir(const char *id, const char *prefix, char **path, ch
if (r < 0) if (r < 0)
return r; return r;
x = strjoin(prefix, "/systemd-private-", SD_ID128_TO_STRING(boot_id), "-", id, "-XXXXXX"); x = strjoin(prefix, "/systemd-private-", sd_id128_to_string(boot_id, bid), "-", id, "-XXXXXX");
if (!x) if (!x)
return -ENOMEM; return -ENOMEM;

View File

@ -566,6 +566,7 @@ static int process_hostname(void) {
static int process_machine_id(void) { static int process_machine_id(void) {
const char *etc_machine_id; const char *etc_machine_id;
char id[SD_ID128_STRING_MAX];
int r; int r;
etc_machine_id = prefix_roota(arg_root, "/etc/machine-id"); etc_machine_id = prefix_roota(arg_root, "/etc/machine-id");
@ -575,7 +576,7 @@ static int process_machine_id(void) {
if (sd_id128_is_null(arg_machine_id)) if (sd_id128_is_null(arg_machine_id))
return 0; return 0;
r = write_string_file(etc_machine_id, SD_ID128_TO_STRING(arg_machine_id), r = write_string_file(etc_machine_id, sd_id128_to_string(arg_machine_id, id),
WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755 | WRITE_STRING_FILE_CREATE | WRITE_STRING_FILE_SYNC | WRITE_STRING_FILE_MKDIR_0755 |
(arg_force ? WRITE_STRING_FILE_ATOMIC : 0)); (arg_force ? WRITE_STRING_FILE_ATOMIC : 0));
if (r < 0) if (r < 0)

View File

@ -817,13 +817,14 @@ static int apply_identity_changes(JsonVariant **_v) {
if (arg_identity_extra_this_machine || !strv_isempty(arg_identity_filter)) { if (arg_identity_extra_this_machine || !strv_isempty(arg_identity_filter)) {
_cleanup_(json_variant_unrefp) JsonVariant *per_machine = NULL, *mmid = NULL; _cleanup_(json_variant_unrefp) JsonVariant *per_machine = NULL, *mmid = NULL;
char mids[SD_ID128_STRING_MAX];
sd_id128_t mid; sd_id128_t mid;
r = sd_id128_get_machine(&mid); r = sd_id128_get_machine(&mid);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to acquire machine ID: %m"); return log_error_errno(r, "Failed to acquire machine ID: %m");
r = json_variant_new_string(&mmid, SD_ID128_TO_STRING(mid)); r = json_variant_new_string(&mmid, sd_id128_to_string(mid, mids));
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to allocate matchMachineId object: %m"); return log_error_errno(r, "Failed to allocate matchMachineId object: %m");

View File

@ -2163,6 +2163,7 @@ int home_augment_status(
uint64_t disk_size = UINT64_MAX, disk_usage = UINT64_MAX, disk_free = UINT64_MAX, disk_ceiling = UINT64_MAX, disk_floor = UINT64_MAX; uint64_t disk_size = UINT64_MAX, disk_usage = UINT64_MAX, disk_free = UINT64_MAX, disk_ceiling = UINT64_MAX, disk_floor = UINT64_MAX;
_cleanup_(json_variant_unrefp) JsonVariant *j = NULL, *v = NULL, *m = NULL, *status = NULL; _cleanup_(json_variant_unrefp) JsonVariant *j = NULL, *v = NULL, *m = NULL, *status = NULL;
_cleanup_(user_record_unrefp) UserRecord *ur = NULL; _cleanup_(user_record_unrefp) UserRecord *ur = NULL;
char ids[SD_ID128_STRING_MAX];
HomeState state; HomeState state;
sd_id128_t id; sd_id128_t id;
int r; int r;
@ -2226,7 +2227,7 @@ int home_augment_status(
j = json_variant_ref(h->record->json); j = json_variant_ref(h->record->json);
v = json_variant_ref(json_variant_by_key(j, "status")); v = json_variant_ref(json_variant_by_key(j, "status"));
m = json_variant_ref(json_variant_by_key(v, SD_ID128_TO_STRING(id))); m = json_variant_ref(json_variant_by_key(v, sd_id128_to_string(id, ids)));
r = json_variant_filter(&m, STRV_MAKE("diskSize", "diskUsage", "diskFree", "diskCeiling", "diskFloor", "signedLocally")); r = json_variant_filter(&m, STRV_MAKE("diskSize", "diskUsage", "diskFree", "diskCeiling", "diskFloor", "signedLocally"));
if (r < 0) if (r < 0)
@ -2236,7 +2237,7 @@ int home_augment_status(
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&v, SD_ID128_TO_STRING(id), m); r = json_variant_set_field(&v, ids, m);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -1487,10 +1487,10 @@ static int luks_format(
_cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL; _cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL;
_cleanup_(erase_and_freep) void *volume_key = NULL; _cleanup_(erase_and_freep) void *volume_key = NULL;
struct crypt_pbkdf_type good_pbkdf, minimal_pbkdf; struct crypt_pbkdf_type good_pbkdf, minimal_pbkdf;
char suuid[ID128_UUID_STRING_MAX], **pp;
_cleanup_free_ char *text = NULL; _cleanup_free_ char *text = NULL;
size_t volume_key_size; size_t volume_key_size;
int slot = 0, r; int slot = 0, r;
char **pp;
assert(node); assert(node);
assert(dm_name); assert(dm_name);
@ -1526,12 +1526,11 @@ static int luks_format(
build_good_pbkdf(&good_pbkdf, hr); build_good_pbkdf(&good_pbkdf, hr);
build_minimal_pbkdf(&minimal_pbkdf, hr); build_minimal_pbkdf(&minimal_pbkdf, hr);
r = sym_crypt_format( r = sym_crypt_format(cd,
cd,
CRYPT_LUKS2, CRYPT_LUKS2,
user_record_luks_cipher(hr), user_record_luks_cipher(hr),
user_record_luks_cipher_mode(hr), user_record_luks_cipher_mode(hr),
ID128_TO_UUID_STRING(uuid), id128_to_uuid_string(uuid, suuid),
volume_key, volume_key,
volume_key_size, volume_key_size,
&(struct crypt_params_luks2) { &(struct crypt_params_luks2) {
@ -1622,6 +1621,7 @@ static int make_partition_table(
_cleanup_free_ char *path = NULL, *disk_uuid_as_string = NULL; _cleanup_free_ char *path = NULL, *disk_uuid_as_string = NULL;
uint64_t offset, size; uint64_t offset, size;
sd_id128_t disk_uuid; sd_id128_t disk_uuid;
char uuids[ID128_UUID_STRING_MAX];
int r; int r;
assert(fd >= 0); assert(fd >= 0);
@ -1676,7 +1676,7 @@ static int make_partition_table(
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set partition name: %m"); return log_error_errno(r, "Failed to set partition name: %m");
r = fdisk_partition_set_uuid(p, ID128_TO_UUID_STRING(uuid)); r = fdisk_partition_set_uuid(p, id128_to_uuid_string(uuid, uuids));
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set partition UUID: %m"); return log_error_errno(r, "Failed to set partition UUID: %m");

View File

@ -24,6 +24,7 @@ int user_record_synthesize(
gid_t gid) { gid_t gid) {
_cleanup_free_ char *hd = NULL, *un = NULL, *ip = NULL, *rr = NULL, *user_name_and_realm = NULL; _cleanup_free_ char *hd = NULL, *un = NULL, *ip = NULL, *rr = NULL, *user_name_and_realm = NULL;
char smid[SD_ID128_STRING_MAX];
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -85,7 +86,7 @@ int user_record_synthesize(
JSON_BUILD_PAIR_CONDITION(!!rr, "realm", JSON_BUILD_STRING(realm)), JSON_BUILD_PAIR_CONDITION(!!rr, "realm", JSON_BUILD_STRING(realm)),
JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("regular")), JSON_BUILD_PAIR("disposition", JSON_BUILD_STRING("regular")),
JSON_BUILD_PAIR("binding", JSON_BUILD_OBJECT( JSON_BUILD_PAIR("binding", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT( JSON_BUILD_PAIR(sd_id128_to_string(mid, smid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("imagePath", JSON_BUILD_STRING(image_path)), JSON_BUILD_PAIR("imagePath", JSON_BUILD_STRING(image_path)),
JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING(hd)), JSON_BUILD_PAIR("homeDirectory", JSON_BUILD_STRING(hd)),
JSON_BUILD_PAIR("storage", JSON_BUILD_STRING(user_storage_to_string(storage))), JSON_BUILD_PAIR("storage", JSON_BUILD_STRING(user_storage_to_string(storage))),
@ -108,6 +109,7 @@ int user_record_synthesize(
int group_record_synthesize(GroupRecord *g, UserRecord *h) { int group_record_synthesize(GroupRecord *g, UserRecord *h) {
_cleanup_free_ char *un = NULL, *rr = NULL, *group_name_and_realm = NULL, *description = NULL; _cleanup_free_ char *un = NULL, *rr = NULL, *group_name_and_realm = NULL, *description = NULL;
char smid[SD_ID128_STRING_MAX];
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -145,11 +147,11 @@ int group_record_synthesize(GroupRecord *g, UserRecord *h) {
JSON_BUILD_PAIR_CONDITION(!!rr, "realm", JSON_BUILD_STRING(rr)), JSON_BUILD_PAIR_CONDITION(!!rr, "realm", JSON_BUILD_STRING(rr)),
JSON_BUILD_PAIR("description", JSON_BUILD_STRING(description)), JSON_BUILD_PAIR("description", JSON_BUILD_STRING(description)),
JSON_BUILD_PAIR("binding", JSON_BUILD_OBJECT( JSON_BUILD_PAIR("binding", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT( JSON_BUILD_PAIR(sd_id128_to_string(mid, smid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(user_record_gid(h))))))), JSON_BUILD_PAIR("gid", JSON_BUILD_UNSIGNED(user_record_gid(h))))))),
JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))), JSON_BUILD_PAIR_CONDITION(h->disposition >= 0, "disposition", JSON_BUILD_STRING(user_disposition_to_string(user_record_disposition(h)))),
JSON_BUILD_PAIR("status", JSON_BUILD_OBJECT( JSON_BUILD_PAIR("status", JSON_BUILD_OBJECT(
JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), JSON_BUILD_OBJECT( JSON_BUILD_PAIR(sd_id128_to_string(mid, smid), JSON_BUILD_OBJECT(
JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.Home")))))))); JSON_BUILD_PAIR("service", JSON_BUILD_STRING("io.systemd.Home"))))))));
if (r < 0) if (r < 0)
return r; return r;
@ -282,6 +284,7 @@ int user_record_add_binding(
gid_t gid) { gid_t gid) {
_cleanup_(json_variant_unrefp) JsonVariant *new_binding_entry = NULL, *binding = NULL; _cleanup_(json_variant_unrefp) JsonVariant *new_binding_entry = NULL, *binding = NULL;
char smid[SD_ID128_STRING_MAX], partition_uuids[ID128_UUID_STRING_MAX], luks_uuids[ID128_UUID_STRING_MAX], fs_uuids[ID128_UUID_STRING_MAX];
_cleanup_free_ char *ip = NULL, *hd = NULL, *ip_auto = NULL, *lc = NULL, *lcm = NULL, *fst = NULL; _cleanup_free_ char *ip = NULL, *hd = NULL, *ip_auto = NULL, *lc = NULL, *lcm = NULL, *fst = NULL;
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -294,6 +297,7 @@ int user_record_add_binding(
r = sd_id128_get_machine(&mid); r = sd_id128_get_machine(&mid);
if (r < 0) if (r < 0)
return r; return r;
sd_id128_to_string(mid, smid);
if (image_path) { if (image_path) {
ip = strdup(image_path); ip = strdup(image_path);
@ -332,9 +336,9 @@ int user_record_add_binding(
r = json_build(&new_binding_entry, r = json_build(&new_binding_entry,
JSON_BUILD_OBJECT( JSON_BUILD_OBJECT(
JSON_BUILD_PAIR_CONDITION(!!image_path, "imagePath", JSON_BUILD_STRING(image_path)), JSON_BUILD_PAIR_CONDITION(!!image_path, "imagePath", JSON_BUILD_STRING(image_path)),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(partition_uuid), "partitionUuid", JSON_BUILD_STRING(ID128_TO_UUID_STRING(partition_uuid))), JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(partition_uuid), "partitionUuid", JSON_BUILD_STRING(id128_to_uuid_string(partition_uuid, partition_uuids))),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(luks_uuid), "luksUuid", JSON_BUILD_STRING(ID128_TO_UUID_STRING(luks_uuid))), JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(luks_uuid), "luksUuid", JSON_BUILD_STRING(id128_to_uuid_string(luks_uuid, luks_uuids))),
JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(fs_uuid), "fileSystemUuid", JSON_BUILD_STRING(ID128_TO_UUID_STRING(fs_uuid))), JSON_BUILD_PAIR_CONDITION(!sd_id128_is_null(fs_uuid), "fileSystemUuid", JSON_BUILD_STRING(id128_to_uuid_string(fs_uuid, fs_uuids))),
JSON_BUILD_PAIR_CONDITION(!!luks_cipher, "luksCipher", JSON_BUILD_STRING(luks_cipher)), JSON_BUILD_PAIR_CONDITION(!!luks_cipher, "luksCipher", JSON_BUILD_STRING(luks_cipher)),
JSON_BUILD_PAIR_CONDITION(!!luks_cipher_mode, "luksCipherMode", JSON_BUILD_STRING(luks_cipher_mode)), JSON_BUILD_PAIR_CONDITION(!!luks_cipher_mode, "luksCipherMode", JSON_BUILD_STRING(luks_cipher_mode)),
JSON_BUILD_PAIR_CONDITION(luks_volume_key_size != UINT64_MAX, "luksVolumeKeySize", JSON_BUILD_UNSIGNED(luks_volume_key_size)), JSON_BUILD_PAIR_CONDITION(luks_volume_key_size != UINT64_MAX, "luksVolumeKeySize", JSON_BUILD_UNSIGNED(luks_volume_key_size)),
@ -351,7 +355,7 @@ int user_record_add_binding(
_cleanup_(json_variant_unrefp) JsonVariant *be = NULL; _cleanup_(json_variant_unrefp) JsonVariant *be = NULL;
/* Merge the new entry with an old one, if that exists */ /* Merge the new entry with an old one, if that exists */
be = json_variant_ref(json_variant_by_key(binding, SD_ID128_TO_STRING(mid))); be = json_variant_ref(json_variant_by_key(binding, smid));
if (be) { if (be) {
r = json_variant_merge(&be, new_binding_entry); r = json_variant_merge(&be, new_binding_entry);
if (r < 0) if (r < 0)
@ -362,7 +366,7 @@ int user_record_add_binding(
} }
} }
r = json_variant_set_field(&binding, SD_ID128_TO_STRING(mid), new_binding_entry); r = json_variant_set_field(&binding, smid, new_binding_entry);
if (r < 0) if (r < 0)
return r; return r;
@ -629,6 +633,7 @@ int user_record_test_recovery_key(UserRecord *h, UserRecord *secret) {
int user_record_set_disk_size(UserRecord *h, uint64_t disk_size) { int user_record_set_disk_size(UserRecord *h, uint64_t disk_size) {
_cleanup_(json_variant_unrefp) JsonVariant *new_per_machine = NULL, *midv = NULL, *midav = NULL, *ne = NULL; _cleanup_(json_variant_unrefp) JsonVariant *new_per_machine = NULL, *midv = NULL, *midav = NULL, *ne = NULL;
_cleanup_free_ JsonVariant **array = NULL; _cleanup_free_ JsonVariant **array = NULL;
char smid[SD_ID128_STRING_MAX];
size_t idx = SIZE_MAX, n; size_t idx = SIZE_MAX, n;
JsonVariant *per_machine; JsonVariant *per_machine;
sd_id128_t mid; sd_id128_t mid;
@ -646,7 +651,9 @@ int user_record_set_disk_size(UserRecord *h, uint64_t disk_size) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_new_string(&midv, SD_ID128_TO_STRING(mid)); sd_id128_to_string(mid, smid);
r = json_variant_new_string(&midv, smid);
if (r < 0) if (r < 0)
return r; return r;
@ -1201,6 +1208,7 @@ int user_record_merge_secret(UserRecord *h, UserRecord *secret) {
int user_record_good_authentication(UserRecord *h) { int user_record_good_authentication(UserRecord *h) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL; _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL;
char buf[SD_ID128_STRING_MAX];
uint64_t counter, usec; uint64_t counter, usec;
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -1227,7 +1235,7 @@ int user_record_good_authentication(UserRecord *h) {
v = json_variant_ref(h->json); v = json_variant_ref(h->json);
w = json_variant_ref(json_variant_by_key(v, "status")); w = json_variant_ref(json_variant_by_key(v, "status"));
z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid))); z = json_variant_ref(json_variant_by_key(w, sd_id128_to_string(mid, buf)));
r = json_variant_set_field_unsigned(&z, "goodAuthenticationCounter", counter); r = json_variant_set_field_unsigned(&z, "goodAuthenticationCounter", counter);
if (r < 0) if (r < 0)
@ -1237,7 +1245,7 @@ int user_record_good_authentication(UserRecord *h) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z); r = json_variant_set_field(&w, buf, z);
if (r < 0) if (r < 0)
return r; return r;
@ -1257,6 +1265,7 @@ int user_record_good_authentication(UserRecord *h) {
int user_record_bad_authentication(UserRecord *h) { int user_record_bad_authentication(UserRecord *h) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL; _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL;
char buf[SD_ID128_STRING_MAX];
uint64_t counter, usec; uint64_t counter, usec;
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -1283,7 +1292,7 @@ int user_record_bad_authentication(UserRecord *h) {
v = json_variant_ref(h->json); v = json_variant_ref(h->json);
w = json_variant_ref(json_variant_by_key(v, "status")); w = json_variant_ref(json_variant_by_key(v, "status"));
z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid))); z = json_variant_ref(json_variant_by_key(w, sd_id128_to_string(mid, buf)));
r = json_variant_set_field_unsigned(&z, "badAuthenticationCounter", counter); r = json_variant_set_field_unsigned(&z, "badAuthenticationCounter", counter);
if (r < 0) if (r < 0)
@ -1293,7 +1302,7 @@ int user_record_bad_authentication(UserRecord *h) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z); r = json_variant_set_field(&w, buf, z);
if (r < 0) if (r < 0)
return r; return r;
@ -1314,6 +1323,7 @@ int user_record_bad_authentication(UserRecord *h) {
int user_record_ratelimit(UserRecord *h) { int user_record_ratelimit(UserRecord *h) {
_cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL; _cleanup_(json_variant_unrefp) JsonVariant *v = NULL, *w = NULL, *z = NULL;
usec_t usec, new_ratelimit_begin_usec, new_ratelimit_count; usec_t usec, new_ratelimit_begin_usec, new_ratelimit_count;
char buf[SD_ID128_STRING_MAX];
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -1345,7 +1355,7 @@ int user_record_ratelimit(UserRecord *h) {
v = json_variant_ref(h->json); v = json_variant_ref(h->json);
w = json_variant_ref(json_variant_by_key(v, "status")); w = json_variant_ref(json_variant_by_key(v, "status"));
z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid))); z = json_variant_ref(json_variant_by_key(w, sd_id128_to_string(mid, buf)));
r = json_variant_set_field_unsigned(&z, "rateLimitBeginUSec", new_ratelimit_begin_usec); r = json_variant_set_field_unsigned(&z, "rateLimitBeginUSec", new_ratelimit_begin_usec);
if (r < 0) if (r < 0)
@ -1355,7 +1365,7 @@ int user_record_ratelimit(UserRecord *h) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z); r = json_variant_set_field(&w, buf, z);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -103,13 +103,14 @@ static ssize_t write_entry(char *buf, size_t size, Uploader *u) {
_fallthrough_; _fallthrough_;
case ENTRY_BOOT_ID: { case ENTRY_BOOT_ID: {
sd_id128_t boot_id; sd_id128_t boot_id;
char sid[SD_ID128_STRING_MAX];
r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id); r = sd_journal_get_monotonic_usec(u->journal, NULL, &boot_id);
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to get monotonic timestamp: %m"); return log_error_errno(r, "Failed to get monotonic timestamp: %m");
r = snprintf(buf + pos, size - pos, r = snprintf(buf + pos, size - pos,
"_BOOT_ID=%s\n", SD_ID128_TO_STRING(boot_id)); "_BOOT_ID=%s\n", sd_id128_to_string(boot_id, sid));
assert(r >= 0); assert(r >= 0);
if ((size_t) r > size - pos) if ((size_t) r > size - pos)
/* not enough space */ /* not enough space */

View File

@ -186,6 +186,7 @@ int icmp6_receive(int fd, void *buffer, size_t size, struct in6_addr *ret_dst,
/* namelen == 0 only happens when running the test-suite over a socketpair */ /* namelen == 0 only happens when running the test-suite over a socketpair */
assert(!(msg.msg_flags & MSG_CTRUNC));
assert(!(msg.msg_flags & MSG_TRUNC)); assert(!(msg.msg_flags & MSG_TRUNC));
CMSG_FOREACH(cmsg, &msg) { CMSG_FOREACH(cmsg, &msg) {

View File

@ -2873,6 +2873,7 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) {
r = sd_bus_message_new_method_return(m, &reply); r = sd_bus_message_new_method_return(m, &reply);
else if (streq_ptr(m->member, "GetMachineId")) { else if (streq_ptr(m->member, "GetMachineId")) {
sd_id128_t id; sd_id128_t id;
char sid[SD_ID128_STRING_MAX];
r = sd_id128_get_machine(&id); r = sd_id128_get_machine(&id);
if (r < 0) if (r < 0)
@ -2882,7 +2883,7 @@ static int process_builtin(sd_bus *bus, sd_bus_message *m) {
if (r < 0) if (r < 0)
return r; return r;
r = sd_bus_message_append(reply, "s", SD_ID128_TO_STRING(id)); r = sd_bus_message_append(reply, "s", sd_id128_to_string(id, sid));
} else { } else {
r = sd_bus_message_new_method_errorf( r = sd_bus_message_new_method_errorf(
m, &reply, m, &reply,

View File

@ -2159,6 +2159,7 @@ _public_ int sd_device_trigger_with_uuid(
sd_device_action_t action, sd_device_action_t action,
sd_id128_t *ret_uuid) { sd_id128_t *ret_uuid) {
char buf[ID128_UUID_STRING_MAX];
const char *s, *j; const char *s, *j;
sd_id128_t u; sd_id128_t u;
int r; int r;
@ -2177,7 +2178,8 @@ _public_ int sd_device_trigger_with_uuid(
if (r < 0) if (r < 0)
return r; return r;
j = strjoina(s, " ", ID128_TO_UUID_STRING(u)); id128_to_uuid_string(u, buf);
j = strjoina(s, " ", buf);
r = sd_device_set_sysattr_value(device, "uevent", j); r = sd_device_set_sysattr_value(device, "uevent", j);
if (r < 0) if (r < 0)

View File

@ -12,8 +12,6 @@
char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]); char *id128_to_uuid_string(sd_id128_t id, char s[static ID128_UUID_STRING_MAX]);
#define ID128_TO_UUID_STRING(id) id128_to_uuid_string((id), (char[ID128_UUID_STRING_MAX]) {})
bool id128_is_valid(const char *s) _pure_; bool id128_is_valid(const char *s) _pure_;
typedef enum Id128Format { typedef enum Id128Format {

View File

@ -3273,6 +3273,7 @@ fail:
#define FORMAT_TIMESTAMP_SAFE(t) (FORMAT_TIMESTAMP(t) ?: " --- ") #define FORMAT_TIMESTAMP_SAFE(t) (FORMAT_TIMESTAMP(t) ?: " --- ")
void journal_file_print_header(JournalFile *f) { void journal_file_print_header(JournalFile *f) {
char a[SD_ID128_STRING_MAX], b[SD_ID128_STRING_MAX], c[SD_ID128_STRING_MAX], d[SD_ID128_STRING_MAX];
struct stat st; struct stat st;
assert(f); assert(f);
@ -3299,10 +3300,10 @@ void journal_file_print_header(JournalFile *f) {
"Objects: %"PRIu64"\n" "Objects: %"PRIu64"\n"
"Entry objects: %"PRIu64"\n", "Entry objects: %"PRIu64"\n",
f->path, f->path,
SD_ID128_TO_STRING(f->header->file_id), sd_id128_to_string(f->header->file_id, a),
SD_ID128_TO_STRING(f->header->machine_id), sd_id128_to_string(f->header->machine_id, b),
SD_ID128_TO_STRING(f->header->boot_id), sd_id128_to_string(f->header->boot_id, c),
SD_ID128_TO_STRING(f->header->seqnum_id), sd_id128_to_string(f->header->seqnum_id, d),
f->header->state == STATE_OFFLINE ? "OFFLINE" : f->header->state == STATE_OFFLINE ? "OFFLINE" :
f->header->state == STATE_ONLINE ? "ONLINE" : f->header->state == STATE_ONLINE ? "ONLINE" :
f->header->state == STATE_ARCHIVED ? "ARCHIVED" : "UNKNOWN", f->header->state == STATE_ARCHIVED ? "ARCHIVED" : "UNKNOWN",

View File

@ -920,6 +920,7 @@ _public_ int sd_journal_previous_skip(sd_journal *j, uint64_t skip) {
_public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) { _public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) {
Object *o; Object *o;
int r; int r;
char bid[SD_ID128_STRING_MAX], sid[SD_ID128_STRING_MAX];
assert_return(j, -EINVAL); assert_return(j, -EINVAL);
assert_return(!journal_pid_changed(j), -ECHILD); assert_return(!journal_pid_changed(j), -ECHILD);
@ -932,10 +933,13 @@ _public_ int sd_journal_get_cursor(sd_journal *j, char **cursor) {
if (r < 0) if (r < 0)
return r; return r;
sd_id128_to_string(j->current_file->header->seqnum_id, sid);
sd_id128_to_string(o->entry.boot_id, bid);
if (asprintf(cursor, if (asprintf(cursor,
"s=%s;i=%"PRIx64";b=%s;m=%"PRIx64";t=%"PRIx64";x=%"PRIx64, "s=%s;i=%"PRIx64";b=%s;m=%"PRIx64";t=%"PRIx64";x=%"PRIx64,
SD_ID128_TO_STRING(j->current_file->header->seqnum_id), le64toh(o->entry.seqnum), sid, le64toh(o->entry.seqnum),
SD_ID128_TO_STRING(o->entry.boot_id), le64toh(o->entry.monotonic), bid, le64toh(o->entry.monotonic),
le64toh(o->entry.realtime), le64toh(o->entry.realtime),
le64toh(o->entry.xor_hash)) < 0) le64toh(o->entry.xor_hash)) < 0)
return -ENOMEM; return -ENOMEM;

View File

@ -127,6 +127,7 @@ static int run(int argc, char *argv[]) {
_cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL; _cleanup_(loop_device_unrefp) LoopDevice *loop_device = NULL;
_cleanup_(decrypted_image_unrefp) DecryptedImage *decrypted_image = NULL; _cleanup_(decrypted_image_unrefp) DecryptedImage *decrypted_image = NULL;
_cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL; _cleanup_(umount_and_rmdir_and_freep) char *unlink_dir = NULL;
char buf[SD_ID128_STRING_MAX];
sd_id128_t id; sd_id128_t id;
int r; int r;
@ -176,7 +177,7 @@ static int run(int argc, char *argv[]) {
} }
if (arg_print) if (arg_print)
puts(SD_ID128_TO_STRING(id)); puts(sd_id128_to_string(id, buf));
return 0; return 0;
} }

View File

@ -281,6 +281,7 @@ static int lldp_send_packet(
} }
static int link_send_lldp(Link *link) { static int link_send_lldp(Link *link) {
char machine_id_string[SD_ID128_STRING_MAX];
_cleanup_free_ char *hostname = NULL, *pretty_hostname = NULL; _cleanup_free_ char *hostname = NULL, *pretty_hostname = NULL;
_cleanup_free_ void *packet = NULL; _cleanup_free_ void *packet = NULL;
size_t packet_size = 0; size_t packet_size = 0;
@ -312,7 +313,7 @@ static int link_send_lldp(Link *link) {
r = lldp_make_packet(link->network->lldp_emit, r = lldp_make_packet(link->network->lldp_emit,
&link->hw_addr.ether, &link->hw_addr.ether,
SD_ID128_TO_STRING(machine_id), sd_id128_to_string(machine_id, machine_id_string),
link->ifname, link->ifname,
(uint16_t) ttl, (uint16_t) ttl,
link->network ? link->network->description : NULL, link->network ? link->network->description : NULL,

View File

@ -536,9 +536,9 @@ static int ndisc_request_address(Address *in, Link *link, sd_ndisc_router *rt) {
static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) { static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
_cleanup_(route_freep) Route *route = NULL; _cleanup_(route_freep) Route *route = NULL;
struct in6_addr gateway; struct in6_addr gateway;
uint32_t table, mtu = 0;
unsigned preference;
uint16_t lifetime; uint16_t lifetime;
unsigned preference;
uint32_t table, mtu;
usec_t time_now; usec_t time_now;
int r; int r;
@ -575,11 +575,11 @@ static int ndisc_router_process_default(Link *link, sd_ndisc_router *rt) {
if (r < 0) if (r < 0)
return log_link_error_errno(link, r, "Failed to get RA timestamp: %m"); return log_link_error_errno(link, r, "Failed to get RA timestamp: %m");
if (link->network->ipv6_accept_ra_use_mtu) {
r = sd_ndisc_router_get_mtu(rt, &mtu); r = sd_ndisc_router_get_mtu(rt, &mtu);
if (r < 0 && r != -ENODATA) if (r == -ENODATA)
mtu = 0;
else if (r < 0)
return log_link_error_errno(link, r, "Failed to get default router MTU from RA: %m"); return log_link_error_errno(link, r, "Failed to get default router MTU from RA: %m");
}
table = link_get_ipv6_accept_ra_route_table(link); table = link_get_ipv6_accept_ra_route_table(link);

View File

@ -256,7 +256,6 @@ IPv6AcceptRA.UseAutonomousPrefix, config_parse_bool,
IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix) IPv6AcceptRA.UseOnLinkPrefix, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_onlink_prefix)
IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns) IPv6AcceptRA.UseDNS, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_dns)
IPv6AcceptRA.UseDomains, config_parse_ipv6_accept_ra_use_domains, 0, offsetof(Network, ipv6_accept_ra_use_domains) IPv6AcceptRA.UseDomains, config_parse_ipv6_accept_ra_use_domains, 0, offsetof(Network, ipv6_accept_ra_use_domains)
IPv6AcceptRA.UseMTU, config_parse_bool, 0, offsetof(Network, ipv6_accept_ra_use_mtu)
IPv6AcceptRA.DHCPv6Client, config_parse_ipv6_accept_ra_start_dhcp6_client, 0, offsetof(Network, ipv6_accept_ra_start_dhcp6_client) IPv6AcceptRA.DHCPv6Client, config_parse_ipv6_accept_ra_start_dhcp6_client, 0, offsetof(Network, ipv6_accept_ra_start_dhcp6_client)
IPv6AcceptRA.RouteTable, config_parse_section_route_table, 0, 0 IPv6AcceptRA.RouteTable, config_parse_section_route_table, 0, 0
IPv6AcceptRA.RouteMetric, config_parse_dhcp_route_metric, 0, 0 IPv6AcceptRA.RouteMetric, config_parse_dhcp_route_metric, 0, 0

View File

@ -400,16 +400,15 @@ int network_load_one(Manager *manager, OrderedHashmap **networks, const char *fi
.ipv4_accept_local = -1, .ipv4_accept_local = -1,
.ipv4_route_localnet = -1, .ipv4_route_localnet = -1,
.ipv6_privacy_extensions = IPV6_PRIVACY_EXTENSIONS_NO, .ipv6_privacy_extensions = IPV6_PRIVACY_EXTENSIONS_NO,
.ipv6_accept_ra = -1,
.ipv6_dad_transmits = -1, .ipv6_dad_transmits = -1,
.ipv6_hop_limit = -1, .ipv6_hop_limit = -1,
.ipv6_proxy_ndp = -1, .ipv6_proxy_ndp = -1,
.proxy_arp = -1, .proxy_arp = -1,
.ipv6_accept_ra = -1,
.ipv6_accept_ra_use_dns = true, .ipv6_accept_ra_use_dns = true,
.ipv6_accept_ra_use_autonomous_prefix = true, .ipv6_accept_ra_use_autonomous_prefix = true,
.ipv6_accept_ra_use_onlink_prefix = true, .ipv6_accept_ra_use_onlink_prefix = true,
.ipv6_accept_ra_use_mtu = true,
.ipv6_accept_ra_route_table = RT_TABLE_MAIN, .ipv6_accept_ra_route_table = RT_TABLE_MAIN,
.ipv6_accept_ra_route_metric = DHCP_ROUTE_METRIC, .ipv6_accept_ra_route_metric = DHCP_ROUTE_METRIC,
.ipv6_accept_ra_start_dhcp6_client = IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES, .ipv6_accept_ra_start_dhcp6_client = IPV6_ACCEPT_RA_START_DHCP6_CLIENT_YES,

View File

@ -301,7 +301,6 @@ struct Network {
bool ipv6_accept_ra_use_dns; bool ipv6_accept_ra_use_dns;
bool ipv6_accept_ra_use_autonomous_prefix; bool ipv6_accept_ra_use_autonomous_prefix;
bool ipv6_accept_ra_use_onlink_prefix; bool ipv6_accept_ra_use_onlink_prefix;
bool ipv6_accept_ra_use_mtu;
bool active_slave; bool active_slave;
bool primary_slave; bool primary_slave;
DHCPUseDomains ipv6_accept_ra_use_domains; DHCPUseDomains ipv6_accept_ra_use_domains;

View File

@ -2550,6 +2550,7 @@ static int setup_hostname(void) {
static int setup_journal(const char *directory) { static int setup_journal(const char *directory) {
_cleanup_free_ char *d = NULL; _cleanup_free_ char *d = NULL;
char id[SD_ID128_STRING_MAX];
const char *dirname, *p, *q; const char *dirname, *p, *q;
sd_id128_t this_id; sd_id128_t this_id;
bool try; bool try;
@ -2570,7 +2571,7 @@ static int setup_journal(const char *directory) {
if (sd_id128_equal(arg_uuid, this_id)) { if (sd_id128_equal(arg_uuid, this_id)) {
log_full(try ? LOG_WARNING : LOG_ERR, log_full(try ? LOG_WARNING : LOG_ERR,
"Host and machine ids are equal (%s): refusing to link journals", SD_ID128_TO_STRING(arg_uuid)); "Host and machine ids are equal (%s): refusing to link journals", sd_id128_to_string(arg_uuid, id));
if (try) if (try)
return 0; return 0;
return -EEXIST; return -EEXIST;
@ -2586,7 +2587,9 @@ static int setup_journal(const char *directory) {
} }
} }
p = strjoina("/var/log/journal/", SD_ID128_TO_STRING(arg_uuid)); (void) sd_id128_to_string(arg_uuid, id);
p = strjoina("/var/log/journal/", id);
q = prefix_roota(directory, p); q = prefix_roota(directory, p);
if (path_is_mount_point(p, NULL, 0) > 0) { if (path_is_mount_point(p, NULL, 0) > 0) {
@ -3180,6 +3183,7 @@ static int inner_child(
char **os_release_pairs) { char **os_release_pairs) {
_cleanup_free_ char *home = NULL; _cleanup_free_ char *home = NULL;
char as_uuid[ID128_UUID_STRING_MAX];
size_t n_env = 1; size_t n_env = 1;
char *envp[] = { char *envp[] = {
(char*) "PATH=" DEFAULT_PATH_COMPAT, (char*) "PATH=" DEFAULT_PATH_COMPAT,
@ -3428,7 +3432,7 @@ static int inner_child(
assert(!sd_id128_is_null(arg_uuid)); assert(!sd_id128_is_null(arg_uuid));
if (asprintf(envp + n_env++, "container_uuid=%s", ID128_TO_UUID_STRING(arg_uuid)) < 0) if (asprintf(envp + n_env++, "container_uuid=%s", id128_to_uuid_string(arg_uuid, as_uuid)) < 0)
return log_oom(); return log_oom();
if (fdset_size(fds) > 0) { if (fdset_size(fds) > 0) {

View File

@ -2115,6 +2115,7 @@ static void context_bar_char_process_partition(
static int partition_hint(const Partition *p, const char *node, char **ret) { static int partition_hint(const Partition *p, const char *node, char **ret) {
_cleanup_free_ char *buf = NULL; _cleanup_free_ char *buf = NULL;
char ids[ID128_UUID_STRING_MAX];
const char *label; const char *label;
sd_id128_t id; sd_id128_t id;
@ -2143,7 +2144,7 @@ static int partition_hint(const Partition *p, const char *node, char **ret) {
else else
id = p->type_uuid; id = p->type_uuid;
buf = strdup(ID128_TO_UUID_STRING(id)); buf = strdup(id128_to_uuid_string(id, ids));
done: done:
if (!buf) if (!buf)
@ -2543,6 +2544,7 @@ static int partition_encrypt(
_cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL; _cleanup_(sym_crypt_freep) struct crypt_device *cd = NULL;
_cleanup_(erase_and_freep) void *volume_key = NULL; _cleanup_(erase_and_freep) void *volume_key = NULL;
_cleanup_free_ char *dm_name = NULL, *vol = NULL; _cleanup_free_ char *dm_name = NULL, *vol = NULL;
char suuid[ID128_UUID_STRING_MAX];
size_t volume_key_size = 256 / 8; size_t volume_key_size = 256 / 8;
sd_id128_t uuid; sd_id128_t uuid;
int r; int r;
@ -2589,7 +2591,7 @@ static int partition_encrypt(
CRYPT_LUKS2, CRYPT_LUKS2,
"aes", "aes",
"xts-plain64", "xts-plain64",
ID128_TO_UUID_STRING(uuid), id128_to_uuid_string(uuid, suuid),
volume_key, volume_key,
volume_key_size, volume_key_size,
&(struct crypt_params_luks2) { &(struct crypt_params_luks2) {
@ -3338,9 +3340,11 @@ static int context_mangle_partitions(Context *context) {
} }
if (!sd_id128_equal(p->new_uuid, p->current_uuid)) { if (!sd_id128_equal(p->new_uuid, p->current_uuid)) {
char buf[ID128_UUID_STRING_MAX];
assert(!sd_id128_is_null(p->new_uuid)); assert(!sd_id128_is_null(p->new_uuid));
r = fdisk_partition_set_uuid(p->current_partition, ID128_TO_UUID_STRING(p->new_uuid)); r = fdisk_partition_set_uuid(p->current_partition, id128_to_uuid_string(p->new_uuid, buf));
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set partition UUID: %m"); return log_error_errno(r, "Failed to set partition UUID: %m");
@ -3367,6 +3371,7 @@ static int context_mangle_partitions(Context *context) {
} else { } else {
_cleanup_(fdisk_unref_partitionp) struct fdisk_partition *q = NULL; _cleanup_(fdisk_unref_partitionp) struct fdisk_partition *q = NULL;
_cleanup_(fdisk_unref_parttypep) struct fdisk_parttype *t = NULL; _cleanup_(fdisk_unref_parttypep) struct fdisk_parttype *t = NULL;
char ids[ID128_UUID_STRING_MAX];
assert(!p->new_partition); assert(!p->new_partition);
assert(p->offset % 512 == 0); assert(p->offset % 512 == 0);
@ -3378,7 +3383,7 @@ static int context_mangle_partitions(Context *context) {
if (!t) if (!t)
return log_oom(); return log_oom();
r = fdisk_parttype_set_typestr(t, ID128_TO_UUID_STRING(p->type_uuid)); r = fdisk_parttype_set_typestr(t, id128_to_uuid_string(p->type_uuid, ids));
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to initialize partition type: %m"); return log_error_errno(r, "Failed to initialize partition type: %m");
@ -3406,7 +3411,7 @@ static int context_mangle_partitions(Context *context) {
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set partition number: %m"); return log_error_errno(r, "Failed to set partition number: %m");
r = fdisk_partition_set_uuid(q, ID128_TO_UUID_STRING(p->new_uuid)); r = fdisk_partition_set_uuid(q, id128_to_uuid_string(p->new_uuid, ids));
if (r < 0) if (r < 0)
return log_error_errno(r, "Failed to set partition UUID: %m"); return log_error_errno(r, "Failed to set partition UUID: %m");

View File

@ -2551,11 +2551,15 @@ static int table_data_to_json(TableData *d, JsonVariant **ret) {
case TABLE_IN6_ADDR: case TABLE_IN6_ADDR:
return json_variant_new_array_bytes(ret, &d->address, FAMILY_ADDRESS_SIZE(AF_INET6)); return json_variant_new_array_bytes(ret, &d->address, FAMILY_ADDRESS_SIZE(AF_INET6));
case TABLE_ID128: case TABLE_ID128: {
return json_variant_new_string(ret, SD_ID128_TO_STRING(d->id128)); char buf[SD_ID128_STRING_MAX];
return json_variant_new_string(ret, sd_id128_to_string(d->id128, buf));
}
case TABLE_UUID: case TABLE_UUID: {
return json_variant_new_string(ret, ID128_TO_UUID_STRING(d->id128)); char buf[ID128_UUID_STRING_MAX];
return json_variant_new_string(ret, id128_to_uuid_string(d->id128, buf));
}
case TABLE_UID: case TABLE_UID:
if (!uid_is_valid(d->uid)) if (!uid_is_valid(d->uid))

View File

@ -59,6 +59,7 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
{}, {},
}; };
char smid[SD_ID128_STRING_MAX];
JsonVariant *m; JsonVariant *m;
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -73,7 +74,7 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
if (r < 0) if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m"); return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid)); m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
if (!m) if (!m)
return 0; return 0;
@ -145,6 +146,7 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
{}, {},
}; };
char smid[SD_ID128_STRING_MAX];
JsonVariant *m; JsonVariant *m;
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -159,7 +161,7 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
if (r < 0) if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m"); return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid)); m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
if (!m) if (!m)
return 0; return 0;

View File

@ -447,7 +447,9 @@ int json_variant_new_hex(JsonVariant **ret, const void *p, size_t n) {
} }
int json_variant_new_id128(JsonVariant **ret, sd_id128_t id) { int json_variant_new_id128(JsonVariant **ret, sd_id128_t id) {
return json_variant_new_string(ret, SD_ID128_TO_STRING(id)); char s[SD_ID128_STRING_MAX];
return json_variant_new_string(ret, sd_id128_to_string(id, s));
} }
static void json_variant_set(JsonVariant *a, JsonVariant *b) { static void json_variant_set(JsonVariant *a, JsonVariant *b) {

View File

@ -752,12 +752,13 @@ static int output_export(
const Set *output_fields, const Set *output_fields,
const size_t highlight[2]) { const size_t highlight[2]) {
_cleanup_free_ char *cursor = NULL;
usec_t realtime, monotonic;
sd_id128_t boot_id; sd_id128_t boot_id;
char sid[SD_ID128_STRING_MAX];
int r;
usec_t realtime, monotonic;
_cleanup_free_ char *cursor = NULL;
const void *data; const void *data;
size_t length; size_t length;
int r;
assert(j); assert(j);
@ -783,7 +784,7 @@ static int output_export(
cursor, cursor,
realtime, realtime,
monotonic, monotonic,
SD_ID128_TO_STRING(boot_id)); sd_id128_to_string(boot_id, sid));
JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) { JOURNAL_FOREACH_DATA_RETVAL(j, data, length, r) {
size_t fieldlen; size_t fieldlen;

View File

@ -65,11 +65,15 @@ int make_filesystem(
if (r < 0) if (r < 0)
return r; return r;
if (r == 0) { if (r == 0) {
char suuid[ID128_UUID_STRING_MAX];
/* Child */ /* Child */
id128_to_uuid_string(uuid, suuid);
if (streq(fstype, "ext4")) if (streq(fstype, "ext4"))
(void) execlp(mkfs, mkfs, (void) execlp(mkfs, mkfs,
"-L", label, "-L", label,
"-U", ID128_TO_UUID_STRING(uuid), "-U", suuid,
"-I", "256", "-I", "256",
"-O", "has_journal", "-O", "has_journal",
"-m", "0", "-m", "0",
@ -78,14 +82,14 @@ int make_filesystem(
else if (streq(fstype, "btrfs")) { else if (streq(fstype, "btrfs")) {
if (discard) if (discard)
(void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), node, NULL); (void) execlp(mkfs, mkfs, "-L", label, "-U", suuid, node, NULL);
else else
(void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), "--nodiscard", node, NULL); (void) execlp(mkfs, mkfs, "-L", label, "-U", suuid, "--nodiscard", node, NULL);
} else if (streq(fstype, "xfs")) { } else if (streq(fstype, "xfs")) {
const char *j; const char *j;
j = strjoina("uuid=", ID128_TO_UUID_STRING(uuid)); j = strjoina("uuid=", suuid);
if (discard) if (discard)
(void) execlp(mkfs, mkfs, "-L", label, "-m", j, "-m", "reflink=1", node, NULL); (void) execlp(mkfs, mkfs, "-L", label, "-m", j, "-m", "reflink=1", node, NULL);
else else
@ -115,7 +119,7 @@ int make_filesystem(
(void) execlp(mkfs, mkfs, (void) execlp(mkfs, mkfs,
"-L", label, "-L", label,
"-U", ID128_TO_UUID_STRING(uuid), "-U", suuid,
node, NULL); node, NULL);
} else } else

View File

@ -1127,6 +1127,7 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
{}, {},
}; };
char smid[SD_ID128_STRING_MAX];
JsonVariant *m; JsonVariant *m;
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -1141,7 +1142,7 @@ static int dispatch_binding(const char *name, JsonVariant *variant, JsonDispatch
if (r < 0) if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m"); return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid)); m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
if (!m) if (!m)
return 0; return 0;
@ -1367,6 +1368,7 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
{}, {},
}; };
char smid[SD_ID128_STRING_MAX];
JsonVariant *m; JsonVariant *m;
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -1381,7 +1383,7 @@ static int dispatch_status(const char *name, JsonVariant *variant, JsonDispatchF
if (r < 0) if (r < 0)
return json_log(variant, flags, r, "Failed to determine machine ID: %m"); return json_log(variant, flags, r, "Failed to determine machine ID: %m");
m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid)); m = json_variant_by_key(variant, sd_id128_to_string(mid, smid));
if (!m) if (!m)
return 0; return 0;

View File

@ -34,13 +34,11 @@ union sd_id128 {
uint64_t qwords[2]; uint64_t qwords[2];
}; };
#define SD_ID128_STRING_MAX 33U #define SD_ID128_STRING_MAX 33
char *sd_id128_to_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX]); char *sd_id128_to_string(sd_id128_t id, char s[_SD_ARRAY_STATIC SD_ID128_STRING_MAX]);
int sd_id128_from_string(const char *s, sd_id128_t *ret); int sd_id128_from_string(const char *s, sd_id128_t *ret);
#define SD_ID128_TO_STRING(id) sd_id128_to_string((id), (char[SD_ID128_STRING_MAX]) {})
int sd_id128_randomize(sd_id128_t *ret); int sd_id128_randomize(sd_id128_t *ret);
int sd_id128_get_machine(sd_id128_t *ret); int sd_id128_get_machine(sd_id128_t *ret);

View File

@ -237,12 +237,16 @@ static void test_condition_test_ac_power(void) {
static void test_condition_test_host(void) { static void test_condition_test_host(void) {
_cleanup_free_ char *hostname = NULL; _cleanup_free_ char *hostname = NULL;
char sid[SD_ID128_STRING_MAX];
Condition *condition; Condition *condition;
sd_id128_t id; sd_id128_t id;
int r;
assert_se(sd_id128_get_machine(&id) >= 0); r = sd_id128_get_machine(&id);
assert_se(r >= 0);
assert_se(sd_id128_to_string(id, sid));
condition = condition_new(CONDITION_HOST, SD_ID128_TO_STRING(id), false, false); condition = condition_new(CONDITION_HOST, sid, false, false);
assert_se(condition); assert_se(condition);
assert_se(condition_test(condition, environ) > 0); assert_se(condition_test(condition, environ) > 0);
condition_free(condition); condition_free(condition);
@ -252,7 +256,7 @@ static void test_condition_test_host(void) {
assert_se(condition_test(condition, environ) == 0); assert_se(condition_test(condition, environ) == 0);
condition_free(condition); condition_free(condition);
condition = condition_new(CONDITION_HOST, SD_ID128_TO_STRING(id), false, true); condition = condition_new(CONDITION_HOST, sid, false, true);
assert_se(condition); assert_se(condition);
assert_se(condition_test(condition, environ) == 0); assert_se(condition_test(condition, environ) == 0);
condition_free(condition); condition_free(condition);

View File

@ -200,8 +200,9 @@ static void test_protect_kernel_logs(void) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *zz = NULL;
sd_id128_t bid; sd_id128_t bid;
char boot_id[SD_ID128_STRING_MAX];
_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *zz = NULL;
test_setup_logging(LOG_INFO); test_setup_logging(LOG_INFO);
@ -213,15 +214,16 @@ int main(int argc, char *argv[]) {
} }
assert_se(sd_id128_get_boot(&bid) >= 0); assert_se(sd_id128_get_boot(&bid) >= 0);
sd_id128_to_string(bid, boot_id);
x = strjoin("/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-abcd.service-"); x = strjoin("/tmp/systemd-private-", boot_id, "-abcd.service-");
y = strjoin("/var/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-abcd.service-"); y = strjoin("/var/tmp/systemd-private-", boot_id, "-abcd.service-");
assert_se(x && y); assert_se(x && y);
test_tmpdir("abcd.service", x, y); test_tmpdir("abcd.service", x, y);
z = strjoin("/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-"); z = strjoin("/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
zz = strjoin("/var/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-"); zz = strjoin("/var/tmp/systemd-private-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-");
assert_se(z && zz); assert_se(z && zz);

View File

@ -89,7 +89,5 @@ int main(void) {
printf("big_enum2_pos → %zu\n", sizeof(big_enum2_pos)); printf("big_enum2_pos → %zu\n", sizeof(big_enum2_pos));
printf("big_enum2_neg → %zu\n", sizeof(big_enum2_neg)); printf("big_enum2_neg → %zu\n", sizeof(big_enum2_neg));
printf("timeval: %zu\n", sizeof(struct timeval));
printf("timespec: %zu\n", sizeof(struct timespec));
return 0; return 0;
} }

View File

@ -416,7 +416,7 @@ static int manager_receive_response(sd_event_source *source, int fd, uint32_t re
.iov_base = &ntpmsg, .iov_base = &ntpmsg,
.iov_len = sizeof(ntpmsg), .iov_len = sizeof(ntpmsg),
}; };
CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct timespec))) control; CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct timeval))) control;
union sockaddr_union server_addr; union sockaddr_union server_addr;
struct msghdr msghdr = { struct msghdr msghdr = {
.msg_iov = &iov, .msg_iov = &iov,

View File

@ -37,6 +37,7 @@ typedef struct LookupParameters {
static int add_nss_service(JsonVariant **v) { static int add_nss_service(JsonVariant **v) {
_cleanup_(json_variant_unrefp) JsonVariant *status = NULL, *z = NULL; _cleanup_(json_variant_unrefp) JsonVariant *status = NULL, *z = NULL;
char buf[SD_ID128_STRING_MAX];
sd_id128_t mid; sd_id128_t mid;
int r; int r;
@ -53,7 +54,7 @@ static int add_nss_service(JsonVariant **v) {
return r; return r;
status = json_variant_ref(json_variant_by_key(*v, "status")); status = json_variant_ref(json_variant_by_key(*v, "status"));
z = json_variant_ref(json_variant_by_key(status, SD_ID128_TO_STRING(mid))); z = json_variant_ref(json_variant_by_key(status, sd_id128_to_string(mid, buf)));
if (json_variant_by_key(z, "service")) if (json_variant_by_key(z, "service"))
return 0; return 0;
@ -62,7 +63,7 @@ static int add_nss_service(JsonVariant **v) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&status, SD_ID128_TO_STRING(mid), z); r = json_variant_set_field(&status, buf, z);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -194,6 +194,7 @@ static int parse_proc_cmdline_item(const char *key, const char *value, void *dat
static int determine_devices(void) { static int determine_devices(void) {
_cleanup_free_ void *m = NULL; _cleanup_free_ void *m = NULL;
sd_id128_t root_uuid, verity_uuid; sd_id128_t root_uuid, verity_uuid;
char ids[ID128_UUID_STRING_MAX];
size_t l; size_t l;
int r; int r;
@ -216,7 +217,7 @@ static int determine_devices(void) {
if (!arg_data_what) { if (!arg_data_what) {
memcpy(&root_uuid, m, sizeof(root_uuid)); memcpy(&root_uuid, m, sizeof(root_uuid));
arg_data_what = path_join("/dev/disk/by-partuuid", ID128_TO_UUID_STRING(root_uuid)); arg_data_what = path_join("/dev/disk/by-partuuid", id128_to_uuid_string(root_uuid, ids));
if (!arg_data_what) if (!arg_data_what)
return log_oom(); return log_oom();
} }
@ -224,7 +225,7 @@ static int determine_devices(void) {
if (!arg_hash_what) { if (!arg_hash_what) {
memcpy(&verity_uuid, (uint8_t*) m + l - sizeof(verity_uuid), sizeof(verity_uuid)); memcpy(&verity_uuid, (uint8_t*) m + l - sizeof(verity_uuid), sizeof(verity_uuid));
arg_hash_what = path_join("/dev/disk/by-partuuid", ID128_TO_UUID_STRING(verity_uuid)); arg_hash_what = path_join("/dev/disk/by-partuuid", id128_to_uuid_string(verity_uuid, ids));
if (!arg_hash_what) if (!arg_hash_what)
return log_oom(); return log_oom();
} }

View File

@ -342,7 +342,6 @@ Label=
Prefix= Prefix=
[IPv6AcceptRA] [IPv6AcceptRA]
UseDomains= UseDomains=
UseMTU=
RouteTable= RouteTable=
RouteMetric= RouteMetric=
UseDNS= UseDNS=