1
0
mirror of https://github.com/systemd/systemd synced 2026-03-25 16:25:04 +01:00

Compare commits

...

11 Commits

Author SHA1 Message Date
Lennart Poettering
72fba0c4e5
Merge pull request #20488 from yuwata/timesync-fix
timesync: fix wrong type for receiving timestamp in nanoseconds
2021-08-20 13:34:20 +02:00
Lennart Poettering
fbe3d9591f
Merge pull request #20490 from poettering/id128-format-compound-literal
compound literal love for sd_id128_to_string()
2021-08-20 13:33:51 +02:00
Alfonso Sánchez-Beato
d48f9174cf src/boot/efi/linux: fix linux_exec prototype
Callers to linux_exec() are actually passing an EFI_HANDLE, not a pointer to
it. linux_efi_handover(), which is called by linux_exec(), also expects an
EFI_HANDLE.
2021-08-20 12:33:09 +02:00
Lennart Poettering
85b55869bc tree-wide: port everything over to new sd-id128 compund literal bliss 2021-08-20 11:09:48 +02:00
Lennart Poettering
c970388b22 sd-id128: add compound literal love to sd_id128_to_string() + id128_to_uuid_string() 2021-08-20 11:09:48 +02:00
Lennart Poettering
f3ce631bbc man: reference getrandom(2) instead of urandom from sd_id128_randomize() page
It's 2021, /dev/urandom is mostly a thing of the past now.
2021-08-20 11:09:48 +02:00
Lennart Poettering
7f3c90ed79 man: document SD_ID128_ALLF 2021-08-20 11:09:47 +02:00
Lennart Poettering
f47234b6e6 man: re-run ninja -C update-man-rules 2021-08-20 11:09:47 +02:00
Yu Watanabe
7d93b92f31 network: add UseMTU= in [IPv6AcceptRA]
Note that kernel has similar knob in sysctl: accept_ra_mtu.

