]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
4 months agosd-event: extend comment about a flex member 37790/head
Zbigniew Jędrzejewski-Szmek [Mon, 9 Jun 2025 14:11:17 +0000 (16:11 +0200)] 
sd-event: extend comment about a flex member

Follow-up for dbef4dd4f23517abfc73b35f0bdf004d2f8f4805. Everything that that
commit says is true, but — at least for me — it wasn't obvious why the code is
correct and we can do fixed-size allocations like new(struct inotify_data, 1).

4 months agosd-event: typedef struct inotify_data to InotifyData
Zbigniew Jędrzejewski-Szmek [Sun, 8 Jun 2025 12:01:16 +0000 (14:01 +0200)] 
sd-event: typedef struct inotify_data to InotifyData

4 months agosd-event: typedef struct inode_data to InodeData
Zbigniew Jędrzejewski-Szmek [Sun, 8 Jun 2025 11:52:59 +0000 (13:52 +0200)] 
sd-event: typedef struct inode_data to InodeData

This is an internal definition, so use the usual CamelCase typedef.

4 months agosd-event: make some more bools non-bitfield
Zbigniew Jędrzejewski-Szmek [Sun, 8 Jun 2025 11:41:31 +0000 (13:41 +0200)] 
sd-event: make some more bools non-bitfield

In sd_event_source.child, we have 5 bools. If we make them each take one byte,
the structure size increases. So let's do that for the three of them, and leave
the other two (less frequently used) squished into the last byte. This allows
more efficient code to be generated, without changing the size of the struct:

$ diff -u <(objdump -S build/src/shared/libsystemd-shared-258.so.0|awk '/^static void source_io_unregister/,/^\}/') \
          <(objdump -S build/src/shared/libsystemd-shared-258.so|awk '/^static void source_io_unregister/,/^\}/')

         s->io.registered = false;
-  34d46f:      48 8b 45 d8             mov    -0x28(%rbp),%rax
-  34d473:      0f b6 90 a4 00 00 00    movzbl 0xa4(%rax),%edx
-  34d47a:      83 e2 fe                and    $0xfffffffe,%edx
-  34d47d:      88 90 a4 00 00 00       mov    %dl,0xa4(%rax)
-  34d483:      eb 04                   jmp    34d489 <source_io_unregister+0x1ca>
+  34bffe:      48 8b 45 d8             mov    -0x28(%rbp),%rax
+  34c002:      c6 80 a4 00 00 00 00    movb   $0x0,0xa4(%rax)
+  34c009:      eb 04                   jmp    34c00f <source_io_unregister+0x1be>
                 return;

4 months agosd-event: drop some bitfield specifiers from struct sd_event_source
Zbigniew Jędrzejewski-Szmek [Sun, 8 Jun 2025 11:21:28 +0000 (13:21 +0200)] 
sd-event: drop some bitfield specifiers from struct sd_event_source

This does not change the size of the structure, because the size is determined
by .child, which has a 128-byte siginfo_t field. But by dropping the specifiers
we let the compiler generate code that operates on full bytes instead of having
to play with bitmasks, see second diff below.

Also move the bools in .memory_pressure into a gap to save a few bytes on
initialization.

$ diff -U100 <(pahole build/src/shared/libsystemd-shared-258.so.0 | awk '/struct sd_event_source/,/^}/') \
             <(pahole build/src/shared/libsystemd-shared-258.so | awk '/struct sd_event_source/,/^}/')
