]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 months agovmspawn: fix `sd_bus_message_append()` arguments and add missing error check
Antonio Alvarez Feijoo [Mon, 8 Apr 2024 15:08:52 +0000 (17:08 +0200)] 
vmspawn: fix `sd_bus_message_append()` arguments and add missing error check

2 months agodocs: Suggest soft-reboot to restart pid1 and all daemons in mkosi VM
Daan De Meyer [Mon, 8 Apr 2024 21:17:33 +0000 (23:17 +0200)] 
docs: Suggest soft-reboot to restart pid1 and all daemons in mkosi VM

2 months agoMerge pull request #32104 from yuwata/network-ndisc-redirect
Luca Boccassi [Mon, 8 Apr 2024 19:03:32 +0000 (20:03 +0100)] 
Merge pull request #32104 from yuwata/network-ndisc-redirect

network/ndisc: add support for Redirect message

2 months agoMerge pull request #32156 from YHNdnzj/mountfsd-followup
Mike Yuan [Mon, 8 Apr 2024 18:48:30 +0000 (02:48 +0800)] 
Merge pull request #32156 from YHNdnzj/mountfsd-followup

Some cleanup for uid-range

2 months agomkosi: Fix debian submodule commit
Daan De Meyer [Mon, 8 Apr 2024 15:08:39 +0000 (17:08 +0200)] 
mkosi: Fix debian submodule commit

This was accidentally changed in https://github.com/systemd/systemd/pull/32155

2 months agoI made more unit test to use the test macro
Usman Akinyemi [Mon, 8 Apr 2024 10:54:16 +0000 (06:54 -0400)] 
I made more unit test to use the test macro

2 months agouserdbctl: correct uid_range_covers check 32156/head
Mike Yuan [Mon, 8 Apr 2024 12:24:23 +0000 (20:24 +0800)] 
userdbctl: correct uid_range_covers check

The third param should be the number of uids.

2 months agouserdbctl: use FOREACH_ARRAY more
Mike Yuan [Mon, 8 Apr 2024 12:24:02 +0000 (20:24 +0800)] 
userdbctl: use FOREACH_ARRAY more

2 months agouserdbctl: avoid NULL pointer deref
Mike Yuan [Mon, 8 Apr 2024 12:19:57 +0000 (20:19 +0800)] 
userdbctl: avoid NULL pointer deref

Error from uid_range_load_userns is ignored,
so 'p' could be NULL.

2 months agouid-range: place 'ret' param at last
Mike Yuan [Mon, 8 Apr 2024 11:38:29 +0000 (19:38 +0800)] 
uid-range: place 'ret' param at last

2 months agouid-range: use FOREACH_ARRAY at one more place
Mike Yuan [Mon, 8 Apr 2024 11:48:01 +0000 (19:48 +0800)] 
uid-range: use FOREACH_ARRAY at one more place

2 months agolabeler: add mountfsd and nsresource
Mike Yuan [Mon, 8 Apr 2024 12:09:54 +0000 (20:09 +0800)] 
labeler: add mountfsd and nsresource

2 months agodocs: Add note on RuntimeBuildSources= to hacking guide
Daan De Meyer [Mon, 8 Apr 2024 10:14:47 +0000 (12:14 +0200)] 
docs: Add note on RuntimeBuildSources= to hacking guide

2 months agoMerge pull request #32141 from DaanDeMeyer/mkosi
Daan De Meyer [Mon, 8 Apr 2024 09:59:16 +0000 (11:59 +0200)] 
Merge pull request #32141 from DaanDeMeyer/mkosi

Install build dependencies into final image

2 months agoMerge pull request #32140 from YHNdnzj/socket-per-peer-source
Luca Boccassi [Mon, 8 Apr 2024 09:38:07 +0000 (10:38 +0100)] 
Merge pull request #32140 from YHNdnzj/socket-per-peer-source

Minor tweaks to socket manual & shorten the code a bit

2 months agomkosi: Update submodules to latest 32141/head
Daan De Meyer [Mon, 8 Apr 2024 09:36:59 +0000 (11:36 +0200)] 
mkosi: Update submodules to latest

2 months agomkosi: Fix environment variable in arch prepare script
Daan De Meyer [Mon, 8 Apr 2024 09:35:38 +0000 (11:35 +0200)] 
mkosi: Fix environment variable in arch prepare script

2 months agoInstall build dependencies into final image
Daan De Meyer [Sun, 7 Apr 2024 18:23:56 +0000 (20:23 +0200)] 
Install build dependencies into final image

This allows us to build and install after booting without having to
build a new image. Together with
https://github.com/systemd/mkosi/pull/2601 and after enabling
RuntimeBuildSources=yes, after booting, "meson install -C /work/build"
can be used to do an incremental build and install. This won't build
proper packages, but will be invaluable for having a quick compile,
edit, test cycle without having to rebuild the image all the time.

2 months agoUpdate pkg/debian/ to latest
Luca Boccassi [Mon, 8 Apr 2024 09:17:53 +0000 (10:17 +0100)] 
Update pkg/debian/ to latest