Closes #18868.
2021-08-20 17:14:08 +09:00
Yu Watanabe
6da22a2fa5 icmp6: drop unnecessary assertion
Follow-up for 3691bcf3c5eebdcca5b4f1c51c745441c57a6cd1.
2021-08-20 08:44:31 +09:00
Yu Watanabe
6f96bdc587 timesync: fix wrong type for receiving timestamp in nanoseconds
Fixes #20482.
2021-08-20 08:42:13 +09:00
45 changed files with 185 additions and 216 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', ['initrd-release'], ''], ['os-release', '5', ['extension-release', '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,7 +633,10 @@ 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', '3', ['sd_id128_from_string'], ''], ['sd_id128_to_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,7 +90,10 @@
<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.</para> <constant>NUL</constant> bytes (i.e. all bits off).</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,12 +35,11 @@
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para><function>sd_id128_randomize()</function> generates a new <para><function>sd_id128_randomize()</function> generates a new randomized 128-bit ID and returns it in
randomized 128-bit ID and returns it in <parameter>ret</parameter>. Every invocation returns a new randomly generated ID. This uses the
<parameter>ret</parameter>. Every invocation returns a new <citerefentry
randomly generated ID. This uses the project='man-pages'><refentrytitle>getrandom</refentrytitle><manvolnum>2</manvolnum></citerefentry>
<filename>/dev/urandom</filename> kernel random number kernel random number generator.</para>
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
@ -72,7 +71,8 @@
<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><refentrytitle>random</refentrytitle><manvolnum>4</manvolnum></citerefentry>, <citerefentry project='man-pages'><refentrytitle>getrandom</refentrytitle><manvolnum>2</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,7 +17,9 @@
<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>
@ -25,9 +27,13 @@
<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>[33]</paramdef> <paramdef>sd_id128_t <parameter>id</parameter>, char <parameter>s</parameter>[static SD_ID128_STRING_MAX]</paramdef>
</funcprototype> </funcprototype>
<funcprototype> <funcprototype>
@ -41,47 +47,48 @@
<refsect1> <refsect1>
<title>Description</title> <title>Description</title>
<para><function>sd_id128_to_string()</function> formats a 128-bit <para><function>sd_id128_to_string()</function> formats a 128-bit ID as a character string. It expects
ID as a character string. It expects the ID and a string array the ID and a string array capable of storing 33 characters
capable of storing 33 characters. The ID will be formatted as 32 (<constant>SD_ID128_STRING_MAX</constant>). The ID will be formatted as 32 lowercase hexadecimal digits
lowercase hexadecimal digits and be terminated by a and be terminated by a <constant>NUL</constant> byte.</para>
<constant>NUL</constant> byte.</para>
<para><function>sd_id128_from_string()</function> implements the reverse operation: it takes a 33 character string <para><function>SD_ID128_TO_STRING()</function> is a macro that wraps
with 32 hexadecimal digits (either lowercase or uppercase, terminated by <constant>NUL</constant>) and parses them <function>sd_id128_to_string()</function> and passes an appropriately sized buffer as second argument,
back into a 128-bit ID returned in <parameter>ret</parameter>. Alternatively, this call can also parse a allocated as C99 compound literal. Each use will thus implicitly acquire a suitable buffer on the stack
37-character string with a 128-bit ID formatted as RFC UUID. If <parameter>ret</parameter> is passed as which remains valid until the end of the current code block. This is usually the simplest way to acquire
<constant>NULL</constant> the function will validate the passed ID string, but not actually return it in parsed a string representation of a 128-bit ID in a buffer that is valid in the current code block.</para>
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 i.e. according to <ulink url="https://tools.ietf.org/html/rfc4122">RFC4122</ulink> Variant 1 rules, even
rules, even if the UUID encodes a different variant. This matches behaviour in various other Linux if the UUID encodes a different variant. This matches behaviour in various other Linux userspace
userspace tools. It's probably wise to avoid UUIDs of other variant types.</para> tools. It's probably wise to avoid UUIDs of other variant types.</para>
<para>For more information about the <literal>sd_id128_t</literal> <para>For more information about the <literal>sd_id128_t</literal> type see
type see <citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>. Note that
<citerefentry><refentrytitle>sd-id128</refentrytitle><manvolnum>3</manvolnum></citerefentry>. these calls operate the same way on all architectures, i.e. the results do not depend on
Note that these calls operate the same way on all architectures, endianness.</para>
i.e. the results do not depend on endianness.</para>
<para>When formatting a 128-bit ID into a string, it is often <para>When formatting a 128-bit ID into a string, it is often easier to use a format string for
easier to use a format string for <citerefentry
<citerefentry project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>. project='man-pages'><refentrytitle>printf</refentrytitle><manvolnum>3</manvolnum></citerefentry>. This
This is easily done using the is easily done using the <constant>SD_ID128_FORMAT_STR</constant> and
<constant>SD_ID128_FORMAT_STR</constant> and <function>SD_ID128_FORMAT_VAL()</function> macros. For <function>SD_ID128_FORMAT_VAL()</function> macros. For more information see
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 <para><function>sd_id128_to_string()</function> always succeeds and returns a pointer to the string array
and returns a pointer to the string array passed in. passed in. <function>sd_id128_from_string()</function> returns 0 on success, in which case
<function>sd_id128_from_string()</function> returns 0 on success, in <parameter>ret</parameter> is filled in, or a negative errno-style error code.</para>
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,6 +2265,14 @@ 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,7 +918,6 @@ 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);
@ -931,7 +930,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, buf)); return rmdir_one(root, SD_ID128_TO_STRING(machine_id));
} }
static int remove_binaries(const char *esp_path) { static int remove_binaries(const char *esp_path) {
@ -1020,8 +1019,6 @@ 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;
@ -1041,12 +1038,15 @@ 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, machine_string)); fprintf(f, "default %s-*\n", SD_ID128_TO_STRING(machine_id));
} }
r = fflush_sync_and_check(f); r = fflush_sync_and_check(f);
@ -1065,7 +1065,6 @@ 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);
@ -1078,7 +1077,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, buf)); return mkdir_one(root, SD_ID128_TO_STRING(machine_id));
} }
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,9 +339,7 @@ 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 {
char m[SD_ID128_STRING_MAX]; r = table_add_cell(table, NULL, TABLE_ID128, &mid);
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,7 +738,6 @@ 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);
@ -749,7 +748,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, ids), 32, SD_ID128_TO_STRING(u->invocation_id), 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,7 +2497,6 @@ 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;
@ -2513,7 +2512,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, bid), "-", id, "-XXXXXX"); x = strjoin(prefix, "/systemd-private-", SD_ID128_TO_STRING(boot_id), "-", id, "-XXXXXX");
if (!x) if (!x)
return -ENOMEM; return -ENOMEM;