--- /proc/self/fd/11 2025-06-08 13:16:55.614738334 +0200
+++ /proc/self/fd/12 2025-06-08 13:16:55.615738386 +0200
@@ -1,109 +1,109 @@
 struct sd_event_source {
  WakeupType                 wakeup;               /*     0     4 */
  unsigned int               n_ref;                /*     4     4 */
  sd_event *                 event;                /*     8     8 */
  void *                     userdata;             /*    16     8 */
  sd_event_handler_t         prepare;              /*    24     8 */
  char *                     description;          /*    32     8 */
  EventSourceType            type;                 /*    40     4 */
        signed int                 enabled:3;            /*    44: 0  4 */
  _Bool                      pending:1;            /*    44: 3  1 */
  _Bool                      dispatching:1;        /*    44: 4  1 */
  _Bool                      floating:1;           /*    44: 5  1 */
  _Bool                      exit_on_failure:1;    /*    44: 6  1 */
  _Bool                      ratelimited:1;        /*    44: 7  1 */

  /* XXX 24 bits hole, try to pack */

  int64_t                    priority;             /*    48     8 */
  unsigned int               pending_index;        /*    56     4 */
  unsigned int               prepare_index;        /*    60     4 */
  /* --- cacheline 1 boundary (64 bytes) --- */
  uint64_t                   pending_iteration;    /*    64     8 */
  uint64_t                   prepare_iteration;    /*    72     8 */
  sd_event_destroy_t         destroy_callback;     /*    80     8 */
  sd_event_handler_t         ratelimit_expire_callback; /*    88     8 */
  sd_event_source *          sources_next;         /*    96     8 */
  sd_event_source *          sources_prev;         /*   104     8 */
  RateLimit                  rate_limit;           /*   112    24 */
  /* --- cacheline 2 boundary (128 bytes) was 8 bytes ago --- */
  unsigned int               earliest_index;       /*   136     4 */
  unsigned int               latest_index;         /*   140     4 */
  union {
  struct {
  sd_event_io_handler_t callback;  /*   144     8 */
  int        fd;                   /*   152     4 */
  uint32_t   events;               /*   156     4 */
  uint32_t   revents;              /*   160     4 */
- _Bool      registered:1;         /*   164: 0  1 */
- _Bool      owned:1;              /*   164: 1  1 */
+ _Bool      registered;           /*   164     1 */
+ _Bool      owned;                /*   165     1 */
  } io;                                    /*   144    24 */
  struct {
  sd_event_time_handler_t callback; /*   144     8 */
  usec_t     next;                 /*   152     8 */
  usec_t     accuracy;             /*   160     8 */
  } time;                                  /*   144    24 */
  struct {
  sd_event_signal_handler_t callback; /*   144     8 */
  struct signalfd_siginfo siginfo; /*   152   128 */
  /* --- cacheline 4 boundary (256 bytes) was 24 bytes ago --- */
  int        sig;                  /*   280     4 */
  _Bool      unblock;              /*   284     1 */
  } signal;                                /*   144   144 */
  struct {
  sd_event_child_handler_t callback; /*   144     8 */
  siginfo_t  siginfo;              /*   152   128 */
  /* --- cacheline 4 boundary (256 bytes) was 24 bytes ago --- */
  pid_t      pid;                  /*   280     4 */
  int        options;              /*   284     4 */
  int        pidfd;                /*   288     4 */
  _Bool      registered:1;         /*   292: 0  1 */
  _Bool      pidfd_owned:1;        /*   292: 1  1 */
  _Bool      process_owned:1;      /*   292: 2  1 */
  _Bool      exited:1;             /*   292: 3  1 */
  _Bool      waited:1;             /*   292: 4  1 */
  } child;                                 /*   144   152 */
  struct {
  sd_event_handler_t callback;     /*   144     8 */
  } defer;                                 /*   144     8 */
  struct {
  sd_event_handler_t callback;     /*   144     8 */
  } post;                                  /*   144     8 */
  struct {
  sd_event_handler_t callback;     /*   144     8 */
  unsigned int prioq_index;        /*   152     4 */
  } exit;                                  /*   144    16 */
  struct {
  sd_event_inotify_handler_t callback; /*   144     8 */
  uint32_t   mask;                 /*   152     4 */

  /* XXX 4 bytes hole, try to pack */

  struct inode_data * inode_data;  /*   160     8 */
  sd_event_source * by_inode_data_next; /*   168     8 */
  sd_event_source * by_inode_data_prev; /*   176     8 */
  } inotify;                               /*   144    40 */
  struct {
  int        fd;                   /*   144     4 */
+ _Bool      registered;           /*   148     1 */
+ _Bool      locked;               /*   149     1 */
+ _Bool      in_write_list;        /*   150     1 */

- /* XXX 4 bytes hole, try to pack */
+ /* XXX 1 byte hole, try to pack */

  sd_event_handler_t callback;     /*   152     8 */
  void *     write_buffer;         /*   160     8 */
  size_t     write_buffer_size;    /*   168     8 */
  uint32_t   events;               /*   176     4 */
  uint32_t   revents;              /*   180     4 */
  sd_event_source * write_list_next; /*   184     8 */
  /* --- cacheline 3 boundary (192 bytes) --- */
  sd_event_source * write_list_prev; /*   192     8 */
- _Bool      registered:1;         /*   200: 0  1 */
- _Bool      locked:1;             /*   200: 1  1 */
- _Bool      in_write_list:1;      /*   200: 2  1 */
- } memory_pressure;                       /*   144    64 */
+ } memory_pressure;                       /*   144    56 */
  };                                               /*   144   152 */

  /* size: 296, cachelines: 5, members: 26 */
  /* sum members: 292 */
  /* sum bitfield members: 8 bits, bit holes: 1, sum bit holes: 24 bits */
  /* last cacheline: 40 bytes */
 };

Example diff in assembly:

$ diff -u <(objdump -S build/src/shared/libsystemd-shared-258.so.0|awk '/^static void event_source_time_prioq_reshuffle/,/^\}/') \
          <(objdump -S build/src/shared/libsystemd-shared-258.so|awk '/^static void event_source_time_prioq_reshuffle/,/^\}/')

         d->needs_rearm = true;
-  34d80e:      48 8b 45 f8             mov    -0x8(%rbp),%rax
-  34d812:      0f b6 50 20             movzbl 0x20(%rax),%edx
-  34d816:      83 ca 01                or     $0x1,%edx
-  34d819:      88 50 20                mov    %dl,0x20(%rax)
-  34d81c:      eb 01                   jmp    34d81f <event_source_time_prioq_reshuffle+0x12c>
+  34d7c3:      48 8b 45 f8             mov    -0x8(%rbp),%rax
+  34d7c7:      c6 40 20 01             movb   $0x1,0x20(%rax)
+  34d7cb:      eb 01                   jmp    34d7ce <event_source_time_prioq_reshuffle+0x126>
                 return; /* no-op for an event source which is neither a timer nor ratelimited. */
-  34d81e:      90                      nop
+  34d7cd:      90                      nop

5 months agoforward: Drop socklen_t forward declaration
Daan De Meyer [Sat, 7 Jun 2025 17:23:45 +0000 (19:23 +0200)] 
forward: Drop socklen_t forward declaration

This is glibc specific and doesn't exist on musl, since removing only
means adding one more include in selinux-util.h, let's drop it.

Fixes #37779