lz4-tool, nsresourced, kmod changes

2 months agonsresource: fix FD leak
Luca Boccassi [Mon, 8 Apr 2024 01:33:27 +0000 (02:33 +0100)] 
nsresource: fix FD leak

Also fix return code, namespace_open_by_type uses RET_NERRNO

CID#1542923

Follow-up for 54452c7b2aa

2 months agonetworkd: report error if lease file cannot be loaded and ignore
Zbigniew Jędrzejewski-Szmek [Sat, 6 Apr 2024 17:01:56 +0000 (19:01 +0200)] 
networkd: report error if lease file cannot be loaded and ignore

On my system, networkd would report that interface ve-rawhide is "Failed"
without anything in the logs:
systemd-networkd[651095]: ve-rawhide: Trying to reconfigure the interface.
systemd-networkd[651095]: ve-rawhide: Gained IPv6LL
systemd-networkd[651095]: ve-rawhide: Link DOWN
systemd-networkd[651095]: ve-rawhide: Lost carrier
systemd-networkd[651095]: ve-rawhide: Configuring with /usr/lib/systemd/network/80-container-ve.network.
systemd-networkd[651095]: ve-rawhide: Link UP
systemd-networkd[651095]: ve-rawhide: Gained carrier
systemd-networkd[651095]: ve-rawhide: Failed

At debug level:
systemd-networkd[799993]: dhcp-server-lease/ve-rawhide:1:1: Missing object field 'Address'.

$ jq </var/lib/systemd/network/dhcp-server-lease/ve-rawhide
{
  "BootID": "5d86b34b98894322bfd4ae8443ce59b3",
  "Leases": [
    {
      "ClientId": [ ... ],
      "Address": [ 192, 168, 120, 179 ],
      "Hostname": "rawhide",
      "ExpirationUSec": 966046821158,
      "ExpirationRealtimeUSec": 1711203197266940
    }
  ]
}

I'm not sure why "Address" is missing, but anyway, in this case, we should ignore the
lease file rather than refusing to configure the interface. Also, warn at the point
where we know what the filename is.

2 months agocore: fix typo
Antonio Alvarez Feijoo [Mon, 8 Apr 2024 08:04:32 +0000 (10:04 +0200)] 
core: fix typo

2 months agotree-wide: drop several remaining license headers
Yu Watanabe [Fri, 5 Apr 2024 04:08:05 +0000 (13:08 +0900)] 
tree-wide: drop several remaining license headers

And downgrade the license of utf8.c to LGPL-2.0-or-later, to follow the
original license.

2 months agomountfsd: fix typo
Yu Watanabe [Mon, 8 Apr 2024 00:22:03 +0000 (09:22 +0900)] 
mountfsd: fix typo

Follow-up for 702a52f4b5d49cce11e2adbc740deb3b644e2de0.

2 months agonsresourced: fix typo
Yu Watanabe [Mon, 8 Apr 2024 00:20:17 +0000 (09:20 +0900)] 
nsresourced: fix typo

Follow-up for 8aee931e7ae1adb01eeac0e1e4c0aef6ed3969ec.

2 months agodissect: fix typo
Yu Watanabe [Mon, 8 Apr 2024 00:17:50 +0000 (09:17 +0900)] 
dissect: fix typo

Follow-up for 9444e54e56b3d9ea81135700abe0792ead7f69ae.

2 months agonspawn: fix typo
Yu Watanabe [Mon, 8 Apr 2024 00:12:06 +0000 (09:12 +0900)] 
nspawn: fix typo

Follow-up for 0af7e294343b29d769c1bae6a8d390236560ec1a.

2 months agoMerge pull request #32136 from YHNdnzj/nextroot-auto-mountpoint
Luca Boccassi [Sun, 7 Apr 2024 22:32:18 +0000 (23:32 +0100)] 
Merge pull request #32136 from YHNdnzj/nextroot-auto-mountpoint

systemctl-logind: auto soft-reboot only if /run/nextroot/ is mountpoint

2 months agotest-execute: check for s390x first and duplicate test
Luca Boccassi [Sun, 7 Apr 2024 15:24:38 +0000 (16:24 +0100)] 
test-execute: check for s390x first and duplicate test

s390x will define both s390x and s390, so exec-personality-s390.service is ran
in both cases but fails on s390x, as the personality returned is s390x.
Split the test and check specifically for s390x.

2 months agohibernate-util: check 'noresume' before reading resume setting
Mike Yuan [Sat, 6 Apr 2024 18:59:07 +0000 (02:59 +0800)] 
hibernate-util: check 'noresume' before reading resume setting

Also hibernation_is_safe() should really take this
into consideration too.

2 months agoMerge pull request #26826 from poettering/mntfsd
Luca Boccassi [Sun, 7 Apr 2024 18:43:34 +0000 (19:43 +0100)] 
Merge pull request #26826 from poettering/mntfsd