View File

@ -566,7 +566,6 @@ 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");
@ -576,7 +575,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, id), r = write_string_file(etc_machine_id, SD_ID128_TO_STRING(arg_machine_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,14 +817,13 @@ 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, mids)); r = json_variant_new_string(&mmid, SD_ID128_TO_STRING(mid));
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,7 +2163,6 @@ 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;
@ -2227,7 +2226,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, ids))); m = json_variant_ref(json_variant_by_key(v, SD_ID128_TO_STRING(id)));
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)
@ -2237,7 +2236,7 @@ int home_augment_status(
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&v, ids, m); r = json_variant_set_field(&v, SD_ID128_TO_STRING(id), 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,11 +1526,12 @@ 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(cd, r = sym_crypt_format(
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, suuid), ID128_TO_UUID_STRING(uuid),
volume_key, volume_key,
volume_key_size, volume_key_size,
&(struct crypt_params_luks2) { &(struct crypt_params_luks2) {
@ -1621,7 +1622,6 @@ 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, uuids)); r = fdisk_partition_set_uuid(p, ID128_TO_UUID_STRING(uuid));
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,7 +24,6 @@ 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;
@ -86,7 +85,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, smid), JSON_BUILD_OBJECT( JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), 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))),
@ -109,7 +108,6 @@ 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;
@ -147,11 +145,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, smid), JSON_BUILD_OBJECT( JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), 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, smid), JSON_BUILD_OBJECT( JSON_BUILD_PAIR(SD_ID128_TO_STRING(mid), 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;
@ -284,7 +282,6 @@ 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;
@ -297,7 +294,6 @@ 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);
@ -336,9 +332,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, partition_uuids))), 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(luks_uuid), "luksUuid", JSON_BUILD_STRING(id128_to_uuid_string(luks_uuid, luks_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(fs_uuid), "fileSystemUuid", JSON_BUILD_STRING(id128_to_uuid_string(fs_uuid, fs_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(!!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)),
@ -355,7 +351,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, smid)); be = json_variant_ref(json_variant_by_key(binding, SD_ID128_TO_STRING(mid)));
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)
@ -366,7 +362,7 @@ int user_record_add_binding(
} }
} }
r = json_variant_set_field(&binding, smid, new_binding_entry); r = json_variant_set_field(&binding, SD_ID128_TO_STRING(mid), new_binding_entry);
if (r < 0) if (r < 0)
return r; return r;
@ -633,7 +629,6 @@ 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;
@ -651,9 +646,7 @@ int user_record_set_disk_size(UserRecord *h, uint64_t disk_size) {
if (r < 0) if (r < 0)
return r; return r;
sd_id128_to_string(mid, smid); r = json_variant_new_string(&midv, SD_ID128_TO_STRING(mid));
r = json_variant_new_string(&midv, smid);
if (r < 0) if (r < 0)
return r; return r;
@ -1208,7 +1201,6 @@ 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;
@ -1235,7 +1227,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, buf))); z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid)));
r = json_variant_set_field_unsigned(&z, "goodAuthenticationCounter", counter); r = json_variant_set_field_unsigned(&z, "goodAuthenticationCounter", counter);
if (r < 0) if (r < 0)
@ -1245,7 +1237,7 @@ int user_record_good_authentication(UserRecord *h) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&w, buf, z); r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z);
if (r < 0) if (r < 0)
return r; return r;
@ -1265,7 +1257,6 @@ 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;
@ -1292,7 +1283,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, buf))); z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid)));
r = json_variant_set_field_unsigned(&z, "badAuthenticationCounter", counter); r = json_variant_set_field_unsigned(&z, "badAuthenticationCounter", counter);
if (r < 0) if (r < 0)
@ -1302,7 +1293,7 @@ int user_record_bad_authentication(UserRecord *h) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&w, buf, z); r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z);
if (r < 0) if (r < 0)
return r; return r;
@ -1323,7 +1314,6 @@ 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;
@ -1355,7 +1345,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, buf))); z = json_variant_ref(json_variant_by_key(w, SD_ID128_TO_STRING(mid)));
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)
@ -1365,7 +1355,7 @@ int user_record_ratelimit(UserRecord *h) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&w, buf, z); r = json_variant_set_field(&w, SD_ID128_TO_STRING(mid), z);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -103,14 +103,13 @@ 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, sid)); "_BOOT_ID=%s\n", SD_ID128_TO_STRING(boot_id));
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,7 +186,6 @@ 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,7 +2873,6 @@ 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)
@ -2883,7 +2882,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, sid)); r = sd_bus_message_append(reply, "s", SD_ID128_TO_STRING(id));
} else { } else {
r = sd_bus_message_new_method_errorf( r = sd_bus_message_new_method_errorf(
m, &reply, m, &reply,

View File

@ -2159,7 +2159,6 @@ _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;
@ -2178,8 +2177,7 @@ _public_ int sd_device_trigger_with_uuid(
if (r < 0) if (r < 0)
return r; return r;
id128_to_uuid_string(u, buf); j = strjoina(s, " ", ID128_TO_UUID_STRING(u));
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,6 +12,8 @@
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,7 +3273,6 @@ 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);
@ -3300,10 +3299,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, a), SD_ID128_TO_STRING(f->header->file_id),
sd_id128_to_string(f->header->machine_id, b), SD_ID128_TO_STRING(f->header->machine_id),
sd_id128_to_string(f->header->boot_id, c), SD_ID128_TO_STRING(f->header->boot_id),
sd_id128_to_string(f->header->seqnum_id, d), SD_ID128_TO_STRING(f->header->seqnum_id),
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,7 +920,6 @@ _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);
@ -933,13 +932,10 @@ _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,
sid, le64toh(o->entry.seqnum), SD_ID128_TO_STRING(j->current_file->header->seqnum_id), le64toh(o->entry.seqnum),
bid, le64toh(o->entry.monotonic), SD_ID128_TO_STRING(o->entry.boot_id), 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,7 +127,6 @@ 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;
@ -177,7 +176,7 @@ static int run(int argc, char *argv[]) {
} }
if (arg_print) if (arg_print)
puts(sd_id128_to_string(id, buf)); puts(SD_ID128_TO_STRING(id));
return 0; return 0;
} }