5 months agonspawn: do basic port to PidRef
Lennart Poettering [Fri, 23 May 2025 15:22:40 +0000 (17:22 +0200)] 
nspawn: do basic port to PidRef

THis is sometimes a bit superficial, but in many cases allows us to use
pidfd for various of our operations.

5 months agomachined: open up machine registration for unpriv clients also via D-Bus
Lennart Poettering [Fri, 23 May 2025 12:09:55 +0000 (14:09 +0200)] 
machined: open up machine registration for unpriv clients also via D-Bus

This is already opened up via Varlink. Let's also open it up via D-Bus
with the same polikit operation.

5 months agomachined: properly open up all missing method calls via D-Bus to unpriv clients
Lennart Poettering [Fri, 23 May 2025 12:10:50 +0000 (14:10 +0200)] 
machined: properly open up all missing method calls via D-Bus to unpriv clients

These method calls all already have polkit hookup, hence actually allow
them to go through on all levels.

This is mostly playing catchup with a variety of calls added over the
years.

5 months agocoredump: fix 0-passed-as-pointer warning
Zbigniew Jędrzejewski-Szmek [Fri, 6 Jun 2025 15:03:46 +0000 (17:03 +0200)] 
coredump: fix 0-passed-as-pointer warning

5 months agonspawn: start polkit agent while we do polkit operations
Lennart Poettering [Fri, 23 May 2025 10:17:47 +0000 (12:17 +0200)] 
nspawn: start polkit agent while we do polkit operations

Let's make sure unpriv nspawn can acquire privs even when invoked
outside of a desktop environment that has a polkit agent registered.

5 months agotest: extend timeout and enable generating debugging logs
Yu Watanabe [Fri, 6 Jun 2025 15:09:37 +0000 (00:09 +0900)] 
test: extend timeout and enable generating debugging logs

Not sure why the test failed, but maybe the test environment is too
slow? Even this does not fix the failure, by enabling debugging logs,
this hopefully provides more useful information for debugging.

For issue #37685.