unprivileged DDI mounts + dynamic userns range allocation via IPC

2 months agoman/systemd.socket: be explicit that MaxConnectionsPerSource=0 means disabled 32140/head
Mike Yuan [Sun, 7 Apr 2024 17:49:33 +0000 (01:49 +0800)] 
man/systemd.socket: be explicit that MaxConnectionsPerSource=0 means disabled

2 months agocore/service: use GREEDY_REALLOC_APPEND
Mike Yuan [Sun, 7 Apr 2024 17:35:24 +0000 (01:35 +0800)] 
core/service: use GREEDY_REALLOC_APPEND

2 months agomkosi: Install dnf5 in Fedora image
Daan De Meyer [Sun, 7 Apr 2024 13:51:57 +0000 (15:51 +0200)] 
mkosi: Install dnf5 in Fedora image

2 months agoMerge pull request #32135 from keszybz/compiler-warning-cleanup
Luca Boccassi [Sun, 7 Apr 2024 15:33:38 +0000 (16:33 +0100)] 
Merge pull request #32135 from keszybz/compiler-warning-cleanup

Compiler warning cleanup

2 months agosystemctl-logind: auto soft-reboot only if /run/nextroot/ is mountpoint 32136/head
Mike Yuan [Sun, 7 Apr 2024 11:33:37 +0000 (19:33 +0800)] 
systemctl-logind: auto soft-reboot only if /run/nextroot/ is mountpoint

Consider the following case: a user sets up a minimum rootfs for
file system maintenance work in /run/nextroot/ dir directly. When
they're done, they expect 'systemctl reboot' to perform a full reboot.
But they keep soft-rebooting back to the tmpfs root, until they
find out about $SYSTEMCTL_SKIP_AUTO_SOFT_REBOOT.

So currently, when /run/nextroot/ is a normal dir, pid1 automatically
turns it into a bind mount to soft-reboot into. This is good, but when
combined with automatic soft-reboot it has an arguably unexpected
behavior, since /run/nextroot/ can never go away in such a case.
OTOH, if /run/nextroot/ is a mountpoint in the first place, the mount
is *moved* so a second reboot would not trigger auto soft-reboot.
Let's just make things more friendly to users, and do auto soft-reboot
only if /run/nextroot/ is also a mountpoint.

2 months agologind-dbus: use FLAGS_SET more
Mike Yuan [Sun, 7 Apr 2024 11:26:56 +0000 (19:26 +0800)] 
logind-dbus: use FLAGS_SET more

2 months agocore: use log_unit_debug in *_set_state
Mike Yuan [Sat, 6 Apr 2024 14:04:17 +0000 (22:04 +0800)] 
core: use log_unit_debug in *_set_state

2 months agorun: query for SoftRebootsCount only for system scope runs
Luca Boccassi [Fri, 5 Apr 2024 23:00:41 +0000 (00:00 +0100)] 
run: query for SoftRebootsCount only for system scope runs

Only the system manager records soft reboots, and the user session is
restarted anyway so it doesn't suffer from the ID clash issue

Follow-up for ed358516937780b524a2cfa833427da3df1bc87f

2 months agosd-bus: rework assert to make the gcc happy 32135/head
Zbigniew Jędrzejewski-Szmek [Sun, 7 Apr 2024 09:13:06 +0000 (11:13 +0200)] 
sd-bus: rework assert to make the gcc happy

With gcc-14.0.1-0.13.fc40, when compiling with -O2, the compiler doesn't understand
that sd_bus_error_setf() always returns negative on error when <name> is provided:

[28/576] Compiling C object systemd-resolved.p/src_resolve_resolved-bus.c.o
../src/resolve/resolved-bus.c: In function ‘call_link_method’:
../src/resolve/resolved-bus.c:1763:16: warning: ‘l’ may be used uninitialized [-Wmaybe-uninitialized]
 1763 |         return handler(message, l, error);
      |                ^~~~~~~~~~~~~~~~~~~~~~~~~~
../src/resolve/resolved-bus.c:1749:15: note: ‘l’ was declared here
 1749 |         Link *l;
      |               ^
../src/resolve/resolved-bus.c: In function ‘bus_method_get_link’:
../src/resolve/resolved-bus.c:1822:13: warning: ‘l’ may be used uninitialized [-Wmaybe-uninitialized]
 1822 |         p = link_bus_path(l);
      |             ^~~~~~~~~~~~~~~~
../src/resolve/resolved-bus.c:1810:15: note: ‘l’ was declared here
 1810 |         Link *l;
      |               ^
...

Let's make the assertion a bit more explicit. With this, the warning goes away,
but I think it's more obvious to a human reader too.

2 months agoask-password: minor shortening
Zbigniew Jędrzejewski-Szmek [Sun, 7 Apr 2024 09:08:22 +0000 (11:08 +0200)] 
ask-password: minor shortening

2 months agocore: silence gcc warning about unitialized variable
Zbigniew Jędrzejewski-Szmek [Sun, 7 Apr 2024 09:05:42 +0000 (11:05 +0200)] 
core: silence gcc warning about unitialized variable