View File

@ -281,7 +281,6 @@ 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;
@ -313,7 +312,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, machine_id_string), SD_ID128_TO_STRING(machine_id),
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;
uint16_t lifetime; uint32_t table, mtu = 0;
unsigned preference; unsigned preference;
uint32_t table, mtu; uint16_t lifetime;
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 == -ENODATA) if (r < 0 && 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,6 +256,7 @@ 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,15 +400,16 @@ 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,6 +301,7 @@ 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,7 +2550,6 @@ 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;
@ -2571,7 +2570,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, id)); "Host and machine ids are equal (%s): refusing to link journals", SD_ID128_TO_STRING(arg_uuid));
if (try) if (try)
return 0; return 0;
return -EEXIST; return -EEXIST;
@ -2587,9 +2586,7 @@ static int setup_journal(const char *directory) {
} }
} }
(void) sd_id128_to_string(arg_uuid, id); p = strjoina("/var/log/journal/", SD_ID128_TO_STRING(arg_uuid));
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) {
@ -3183,7 +3180,6 @@ 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,
@ -3432,7 +3428,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, as_uuid)) < 0) if (asprintf(envp + n_env++, "container_uuid=%s", ID128_TO_UUID_STRING(arg_uuid)) < 0)
return log_oom(); return log_oom();
if (fdset_size(fds) > 0) { if (fdset_size(fds) > 0) {

View File

@ -2115,7 +2115,6 @@ 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;
@ -2144,7 +2143,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, ids)); buf = strdup(ID128_TO_UUID_STRING(id));
done: done:
if (!buf) if (!buf)
@ -2544,7 +2543,6 @@ 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;
@ -2591,7 +2589,7 @@ static int partition_encrypt(
CRYPT_LUKS2, CRYPT_LUKS2,
"aes", "aes",
"xts-plain64", "xts-plain64",
id128_to_uuid_string(uuid, suuid), ID128_TO_UUID_STRING(uuid),
volume_key, volume_key,
volume_key_size, volume_key_size,
&(struct crypt_params_luks2) { &(struct crypt_params_luks2) {
@ -3340,11 +3338,9 @@ 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, buf)); r = fdisk_partition_set_uuid(p->current_partition, ID128_TO_UUID_STRING(p->new_uuid));
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");
@ -3371,7 +3367,6 @@ 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);
@ -3383,7 +3378,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, ids)); r = fdisk_parttype_set_typestr(t, ID128_TO_UUID_STRING(p->type_uuid));
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");
@ -3411,7 +3406,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, ids)); r = fdisk_partition_set_uuid(q, ID128_TO_UUID_STRING(p->new_uuid));
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,15 +2551,11 @@ 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:
char buf[SD_ID128_STRING_MAX]; return json_variant_new_string(ret, SD_ID128_TO_STRING(d->id128));
return json_variant_new_string(ret, sd_id128_to_string(d->id128, buf));
}
case TABLE_UUID: { case TABLE_UUID:
char buf[ID128_UUID_STRING_MAX]; return json_variant_new_string(ret, ID128_TO_UUID_STRING(d->id128));
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,7 +59,6 @@ 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;
@ -74,7 +73,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, smid)); m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m) if (!m)
return 0; return 0;
@ -146,7 +145,6 @@ 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;
@ -161,7 +159,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, smid)); m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m) if (!m)
return 0; return 0;