5 months agorun: ignore bus connection error in acquiring invocation ID (#37763)
Yu Watanabe [Fri, 6 Jun 2025 16:55:21 +0000 (01:55 +0900)] 
run: ignore bus connection error in acquiring invocation ID (#37763)

This introduce bus_error_is_connection(), and use it where applicable.
Then, this makes connection errors in acquiring invocation ID by
systemd-run handled gracefully, like we already do other places.

Fixes #37675.

5 months agotree-wide: allow building with -Wgnu-variable-sized-type-not-at-end option for clang...
Yu Watanabe [Fri, 6 Jun 2025 16:02:38 +0000 (01:02 +0900)] 
tree-wide: allow building with -Wgnu-variable-sized-type-not-at-end option for clang (#37499)

Follow-up for #36993.
Closes #37497.

5 months agorun: ignore bus connection error in acquiring invocation ID 37763/head
Yu Watanabe [Fri, 6 Jun 2025 10:50:34 +0000 (19:50 +0900)] 
run: ignore bus connection error in acquiring invocation ID

Similar to 2b983b43c6e4a0dc9d58671eaf2f508a8ce8e3b9, but for acquiring
invocation ID.

Fixes #37675.

5 months agosd-device: replace '!' with '/' before calling sd_device_new_from_subsystem_sysname()
Yu Watanabe [Fri, 6 Jun 2025 12:14:20 +0000 (21:14 +0900)] 
sd-device: replace '!' with '/' before calling sd_device_new_from_subsystem_sysname()

Device ID uses device directory name as is, hence may contain '!', but
sd_device_new_from_subsystem_sysname() expects that the input is sysname.
So, we need to replace '!' with '/'.

Follow-up for 1393c5a2a42d6ff16afcdc3ac39f007921b9cb57.
Fixes #37711.

5 months agocodeql: taint basename()
Lennart Poettering [Fri, 6 Jun 2025 13:56:46 +0000 (15:56 +0200)] 
codeql: taint basename()

5 months agorepart: fix CopyBlocks=auto for verity-sig partitions, even harder (#37704)
Lennart Poettering [Fri, 6 Jun 2025 14:06:26 +0000 (16:06 +0200)] 
repart: fix CopyBlocks=auto for verity-sig partitions, even harder (#37704)

@DaanDeMeyer, this is for you.

Seems to work great here to duplicate ParticleOS onto another disk.

5 months agotree-wide: basename -> path_extract_filename (#34906)
Lennart Poettering [Fri, 6 Jun 2025 13:53:28 +0000 (15:53 +0200)] 
tree-wide: basename -> path_extract_filename (#34906)

5 months agotree-wide: introduce bus_error_is_connection() and use it where applicable
Yu Watanabe [Fri, 6 Jun 2025 12:42:01 +0000 (21:42 +0900)] 
tree-wide: introduce bus_error_is_connection() and use it where applicable

5 months agorepart: use partition_designator_is_verity_sig() + partition_designator_is_verity... 37704/head
Lennart Poettering [Fri, 6 Jun 2025 10:30:41 +0000 (12:30 +0200)] 
repart: use partition_designator_is_verity_sig() + partition_designator_is_verity() more

5 months agorepart: try harder to find verity-sig partitions for CopyBlocks=auto
Lennart Poettering [Mon, 2 Jun 2025 17:27:33 +0000 (19:27 +0200)] 
repart: try harder to find verity-sig partitions for CopyBlocks=auto

verity-sig partitions are not kernel concepts, hence dm-verity won't
link them for us from the slaves/ subdir in sysfs. Hence let's instead
look up the partition via udev's database.

Hence: when we search for the data+verity+verity-sig partitions then
search for the first two as usual, but search for the latter by looking
up the udev props on the first two, and then following the paths
provided therein.

Fixes: #34835
5 months agoudev: add udev properties that point to verity/verity sig metadata partitions from...
Lennart Poettering [Mon, 2 Jun 2025 16:31:40 +0000 (18:31 +0200)] 
udev: add udev properties that point to verity/verity sig metadata partitions from data partitions

This extends the dissect_image builtin to actually add device node
references to the device nodes where the associated data is placed, if
we can find it.

This is kept very generic, and independent from the roothash properties
and suchlike, since it makes sense to make it possible to set these
properties also independently of the dissect-image builtin.

The device path is a /dev/disk/by-diskseq/ symlink, so that we have
stable reference that are not subject to dev_t reuses.

5 months agogpt: add partition_designator_is_verity() helper
Lennart Poettering [Fri, 6 Jun 2025 10:20:13 +0000 (12:20 +0200)] 
gpt: add partition_designator_is_verity() helper

And rework partition_designator_is_verity_sig() to be based on
partition_verity_sig_to_data(), so that we don't have to maintain two
lists of verity sig partition types.

5 months agosd-lldp-rx: add VLAN ID parsing (#37725)
Yu Watanabe [Fri, 6 Jun 2025 10:12:48 +0000 (19:12 +0900)] 
sd-lldp-rx: add VLAN ID parsing (#37725)

While the `port_vlan_id` field was already present in the
`sd_lldp_neighbor`, it wasn't currently parsed from the LLDP packet.
Added support for that as well as a small parsing test.

Closes #28354.

5 months agoTODO: drop completed entry 34906/head
Yu Watanabe [Fri, 6 Jun 2025 10:09:49 +0000 (19:09 +0900)] 
TODO: drop completed entry

5 months agosystemctl: replace basename() with path_extract_filename()
Yu Watanabe [Fri, 6 Jun 2025 10:00:15 +0000 (19:00 +0900)] 
systemctl: replace basename() with path_extract_filename()

5 months agodelta: rework how enumerate files
Yu Watanabe [Fri, 6 Jun 2025 09:53:16 +0000 (18:53 +0900)] 
delta: rework how enumerate files

5 months agotree-wide: basename -> path_extract_filename
A. Wilcox [Sat, 7 Sep 2024 04:03:06 +0000 (23:03 -0500)] 
tree-wide: basename -> path_extract_filename

5 months agoupdate TODO
Lennart Poettering [Fri, 6 Jun 2025 10:03:11 +0000 (12:03 +0200)] 
update TODO

5 months agogenerator: improve scope check (#37761)
Lennart Poettering [Fri, 6 Jun 2025 10:02:25 +0000 (12:02 +0200)] 
generator: improve scope check (#37761)

Fixes: #35723
5 months agonetwork: test-lldp-rx: set more variable as static const 37725/head
Lorenzo Arena [Thu, 5 Jun 2025 06:57:54 +0000 (08:57 +0200)] 
network: test-lldp-rx: set more variable as static const

5 months agosd-lldp-rx: add VLAN ID parsing
Lorenzo Arena [Wed, 4 Jun 2025 11:21:21 +0000 (13:21 +0200)] 
sd-lldp-rx: add VLAN ID parsing

Closes #28354.

5 months agogenerator: check $SYSTEMD_SCOPE rather than cgroup membership 37761/head
Lennart Poettering [Fri, 6 Jun 2025 06:59:31 +0000 (08:59 +0200)] 
generator: check $SYSTEMD_SCOPE rather than cgroup membership

This is more explicit and ensures that even in testing environments we
operate the same way.

As side effect it also avoids the mess around SELinux blocking access to
cgroupfs.

Fixes: #35723
5 months agocore: break lines in some overly long function calls
Lennart Poettering [Fri, 6 Jun 2025 06:59:19 +0000 (08:59 +0200)] 
core: break lines in some overly long function calls

5 months agoconf-files: use proper enum for flags parameters
Lennart Poettering [Fri, 6 Jun 2025 06:33:31 +0000 (08:33 +0200)] 
conf-files: use proper enum for flags parameters

5 months agojournal: concurrent update fixes (#37757)
Lennart Poettering [Fri, 6 Jun 2025 06:24:16 +0000 (08:24 +0200)] 
journal: concurrent update fixes (#37757)

Fixes: #35229 #32436
5 months agocore: adding CGroup for io.systemd.Unit.List (second PR) (#37646)
Yu Watanabe [Thu, 5 Jun 2025 21:07:35 +0000 (06:07 +0900)] 
core: adding CGroup for io.systemd.Unit.List (second PR) (#37646)

This PR adds CGroup context/runtime for io.systemd.Unit.List method.

This is follow up for https://github.com/systemd/systemd/pull/37432.

5 months agoBugprone argument comment 10 (#37755)
Yu Watanabe [Thu, 5 Jun 2025 21:07:05 +0000 (06:07 +0900)] 
Bugprone argument comment 10 (#37755)

Follow up from https://github.com/systemd/systemd/pull/37712

5 months agojournal: replace a bunch of assert() with friendlier checks 37757/head
Lennart Poettering [Thu, 5 Jun 2025 20:26:03 +0000 (22:26 +0200)] 
journal: replace a bunch of assert() with friendlier checks

We should not rely that data stored in the journal files remains
entirely untouched at all times. Because we unallocate files, data might
go away any time. Hence, never assert() on any expectations on what the
file contains. Instead, handle it more gracefully as a corruption issue,
and return EBADMSG.

Fixes: #35229 #32436
5 months agojournal: add 'const' at one more place
Lennart Poettering [Thu, 5 Jun 2025 20:25:33 +0000 (22:25 +0200)] 
journal: add 'const' at one more place

5 months agojournal: determine compression once, not twice
Lennart Poettering [Thu, 5 Jun 2025 20:22:55 +0000 (22:22 +0200)] 
journal: determine compression once, not twice

This is just paranoia: let's determine the compression to use once,
instead of twice, after all te data is in journal files which might be
corrupted any time, and it would be weird if we came to different
results here each time.

5 months agojournal: use EBADMSG for invalid data in file mmap
Lennart Poettering [Thu, 5 Jun 2025 20:21:16 +0000 (22:21 +0200)] 
journal: use EBADMSG for invalid data in file mmap

We must assume that any data in the mmap can change anytime because the
file is deallocated or similar. Let's strictly use EBADMSG for reporting
invalid file contents though (as opposed to using EINVAL if our own code
passes a wrong parameter somwhere).

5 months agocore/varlink: split out dynamic-user stuff into its own source files
Mike Yuan [Thu, 5 Jun 2025 14:20:35 +0000 (16:20 +0200)] 
core/varlink: split out dynamic-user stuff into its own source files

5 months agohwdb: Acer Nitro ANV15-51 Mic Toggle
SoloSaravanan [Thu, 5 Jun 2025 13:06:23 +0000 (18:36 +0530)] 
hwdb: Acer Nitro ANV15-51 Mic Toggle

5 months agomountfsd: support processing block devices with MountImage() (#37746)
Lennart Poettering [Thu, 5 Jun 2025 14:51:06 +0000 (16:51 +0200)] 
mountfsd: support processing block devices with MountImage() (#37746)

Fixes: #35111
5 months agocore: Various fixes for cgroup and pid namespaces (#36815)
Daan De Meyer [Thu, 5 Jun 2025 13:21:59 +0000 (15:21 +0200)] 
core: Various fixes for cgroup and pid namespaces (#36815)

5 months agomeson: Don't fail install script if file doesn't exist
Daan De Meyer [Thu, 5 Jun 2025 10:14:45 +0000 (12:14 +0200)] 
meson: Don't fail install script if file doesn't exist

Depending on which optional features are enabled, the NSS module
might not have been built, which means the custom install script
will fail to remove the file. Let's pass -f so it succeeds regardless
of whether the file exists or not.

5 months agoman: suggest using --unlock-tpm2-device=auto in cryptenroll example
Lennart Poettering [Thu, 5 Jun 2025 12:40:42 +0000 (14:40 +0200)] 
man: suggest using --unlock-tpm2-device=auto in cryptenroll example

When refreshing a tpm2 enrollment, it makes sense to use tpm2 to unlock
the device.

Fixes: #35279
5 months agomeson: Add libmount feature
Daan De Meyer [Thu, 5 Jun 2025 09:05:08 +0000 (11:05 +0200)] 
meson: Add libmount feature

Let's reduce the dependencies required to build just libsystemd by
making libmount optional. The meson disabler feature makes this quite
trivial.

5 months agoadd CITATION.cff file
Lennart Poettering [Thu, 5 Jun 2025 12:35:26 +0000 (14:35 +0200)] 
add CITATION.cff file

As per spec: https://citation-file-format.github.io/

Fixes: #35260
5 months agomountfsd: slightly relax check on image fds 37746/head
Lennart Poettering [Thu, 5 Jun 2025 12:12:18 +0000 (14:12 +0200)] 
mountfsd: slightly relax check on image fds

Fixes: #35111
5 months agodissect-image: port to varlink_callbo_and_log()
Lennart Poettering [Thu, 5 Jun 2025 11:18:45 +0000 (13:18 +0200)] 
dissect-image: port to varlink_callbo_and_log()

5 months agovarlink-util: format system errors via %m in varlink_call_and_log()
Lennart Poettering [Thu, 5 Jun 2025 11:17:17 +0000 (13:17 +0200)] 
varlink-util: format system errors via %m in varlink_call_and_log()

This kinda does what bee59ab901ca199d194f440cf37f7645004d3054 did for
varlinkctl also for the generic varlink_call_and_log() handler.

5 months agofixes for --machine= handling in run0 and journalctl (#37741)
Lennart Poettering [Thu, 5 Jun 2025 12:02:26 +0000 (14:02 +0200)] 
fixes for --machine= handling in run0 and journalctl (#37741)

Fixes: #32997
5 months agoresolvectl: --raw improvements (#37743)
Lennart Poettering [Thu, 5 Jun 2025 12:02:00 +0000 (14:02 +0200)] 
resolvectl: --raw improvements (#37743)

Fixes: #37737
5 months agocore: adding CGroup runtime for io.systemd.Unit.List 37646/head
Ivan Kruglov [Mon, 2 Jun 2025 18:04:19 +0000 (20:04 +0200)] 
core: adding CGroup runtime for io.systemd.Unit.List

5 months agocore: adding CGroup context for io.systemd.Unit.List
Ivan Kruglov [Mon, 2 Jun 2025 12:12:44 +0000 (14:12 +0200)] 
core: adding CGroup context for io.systemd.Unit.List

5 months agocore: *ret = NULL for early return in unit_mounts_for_build_json()
Ivan Kruglov [Wed, 4 Jun 2025 14:37:03 +0000 (07:37 -0700)] 
core: *ret = NULL for early return in unit_mounts_for_build_json()

5 months agocore: rework how we track cgroup realized state (#37733)
Mike Yuan [Thu, 5 Jun 2025 10:56:31 +0000 (12:56 +0200)] 
core: rework how we track cgroup realized state (#37733)

5 months agosd-bus: treat '@' as equivalent to '@.host' 37741/head
Lennart Poettering [Thu, 5 Jun 2025 09:53:04 +0000 (11:53 +0200)] 
sd-bus: treat '@' as equivalent to '@.host'

We allow omission of the part before and the part after the @. But so
far we didn't allow omitting both. There's no real reason for
disallowing that, hence be systematic and allow it.

5 months agosd-bus: port to split_user_at_host()
Lennart Poettering [Thu, 5 Jun 2025 09:52:47 +0000 (11:52 +0200)] 
sd-bus: port to split_user_at_host()

5 months agojournalctl: politely refuse if non-root usernames are specified for --machine=
Lennart Poettering [Thu, 5 Jun 2025 09:27:53 +0000 (11:27 +0200)] 
journalctl: politely refuse if non-root usernames are specified for --machine=

We currently cannot support that (supporting that would probably require
some active component in the machine, or alternatively idmapped mounts
or so), hence politely refuse it.

See: https://github.com/systemd/systemd/issues/32997#issuecomment-2127700945

5 months agorun: chop off username from --machine= argument before calling OpenMachinePTY()
Lennart Poettering [Wed, 4 Jun 2025 16:28:35 +0000 (18:28 +0200)] 
run: chop off username from --machine= argument before calling OpenMachinePTY()

Let's be compatible with sd-bus' logic to talk to machine, and support
the usual user@host syntax. We only want the host part, hence chop if
off before passing it to OpenMachinePTY().

Fixes: #32997
5 months agomachined: open up OpenMachinePTY() for unpriv clients
Lennart Poettering [Thu, 5 Jun 2025 08:58:54 +0000 (10:58 +0200)] 
machined: open up OpenMachinePTY() for unpriv clients

The method call already does a PK check, it was just forgotten to
allowlist this in the dbus policy. And in the dbus vtable for
OpenMachinePTY() call. (It was allowlisted in the per-machine
vtable…)

Anyway, clean this up.

5 months agohostname-util: add new helper split_user_at_host()
Lennart Poettering [Thu, 5 Jun 2025 09:17:22 +0000 (11:17 +0200)] 
hostname-util: add new helper split_user_at_host()

Let's introduce a common helper for splitting user@host specifications
like we use them for --machine=.

5 months agoresolvectl: improve error message if we do not support dumping payload of RR 37743/head
Lennart Poettering [Thu, 5 Jun 2025 10:43:36 +0000 (12:43 +0200)] 
resolvectl: improve error message if we do not support dumping payload of RR

5 months agoman: reword --raw= explanation a bit
Lennart Poettering [Thu, 5 Jun 2025 10:22:34 +0000 (12:22 +0200)] 
man: reword --raw= explanation a bit

Explain what we mean by "payload", and for which RR types this is
intended.

And don#t claim we'd output a full packet, because we don't. We output
only the RR in binary.

Fixes: #37737
5 months agoresolvectl: output slightly more data when --raw=payload is used
Lennart Poettering [Thu, 5 Jun 2025 10:17:01 +0000 (12:17 +0200)] 
resolvectl: output slightly more data when --raw=payload is used

Let's also show A/AAAA data in binary form if --raw=payload is used. For
these RR types there's only a single data field, hence it's obbviously
meant.

Inspired by: #37737

5 months ago core: Make sure we handle DelegateSubgroup= in combo with cgroupns 36815/head
Daan De Meyer [Fri, 25 Apr 2025 10:40:52 +0000 (12:40 +0200)] 
 core: Make sure we handle DelegateSubgroup= in combo with cgroupns

Currently, if we use a cgroup namespace together with DelegateSubgroup=,
the subgroup becomes the root of the cgroup namespace because we move the
service process to the subgroup before we unshare the cgroup namespace, and
the current cgroup becomes the root of the cgroup namespace when we unshare
the cgroup namespace.

Let's fix the problem by not moving the service process to the subgroup until
we've unshared the cgroup namespace. Note that this doesn't break the primary use
case of CLONE_INTO_CGROUP since we still use it to immediately clone into the service
main cgroup, just not anymore into the subgroup, but this shouldn't matter in practice.

Additionally, we need special handling for control processes, as those *do*
need to get spawned into the subcgroup immediately if delegation is configured to
avoid violating the cgroupsv2 "no inner processes" rule.

Effectively, this leaves us with the following logic:
- In exec_spawn(), spawn into subgroup if we're spawning a control process
  that needs to be spawned into a subgroup immediately. Otherwise, spawn into
  main service cgroup.
- In exec_invoke(), move into subgroup early if we don't need a cgroup namespace.
  Otherwise, move into subgroup after we've unshared the cgroup namespace.

5 months agocore: Disable pid namespacing for control processes
Daan De Meyer [Fri, 21 Mar 2025 08:41:15 +0000 (09:41 +0100)] 
core: Disable pid namespacing for control processes

PID namespaces frankly don't make any sense for control processes, so
let's gracefully degrade to no pid namespaces for control processes.

5 months agomeson: Remove unnecessary deps from libsystemd-static build
Daan De Meyer [Thu, 5 Jun 2025 09:04:06 +0000 (11:04 +0200)] 
meson: Remove unnecessary deps from libsystemd-static build

blkid, libmount and openssl are not used in src/basic or src/libsystemd,
and so shouldn't be required as deps of libsystemd static, so let's drop
them.

5 months agoptyfwd: introduce pty_forward_set_window_title() helper function
Yu Watanabe [Thu, 5 Jun 2025 05:59:40 +0000 (14:59 +0900)] 
ptyfwd: introduce pty_forward_set_window_title() helper function

5 months agohwdb: add support for Loupedeck devices
tytan652 [Thu, 5 Jun 2025 09:26:58 +0000 (11:26 +0200)] 
hwdb: add support for Loupedeck devices

Razer has partnered with Loupedeck to develop some devices.

Add support for the following devices:
- Loupedeck CT
- Loupedeck Live
- Loupedeck Live S
- Razer Stream Controller
- Razer Stream Controller X

5 months agosd-daemon: add sd_pidfd_get_inode_id() (#37679)
Lennart Poettering [Thu, 5 Jun 2025 07:31:48 +0000 (09:31 +0200)] 
sd-daemon: add sd_pidfd_get_inode_id() (#37679)

5 months agovmspawn: fix call to GetUnitByPID
Sam Leonard [Mon, 2 Jun 2025 15:13:13 +0000 (16:13 +0100)] 
vmspawn: fix call to GetUnitByPID

This commit also adds a handler for SIGRTMIN+4 which is another signal
used to shutdown systemd.

5 months agotest-daemon: add test case for sd_pidfd_get_inode_id() 37679/head
Mike Yuan [Tue, 3 Jun 2025 15:15:00 +0000 (17:15 +0200)] 
test-daemon: add test case for sd_pidfd_get_inode_id()

5 months agosd-daemon: add sd_pidfd_get_inode_id()
Mike Yuan [Sun, 1 Jun 2025 07:12:13 +0000 (09:12 +0200)] 
sd-daemon: add sd_pidfd_get_inode_id()

We nowadays expose pidfdid at various places, e.g. envvars
and dbus properties. Also the sd_notify() MAINPID= message
has been complemented with MAINPIDFDID=. But acquiring
pidfdid is actually non-trivial especially considering
the 32-bit case, hence let's introduce a public helper
in sd-daemon specifically for that purpose.

5 months agopidfd-util: extract pidfd_get_inode_id_impl() and make it thread safe
Mike Yuan [Sun, 1 Jun 2025 06:57:49 +0000 (08:57 +0200)] 
pidfd-util: extract pidfd_get_inode_id_impl() and make it thread safe

Preparation for later commits.

5 months agopidfd-util: open an internal pidfd if none is passed in pidfd_check_pidfs()
Mike Yuan [Sun, 1 Jun 2025 06:55:50 +0000 (08:55 +0200)] 
pidfd-util: open an internal pidfd if none is passed in pidfd_check_pidfs()

I'd like to introduce a libsystemd helper for acquiring pidfd
inode id, which however means the fd passed to pidfd_check_pidfs()
can no longer be trusted. Let's add back the logic of allocating
a genuine pidfd allocated internally, which was remove in
5dc9d5b4eacbe32f58ad6ca18d70931ab89ea409.

5 months agoman/sd_pid_get_owner_uid: don't limit -EBADF to socket fds
Mike Yuan [Sun, 1 Jun 2025 07:06:36 +0000 (09:06 +0200)] 
man/sd_pid_get_owner_uid: don't limit -EBADF to socket fds

5 months agosd-login: reject invalid pidfd with -EBADF consistently
Mike Yuan [Sun, 1 Jun 2025 07:04:27 +0000 (09:04 +0200)] 
sd-login: reject invalid pidfd with -EBADF consistently

We got it mostly right except for one function, fix it.

5 months agosd-login: various modernizations (#37728)
Lennart Poettering [Wed, 4 Jun 2025 20:24:57 +0000 (22:24 +0200)] 
sd-login: various modernizations (#37728)

5 months agoio-util: protect against INT_MAX overflow in flush_fd()
Lennart Poettering [Wed, 4 Jun 2025 14:05:41 +0000 (16:05 +0200)] 
io-util: protect against INT_MAX overflow in flush_fd()

5 months agocore/cgroup: make various functions static 37733/head
Mike Yuan [Wed, 4 Jun 2025 16:28:58 +0000 (18:28 +0200)] 
core/cgroup: make various functions static

Not used externally anymore with previous commits.

5 months agocore/unit-printf: port to unit_get_cgroup_path_with_fallback()
Mike Yuan [Wed, 4 Jun 2025 18:30:59 +0000 (20:30 +0200)] 
core/unit-printf: port to unit_get_cgroup_path_with_fallback()

5 months agocore: rework how we track cgroup realized state
Mike Yuan [Wed, 4 Jun 2025 15:34:11 +0000 (17:34 +0200)] 
core: rework how we track cgroup realized state

Prompted by https://github.com/systemd/systemd/pull/37646#discussion_r2126882561

Follow-up for 879952a85311ca375c673480d9718a9e0cd93c1d

Currently, almost all cgroup attr getters check cgroup_path for whether
cgroup is around. This is actually great, because we never want to expose
a non-existent cgroup path via IPC and such. However, it is spuriously
initialized at places where it shouldn't be, e.g. in unit_warn_leftover_processes().
This matters especially to units that *may* carry processes to run, but
not *always*, notably socket units. unit_warn_leftover_processes() is supposed
to be informative only and not try to set cgroup tracking to realized in
a half-assed way.

Hence, let's kill cgroup_realized field, and make sure cgroup_path is set
only if cgroup has been created. Be extra careful with deserialization
though, since the previous versions don't follow this rule and we need
to patch cgroup_path manually based on cgroup_realized we got from deserialization.

Calls to unit_watch_cgroup*() are dropped in cgroup_runtime_deserialize_one(),
because unit_deserialize_state() will invalidate cgroup realized state and
reapply later.

5 months agocore/cgroup: don't ever try to get SPECIAL_ROOT_SLICE from Manager.cgroup_unit
Mike Yuan [Wed, 4 Jun 2025 18:18:01 +0000 (20:18 +0200)] 
core/cgroup: don't ever try to get SPECIAL_ROOT_SLICE from Manager.cgroup_unit

This tries to query unit name in cgroup_unit hashmap, which
always returns NULL. Just return NULL directly instead.

5 months agocore/unit-serialize: drop deserialization compat for state_change_timestamp
Mike Yuan [Wed, 4 Jun 2025 19:59:23 +0000 (21:59 +0200)] 
core/unit-serialize: drop deserialization compat for state_change_timestamp

This was from v228, i.e. before cgroup v2 got introduced.
Nowadays cgroup v1 is outright rejected during initialization,
i.e. upgrading isn't possible whatsoever. Remove the compat glue there.

5 months agojournal: make journal_file_copy_entry() robust towards copying invalid/half-written...
Lennart Poettering [Wed, 4 Jun 2025 18:51:24 +0000 (20:51 +0200)] 
journal: make journal_file_copy_entry() robust towards copying invalid/half-written source journal files (#37732)

5 months agojournal-file: let's make journal_file_copy_entry() robust against concurrent writing... 37732/head
Lennart Poettering [Wed, 4 Jun 2025 15:00:29 +0000 (17:00 +0200)] 
journal-file: let's make journal_file_copy_entry() robust against concurrent writing of the source

As usual, we need to protect ourselves against concurrent modification
of journal files. We a pretty good at that these days when reading
journal files. But journal_file_copy_entry() so far wasn't too good with
that. journal_file_append_data() so far returned EINVAL when you pass
invalid data to it. Since we pass the source data as-is in there, it's
going to fail if the journal source file is slightly invalid due to a
concurrent update.

Hence, we need to validate data gracefully here that we think comes from
a safe place, because actually it doesn't, it's directly copied from an
unsafe journal file.

Hence, let's introduce a clear error code here, and look for it in
journal_file_copy_entry(), and handle it gracefully.

Pretty sure this fixes #33372, but it's a race, so I don't know for
sure. If this remains reproducible we need to look at this again.

Fixes: #33372
5 months agocompress: get rid of a bunch of 'else'
Lennart Poettering [Wed, 4 Jun 2025 15:00:21 +0000 (17:00 +0200)] 
compress: get rid of a bunch of 'else'

5 months agosd-login: port sd_peer_get_cgroup() to SO_PEERPIDFD 37728/head
Lennart Poettering [Wed, 4 Jun 2025 09:45:20 +0000 (11:45 +0200)] 
sd-login: port sd_peer_get_cgroup() to SO_PEERPIDFD

5 months agosd-login: place inner part of sd_login_monitor_new() by a table
Lennart Poettering [Wed, 4 Jun 2025 09:40:45 +0000 (11:40 +0200)] 
sd-login: place inner part of sd_login_monitor_new() by a table

5 months agosd-login: modernize return parameter handling
Lennart Poettering [Wed, 4 Jun 2025 09:38:40 +0000 (11:38 +0200)] 
sd-login: modernize return parameter handling

Let's rename the return parameters as "ret_xyz" systematically in
sd-login.

Also, let's make the return parameters systematically optional, like we
typically do these days. So far some where optional, other's weren't.
Let's clean this up.

5 months agotest-network: extend comments how to run the test
Yu Watanabe [Wed, 4 Jun 2025 15:22:14 +0000 (00:22 +0900)] 
test-network: extend comments how to run the test

5 months agoSeveral follow-ups for userdb lookup from udevd and networkd (#37719)
Yu Watanabe [Wed, 4 Jun 2025 14:32:24 +0000 (23:32 +0900)] 
Several follow-ups for userdb lookup from udevd and networkd (#37719)

5 months agoupdate TODO
Lennart Poettering [Wed, 4 Jun 2025 14:05:09 +0000 (16:05 +0200)] 
update TODO

5 months agoclang-tidy: enable bugprone-argument-comment check 37755/head
Jelle van der Waa [Wed, 4 Jun 2025 13:50:00 +0000 (15:50 +0200)] 
clang-tidy: enable bugprone-argument-comment check

5 months agoresolved-manager: rename 's' -> 'source'
Jelle van der Waa [Wed, 4 Jun 2025 13:48:02 +0000 (15:48 +0200)] 
resolved-manager: rename 's' -> 'source'