When compiled with -O2, the compiler is not happy about dynamic_user_pop() and
would warn about the output variables not being set. It does have a point:
we were doing a cast from ssize_t to int, and theoretically there could be
wraparound. So let's add an explicit check that the cast to int is fine.

[540/2509] Compiling C object src/core/libsystemd-core-256.so.p/dynamic-user.c.o
../src/core/dynamic-user.c: In function ‘dynamic_user_close.isra’:
../src/core/dynamic-user.c:580:9: warning: ‘uid’ may be used uninitialized [-Wmaybe-uninitialized]
  580 |         unlink_uid_lock(lock_fd, uid, d->name);
      |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
../src/core/dynamic-user.c:560:15: note: ‘uid’ was declared here
  560 |         uid_t uid;
      |               ^~~
../src/core/dynamic-user.c: In function ‘dynamic_user_realize’:
../src/core/dynamic-user.c:476:29: warning: ‘new_uid’ may be used uninitialized [-Wmaybe-uninitialized]
  476 |                         num = new_uid;
      |                         ~~~~^~~~~~~~~
../src/core/dynamic-user.c:398:23: note: ‘new_uid’ was declared here
  398 |                 uid_t new_uid;
      |                       ^~~~~~~

2 months agoupdate TODO 26826/head
Lennart Poettering [Mon, 4 Dec 2023 16:57:06 +0000 (17:57 +0100)] 
update TODO

2 months agotest: add integration test for unpriv mountfsd/nsresourced
Lennart Poettering [Tue, 23 Jan 2024 15:20:10 +0000 (16:20 +0100)] 
test: add integration test for unpriv mountfsd/nsresourced

2 months agonspawn: make nspawn work without privileges
Lennart Poettering [Tue, 12 Dec 2023 10:00:19 +0000 (11:00 +0100)] 
nspawn: make nspawn work without privileges

2 months agocore: implement RootImage= via mountfsd in unprivileged environments
Lennart Poettering [Wed, 6 Dec 2023 15:39:39 +0000 (16:39 +0100)] 
core: implement RootImage= via mountfsd in unprivileged environments

2 months agodissect-tool: allow systemd-dissect to talk to mountfsd
Lennart Poettering [Thu, 20 Apr 2023 17:07:10 +0000 (19:07 +0200)] 
dissect-tool: allow systemd-dissect to talk to mountfsd

2 months agodissect-image: add a generic varlink client side for mountfsd
Lennart Poettering [Mon, 4 Dec 2023 21:09:15 +0000 (22:09 +0100)] 
dissect-image: add a generic varlink client side for mountfsd

2 months agomountfsd: add new systemd-mountfsd component
Lennart Poettering [Thu, 9 Mar 2023 11:27:29 +0000 (12:27 +0100)] 
mountfsd: add new systemd-mountfsd component

2 months agonsresourced: add client-side helpers around nsresourced APIs
Lennart Poettering [Mon, 4 Dec 2023 16:57:22 +0000 (17:57 +0100)] 
nsresourced: add client-side helpers around nsresourced APIs

This adds simple functions that wrap the Varlink IPC calls.

2 months agonsresourced: add new daemon for granting clients user namespaces and assigning resour...
Lennart Poettering [Thu, 20 Apr 2023 17:07:33 +0000 (19:07 +0200)] 
nsresourced: add new daemon for granting clients user namespaces and assigning resources to them

This adds a small, socket-activated Varlink daemon that can delegate UID
ranges for user namespaces to clients asking for it.

The primary call is AllocateUserRange() where the user passes in an
uninitialized userns fd, which is then set up.

There are other calls that allow assigning a mount fd to a userns
allocated that way, to set up permissions for a cgroup subtree, and to
allocate a veth for such a user namespace.

Since the UID assignments are supposed to be transitive, i.e. not
permanent, care is taken to ensure that users cannot create inodes owned
by these UIDs, so that persistancy cannot be acquired. This is
implemented via a BPF-LSM module that ensures that any member of a
userns allocated that way cannot create files unless the mount it
operates on is owned by the userns itself, or is explicitly
allowelisted.

BPF LSM program with contributions from Alexei Starovoitov.

2 months agobuild-sys: pick up vmlinux.h from running kernel BTF or user
Lennart Poettering [Wed, 6 Dec 2023 17:37:31 +0000 (18:37 +0100)] 
build-sys: pick up vmlinux.h from running kernel BTF or user

2 months agodissect-image: document one more dissected_image_decrypt() error code
Lennart Poettering [Tue, 23 Jan 2024 15:19:38 +0000 (16:19 +0100)] 
dissect-image: document one more dissected_image_decrypt() error code

2 months agodissect-image: make dissected_image_acquire_metadata() operate within a userns if...
Lennart Poettering [Mon, 4 Dec 2023 17:23:31 +0000 (18:23 +0100)] 
dissect-image: make dissected_image_acquire_metadata() operate within a userns if possible