View File

@ -447,9 +447,7 @@ 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) {
char s[SD_ID128_STRING_MAX]; return json_variant_new_string(ret, SD_ID128_TO_STRING(id));
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,13 +752,12 @@ static int output_export(
const Set *output_fields, const Set *output_fields,
const size_t highlight[2]) { const size_t highlight[2]) {
sd_id128_t boot_id;
char sid[SD_ID128_STRING_MAX];
int r;
usec_t realtime, monotonic;
_cleanup_free_ char *cursor = NULL; _cleanup_free_ char *cursor = NULL;
usec_t realtime, monotonic;
sd_id128_t boot_id;
const void *data; const void *data;
size_t length; size_t length;
int r;
assert(j); assert(j);
@ -784,7 +783,7 @@ static int output_export(
cursor, cursor,
realtime, realtime,
monotonic, monotonic,
sd_id128_to_string(boot_id, sid)); SD_ID128_TO_STRING(boot_id));
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,15 +65,11 @@ 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", suuid, "-U", ID128_TO_UUID_STRING(uuid),
"-I", "256", "-I", "256",
"-O", "has_journal", "-O", "has_journal",
"-m", "0", "-m", "0",
@ -82,14 +78,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", suuid, node, NULL); (void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), node, NULL);
else else
(void) execlp(mkfs, mkfs, "-L", label, "-U", suuid, "--nodiscard", node, NULL); (void) execlp(mkfs, mkfs, "-L", label, "-U", ID128_TO_UUID_STRING(uuid), "--nodiscard", node, NULL);
} else if (streq(fstype, "xfs")) { } else if (streq(fstype, "xfs")) {
const char *j; const char *j;
j = strjoina("uuid=", suuid); j = strjoina("uuid=", ID128_TO_UUID_STRING(uuid));
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
@ -119,7 +115,7 @@ int make_filesystem(
(void) execlp(mkfs, mkfs, (void) execlp(mkfs, mkfs,
"-L", label, "-L", label,
"-U", suuid, "-U", ID128_TO_UUID_STRING(uuid),
node, NULL); node, NULL);
} else } else

View File

@ -1127,7 +1127,6 @@ 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;
@ -1142,7 +1141,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, smid)); m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m) if (!m)
return 0; return 0;
@ -1368,7 +1367,6 @@ 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;
@ -1383,7 +1381,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, smid)); m = json_variant_by_key(variant, SD_ID128_TO_STRING(mid));
if (!m) if (!m)
return 0; return 0;

View File

@ -34,11 +34,13 @@ union sd_id128 {
uint64_t qwords[2]; uint64_t qwords[2];
}; };
#define SD_ID128_STRING_MAX 33 #define SD_ID128_STRING_MAX 33U
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,16 +237,12 @@ 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;
r = sd_id128_get_machine(&id); assert_se(sd_id128_get_machine(&id) >= 0);
assert_se(r >= 0);
assert_se(sd_id128_to_string(id, sid));
condition = condition_new(CONDITION_HOST, sid, false, false); condition = condition_new(CONDITION_HOST, SD_ID128_TO_STRING(id), 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);
@ -256,7 +252,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, sid, false, true); condition = condition_new(CONDITION_HOST, SD_ID128_TO_STRING(id), 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,9 +200,8 @@ static void test_protect_kernel_logs(void) {
} }
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
sd_id128_t bid;
char boot_id[SD_ID128_STRING_MAX];
_cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *zz = NULL; _cleanup_free_ char *x = NULL, *y = NULL, *z = NULL, *zz = NULL;
sd_id128_t bid;
test_setup_logging(LOG_INFO); test_setup_logging(LOG_INFO);
@ -214,16 +213,15 @@ 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-", boot_id, "-abcd.service-"); x = strjoin("/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-abcd.service-");
y = strjoin("/var/tmp/systemd-private-", boot_id, "-abcd.service-"); y = strjoin("/var/tmp/systemd-private-", SD_ID128_TO_STRING(bid), "-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-", boot_id, "-sys-devices-pci0000:00-0000:00:1a.0-usb3-3\\x2d1-3\\x2d1:1.0-bluetooth-hci0.device-"); 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-");
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-"); 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-");
assert_se(z && zz); assert_se(z && zz);

View File

@ -89,5 +89,7 @@ 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 timeval))) control; CMSG_BUFFER_TYPE(CMSG_SPACE(sizeof(struct timespec))) 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,7 +37,6 @@ 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;
@ -54,7 +53,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, buf))); z = json_variant_ref(json_variant_by_key(status, SD_ID128_TO_STRING(mid)));
if (json_variant_by_key(z, "service")) if (json_variant_by_key(z, "service"))
return 0; return 0;
@ -63,7 +62,7 @@ static int add_nss_service(JsonVariant **v) {
if (r < 0) if (r < 0)
return r; return r;
r = json_variant_set_field(&status, buf, z); r = json_variant_set_field(&status, SD_ID128_TO_STRING(mid), z);
if (r < 0) if (r < 0)
return r; return r;

View File

@ -194,7 +194,6 @@ 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;
@ -217,7 +216,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, ids)); arg_data_what = path_join("/dev/disk/by-partuuid", ID128_TO_UUID_STRING(root_uuid));
if (!arg_data_what) if (!arg_data_what)
return log_oom(); return log_oom();
} }
@ -225,7 +224,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, ids)); arg_hash_what = path_join("/dev/disk/by-partuuid", ID128_TO_UUID_STRING(verity_uuid));
if (!arg_hash_what) if (!arg_hash_what)
return log_oom(); return log_oom();
} }

View File

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