This opens the door for making the call work without privileges: if we
pass in a userns fd and DissectedImage that has mount fds then we can
acquire all information without privs.

2 months agodissect-image: add a new helper that checks if VeritySettings has anything set at all
Lennart Poettering [Mon, 4 Dec 2023 17:12:58 +0000 (18:12 +0100)] 
dissect-image: add a new helper that checks if VeritySettings has anything set at all

2 months agodissect-image: add dissected_image_close() that closes all references to resources
Lennart Poettering [Tue, 14 Mar 2023 21:46:56 +0000 (22:46 +0100)] 
dissect-image: add dissected_image_close() that closes all references to resources

2 months agodiscover-image: export search paths array
Lennart Poettering [Wed, 26 Apr 2023 19:22:06 +0000 (21:22 +0200)] 
discover-image: export search paths array

This way we can use it to validate image paths later.

2 months agocgroup-setup: add fd-based version of cg_attach()
Lennart Poettering [Tue, 12 Dec 2023 10:02:59 +0000 (11:02 +0100)] 
cgroup-setup: add fd-based version of cg_attach()

2 months agocgroup-util: add helpers for opening cgroup by id
Lennart Poettering [Tue, 12 Dec 2023 09:44:57 +0000 (10:44 +0100)] 
cgroup-util: add helpers for opening cgroup by id

2 months agolock-util: make global lock return parameter to image_path_lock() optional
Lennart Poettering [Fri, 8 Dec 2023 09:47:38 +0000 (10:47 +0100)] 
lock-util: make global lock return parameter to image_path_lock() optional

When adding unprivileged nspawn support we don't really want a global
lock file, since we cannot even access the dir they are stored in, hence
make the concept optional.

Some minor other modernizations.

2 months agobpf-dlopen: pick up more symbols from libbpf
Lennart Poettering [Fri, 1 Mar 2024 16:31:06 +0000 (17:31 +0100)] 
bpf-dlopen: pick up more symbols from libbpf

2 months agonamespace-util: add new helper is_our_namespace()
Lennart Poettering [Wed, 6 Dec 2023 10:35:04 +0000 (11:35 +0100)] 
namespace-util: add new helper is_our_namespace()

2 months agonamespace-util: add namespace_open_by_type() helper
Lennart Poettering [Tue, 5 Dec 2023 10:51:26 +0000 (11:51 +0100)] 
namespace-util: add namespace_open_by_type() helper

2 months agonamespace-util: add detach_mount_namespace_userns()
Lennart Poettering [Tue, 14 Mar 2023 21:36:35 +0000 (22:36 +0100)] 
namespace-util: add detach_mount_namespace_userns()

2 months agonamespace-util: add helper for allocating an empty userns fd
Lennart Poettering [Tue, 14 Mar 2023 16:22:18 +0000 (17:22 +0100)] 
namespace-util: add helper for allocating an empty userns fd

2 months agonamespace-util: add detach_mount_namespace_harder()
Lennart Poettering [Mon, 13 Mar 2023 14:23:11 +0000 (15:23 +0100)] 
namespace-util: add detach_mount_namespace_harder()

This is just like detach_mount_namespace() but if need be uses unpriv
user namespaces to be able to execute CLONE_NEWNS.

2 months agouid-range: add some basic operations on UidRange objects
Lennart Poettering [Thu, 20 Apr 2023 16:51:26 +0000 (18:51 +0200)] 
uid-range: add some basic operations on UidRange objects

Helpers to compare and get size, and whether the object is empty.

2 months agouid-range: add new uid_range_load_userns_by_fd() helper
Lennart Poettering [Thu, 20 Apr 2023 16:51:55 +0000 (18:51 +0200)] 
uid-range: add new uid_range_load_userns_by_fd() helper

This is similar to uid_range_load_userns() but instead of reading the
uid_map off a process it reads it off a userns fd.

(Of course the kernel has no API for this right now, hence we fork off a
throw-away process which joins the user namespace, and then read off the
data from there.)

2 months agouid-range: optionally load outside view of UID range from uid_map procfs file
Lennart Poettering [Thu, 20 Apr 2023 16:51:03 +0000 (18:51 +0200)] 
uid-range: optionally load outside view of UID range from uid_map procfs file

2 months agouid-range: add uid_range_overlaps() helper
Lennart Poettering [Tue, 14 Mar 2023 09:38:58 +0000 (10:38 +0100)] 
uid-range: add uid_range_overlaps() helper

2 months agoimage-policy: add a new image_policy_intersect() call
Lennart Poettering [Wed, 26 Apr 2023 19:51:53 +0000 (21:51 +0200)] 
image-policy: add a new image_policy_intersect() call

This new call takes two image policy objects and generates an
"intersection" policy, i.e. only allows what is allowed by both. Or in
other words it conceptually implements a binary AND of the policy flags.
(Except that it's a bit harder, due to normalization, and underspecified
flags).

We can use this later for mountfsd: a client can specify a policy, and
mountfsd can specify another policy, and we'll then apply only what both
allow.

Note that a policy generated like this might be invalid. For example, if
one policy says root must exist and be verity or luks protected, and the
other policy says root must be absent, then the intersection is invalid,
since one policy only allows what the other prohibits and vice versa.
We'll return a clear error code in that case (ENAVAIL). (This is because
we simply don't allow encoding such impossible policies in an
ImagePolicy structure, for good reasons.)

2 months agovarlink: add varlink_peek_dup_fd() helper
Lennart Poettering [Tue, 23 Jan 2024 09:22:27 +0000 (10:22 +0100)] 
varlink: add varlink_peek_dup_fd() helper

This new call is like varlink_peek_fd() (i.e. gets an fd out of the
connection but leaving it also in there), and combines ith with
F_DUPFD_CLOEXEC to make a copy of it.

We previously already had varlink_dup_fd() which was a duplicating
version for pushing an fd *into* the connection. To reduce confusion,
let's rename that one varlink_push_dup_fd() to make the symmetry to
valrink_push_fd() clear so that we have no:

varlink_peer_push_fd()        → put fd in without dup'ing
varlink_peer_push_dup_fd()    → same with F_DUPFD_CLOEXEC
varlink_peer_peek_fd()        → get fd out without dup'ing
varlink_peer_peek_dup_fd()    → same with F_DUPFD_CLOEXEC

2 months agovarlink: add varlink_get_peer_gid() helper
Lennart Poettering [Tue, 19 Dec 2023 12:12:14 +0000 (13:12 +0100)] 
varlink: add varlink_get_peer_gid() helper

2 months agotest: improve debug-ability of test-execute
Frantisek Sumsal [Fri, 5 Apr 2024 19:23:42 +0000 (21:23 +0200)] 
test: improve debug-ability of test-execute

Since e56a8790a0 debugging test-execute fails has been a royal PITA, since
we ditch all potentially useful output from the test units (that, for
the most part, run `sh -x ...`). Let's improve the situation a bit by
setting EXEC_OUTPUT_NULL only when running the single test case that
needs it, and inheriting stdout otherwise.

For example, with a purposefully introduced error we get this output
with this patch:
exec-personality-x86-64.service: About to execute: sh -x -c "c=\$\$(uname -m); test \"\$\$c\" = \"foo_bar\""
Serializing sd-executor-state to memfd.
...
        Personality: x86-64
        LockPersonality: no
        SystemCallErrorNumber: kill
++ uname -m
+ c=x86_64
+ test x86_64 = foo_bar
Received SIGCHLD from PID 1520588 (sh).
Child 1520588 (sh) died (code=exited, status=1/FAILURE)
exec-personality-x86-64.service: Child 1520588 belongs to exec-personality-x86-64.service.
exec-personality-x86-64.service: Main process exited, code=exited, status=1/FAILURE
exec-personality-x86-64.service: Failed with result 'exit-code'.
...
        Exit Status: 1
src/test/test-execute.c:456:test_exec_personality: exec-personality-x86-64.service: can_unshare=yes: exit status 1, expected 0
(test-execute-root) terminated by signal ABRT.
Assertion 'r >= 0' failed at src/test/test-execute.c:1433, function prepare_ns(). Aborting.
Aborted

But without it, we'd miss the most important part:
exec-personality-x86-64.service: About to execute: sh -x -c "c=\$\$(uname -m); test \"\$\$c\" = \"foo_bar\""
Serializing sd-executor-state to memfd.
...
        Personality: x86-64
        LockPersonality: no
        SystemCallErrorNumber: kill
Received SIGCHLD from PID 1521365 (sh).
Child 1521365 (sh) died (code=exited, status=1/FAILURE)
exec-personality-x86-64.service: Child 1521365 belongs to exec-personality-x86-64.service.
exec-personality-x86-64.service: Main process exited, code=exited, status=1/FAILURE
exec-personality-x86-64.service: Failed with result 'exit-code'.
...
        Exit Status: 1
src/test/test-execute.c:456:test_exec_personality: exec-personality-x86-64.service: can_unshare=yes: exit status 1, expected 0
(test-execute-root) terminated by signal ABRT.
Assertion 'r >= 0' failed at src/test/test-execute.c:1433, function prepare_ns(). Aborting.
Aborted

2 months agoMerge pull request #31131 from poettering/dlopen-kmod
Luca Boccassi [Sat, 6 Apr 2024 12:19:27 +0000 (13:19 +0100)] 
Merge pull request #31131 from poettering/dlopen-kmod

turn libkmod into a dlopen() dependency, too

2 months agoman: fix typo s/veno/reno/
Vito Caputo [Sat, 6 Apr 2024 04:11:28 +0000 (21:11 -0700)] 
man: fix typo s/veno/reno/

2 months agoMerge pull request #32115 from YHNdnzj/service-main-pid-take
Luca Boccassi [Fri, 5 Apr 2024 22:53:13 +0000 (23:53 +0100)] 
Merge pull request #32115 from YHNdnzj/service-main-pid-take

core/service: a few improvements for main pid handling

2 months agoMerge pull request #32123 from mrc0mmand/assorted-tweaks
Luca Boccassi [Fri, 5 Apr 2024 21:22:06 +0000 (22:22 +0100)] 
Merge pull request #32123 from mrc0mmand/assorted-tweaks

A couple of assorted tweaks

2 months agoMerge pull request #32125 from YHNdnzj/post-merge-stuff
Luca Boccassi [Fri, 5 Apr 2024 21:18:31 +0000 (22:18 +0100)] 
Merge pull request #32125 from YHNdnzj/post-merge-stuff

Trivial post merge stuff

2 months agocore/service: add a FIXME to use pidfd to monitor foreign processes 32115/head
Mike Yuan [Fri, 5 Apr 2024 10:41:07 +0000 (18:41 +0800)] 
core/service: add a FIXME to use pidfd to monitor foreign processes

2 months agocore/service: complain louder if new MAINPID= is refused
Mike Yuan [Fri, 5 Apr 2024 10:28:13 +0000 (18:28 +0800)] 
core/service: complain louder if new MAINPID= is refused

2 months agocore/service: make service_set_main_pidref consume pidref
Mike Yuan [Fri, 5 Apr 2024 10:21:50 +0000 (18:21 +0800)] 
core/service: make service_set_main_pidref consume pidref

Currently, the memory management of service_set_main_pidref
is a bit odd. Normally we either invalidate the original
resource on caller's side after the call succeeds, or
just pass the ownership wholly. But service_set_main_pidref
take a pointer, and calls pidref_done() internally.

Let's just make it consume the passed pidref. This is more
straightforward.

2 months agosleep: rename SleepMemMode= to MemorySleepMode= 32125/head
Mike Yuan [Fri, 5 Apr 2024 18:10:17 +0000 (02:10 +0800)] 
sleep: rename SleepMemMode= to MemorySleepMode=

Addresses https://github.com/systemd/systemd/pull/31986#discussion_r1554053623

2 months agoos-util: use ENDSWITH_SET where appropriate
Mike Yuan [Fri, 5 Apr 2024 18:06:38 +0000 (02:06 +0800)] 
os-util: use ENDSWITH_SET where appropriate

Addresses https://github.com/systemd/systemd/pull/31435#discussion_r1553969156

Co-authored-by: Lennart Poettering <lennart@poettering.net>
2 months agobase-filesystem: check for __s390x__ first 32123/head
Frantisek Sumsal [Fri, 5 Apr 2024 17:33:28 +0000 (19:33 +0200)] 
base-filesystem: check for __s390x__ first

On s390x both __s390__ and __s390x__ are defined, and with the original
order we'd go through the __s390__ branch and emit a warning:

[169/2118] Compiling C object src/shared/libsystemd-shared-256.a.p/base-filesystem.c.o
../src/shared/base-filesystem.c:136:11: note: ‘#pragma message: Please add an entry above specifying whether your architecture uses /lib64/, /lib32/, or no such links.’
  136 | #  pragma message "Please add an entry above specifying whether your architecture uses /lib64/, /lib32/, or no such links."
      |           ^~~~~~~

2 months agotest: account for build dir being under one of the tmpfs-ed directories
Frantisek Sumsal [Fri, 5 Apr 2024 17:23:12 +0000 (19:23 +0200)] 
test: account for build dir being under one of the tmpfs-ed directories

If we're running test-execute from the build directory which is under
one of the tmpfs-ed directories (i.e. /root or /tmp), test-execute might
behave strangely, since in that case manager_new() pins the system
systemd-executor binary instead of the build dir one, which may lead to
a very confusing test fails (if there's enough difference between the
system and built sd-executor binary). Let's account for that and
bind-mount the build dir under the tmpfs-ed directory if necessary.

2 months agotest: make test-fd-util more lenient when using fd_move_above_stdio()
Frantisek Sumsal [Fri, 5 Apr 2024 10:18:58 +0000 (12:18 +0200)] 
test: make test-fd-util more lenient when using fd_move_above_stdio()

On s390x this test fails when the SUT uses the z90crypt kernel module,
as it's an another FD the test doesn't account for:

/* test_rearrange_stdio */
Successfully forked off 'rearrange' as PID 57293.
test_rearrange_stdio: r=0
/proc/57293/fd:
total 0
lrwx------. 1 root root 64 Apr  5 06:18 0 -> /dev/pts/0
lrwx------. 1 root root 64 Apr  5 06:18 1 -> /dev/pts/0
lrwx------. 1 root root 64 Apr  5 06:18 2 -> /dev/pts/0
lrwx------. 1 root root 64 Apr  5 06:18 3 -> /dev/z90crypt
rearrange terminated by signal ABRT.

Debugging this was pain, since the child process didn't log anything
once we closed stdout/stderr (for obvious reasons). Let's fix both
issues by switching logging to kmsg once we close stdin/stdout/stderr,
and also by making the test work fine when there are some extra FDs in
the child's environment.

2 months agoMerge pull request #31435 from bluca/portable_fix_versioned
Zbigniew Jędrzejewski-Szmek [Fri, 5 Apr 2024 15:04:17 +0000 (17:04 +0200)] 
Merge pull request #31435 from bluca/portable_fix_versioned

portable: assorted bug fixes

2 months agosd-journal: fix check in `journal_file_verify_header()`
Antonio Alvarez Feijoo [Fri, 5 Apr 2024 06:27:36 +0000 (08:27 +0200)] 
sd-journal: fix check in `journal_file_verify_header()`

Fixes 6ea51363c8e39fb0924dda972a212936456a2b4f

2 months agolog: fix comment
Frantisek Sumsal [Fri, 5 Apr 2024 10:14:18 +0000 (12:14 +0200)] 
log: fix comment

2 months agocore: Serialize both pid and pidfd to keep downgrades working
Daan De Meyer [Wed, 3 Apr 2024 14:06:14 +0000 (16:06 +0200)] 
core: Serialize both pid and pidfd to keep downgrades working

Currently, when downgrading from a version with pidfd support to a
version without pidfd support, all information about running processes
is lost as the newer systemd will serialized pidfds which are not recognized
by the older systemd when deserializing.

To improve the situation, let's serialize both the pid and the pidfd.
This is safe because existing versions will either replace the first
deserialized pidref with the second one or discard the second one in
favor of the first one depending on the unit and field. Older versions
that don't support pidfd's will silently discard any fields that contain
a pidfd as those will try to parse the field as a pid and since a pidfd
field will start with '@', those versions will debug error log and ignore
the value.

To make sure we reuse the existing pidfd as much as possible, the pidfd
is serialized first. Both for scopes and service main pids, if the same
pid is seen multiple times, the first pidref is kept. So by serializing
the pidfd first we make sure the original pidfd is used instead of the
new one which is opened when deserializing the first pid field.

For other control units, older versions with pidfd support will discard
the first pidfd and replace it with a new pidfd from the second pid field.
This is a slight regression on downgrades, but we make sure it doesn't
happen for future versions (and older versions when this commit is
backported) by modifying the logic to only use the first successfully
deserialized pidref so that the raw pid without pidfd is discarded instead
of it replacing the existing pidfd.

2 months agomeson: set -fno-ssa-phiopt when building bpf with gcc
Luca Boccassi [Thu, 4 Apr 2024 22:42:45 +0000 (23:42 +0100)] 
meson: set -fno-ssa-phiopt when building bpf with gcc

There are bugs in the kernel verifier that cause legitimate code
to be rejected, disabling this optimization makes bpf programs
built with a new enough gcc work again.

Fixes https://github.com/systemd/systemd/issues/31888

2 months agohwdb: fix missing colon (#32108)
Kirk [Fri, 5 Apr 2024 01:18:59 +0000 (20:18 -0500)] 
hwdb: fix missing colon (#32108)

Missing colon prevents this from working correctly on the Chuwi UBook X and UBook X Pro.

2 months agoMerge pull request #32085 from yuwata/udev-check-processing 32089/head
Luca Boccassi [Thu, 4 Apr 2024 22:46:26 +0000 (23:46 +0100)] 
Merge pull request #32085 from yuwata/udev-check-processing

udev: check ID_PROCESSING udev property more

2 months agotest-network: add test cases for Redirect and Neighbor Advertisement message handling 32104/head
Yu Watanabe [Tue, 5 Mar 2024 06:08:12 +0000 (15:08 +0900)] 
test-network: add test cases for Redirect and Neighbor Advertisement message handling

2 months agotest: introduce a test executable to send NDisc message
Yu Watanabe [Tue, 5 Mar 2024 05:24:19 +0000 (14:24 +0900)] 
test: introduce a test executable to send NDisc message

2 months agonetwork/ndisc: add basic support for Redirect message
Yu Watanabe [Fri, 23 Feb 2024 03:03:26 +0000 (12:03 +0900)] 
network/ndisc: add basic support for Redirect message

Closes #31438.

2 months agosd-ndisc: add basic support of Redirect message
Yu Watanabe [Thu, 22 Feb 2024 03:31:49 +0000 (12:31 +0900)] 
sd-ndisc: add basic support of Redirect message

This makes sd-ndisc support Redirect message defined in RFC 4861.

2 months agonetwork/ndisc: remember the latest RA from the default router
Yu Watanabe [Fri, 23 Feb 2024 02:42:33 +0000 (11:42 +0900)] 
network/ndisc: remember the latest RA from the default router

The remembered RA will be used later. Preparation for later commits.

2 months agoMerge pull request #31373 from yuwata/network-neighbor-advertisement
Yu Watanabe [Thu, 4 Apr 2024 20:54:12 +0000 (05:54 +0900)] 
Merge pull request #31373 from yuwata/network-neighbor-advertisement

network: add basic support of neighbor advertisement