systemd/.git
13 months agosd-daemon: add fd array size safety check to sd_notify_with_fds()
Lennart Poettering [Mon, 4 Nov 2024 10:18:29 +0000 (11:18 +0100)]
sd-daemon: add fd array size safety check to sd_notify_with_fds()

The previous commit removed the UINT_MAX check for the fd array. Let's
now re-add one, but at a better place, and with a more useful limit. As
it turns out the kernel does not allow passing more than 253 fds at the
same time, hence use that as limit. And do so immediately before
calculating the control buffer size, so that we catch multiplication
overflows.

13 months agosd-daemon: count array elements in size_t
Lennart Poettering [Mon, 4 Nov 2024 10:01:23 +0000 (11:01 +0100)]
sd-daemon: count array elements in size_t

We fucked that up in the original sd_listen() calls, and then we fixed
that on the newer flavours. But pour internal common implementation
should of course use the full range size_t, as it should be.

This then allows us to drop a redundant range check.

13 months agosd-daemon: drop some redundant 'else'
Lennart Poettering [Mon, 4 Nov 2024 10:01:07 +0000 (11:01 +0100)]
sd-daemon: drop some redundant 'else'

13 months agosd-daemon: clean up env var unsetting
Lennart Poettering [Mon, 4 Nov 2024 09:46:37 +0000 (10:46 +0100)]
sd-daemon: clean up env var unsetting

This cleans up the handling of the "unset_environment" parameter to
sd_listen() and related calls: the man pages claim we operate on it on
error too. Hence, actually do so in strictly all error paths. Previously
we'd miss out on some, because wrapper functions mishandled them.

This was addressed before in 362dcfc5db0271cd6b3a564c528cabf0ac0e7993
but some codepaths were missed. Complete the work now.

This establishes a common pattern: a function to unset the relevant env
vars, that is called from a goto section at the botom on both success
and failure.

13 months agoupdate TODO
Lennart Poettering [Mon, 4 Nov 2024 09:45:26 +0000 (10:45 +0100)]
update TODO

13 months agoudev-builtin-path_id: SAS wide ports must have num_phys > 1
Martin Wilck [Wed, 30 Oct 2024 15:57:39 +0000 (16:57 +0100)]
udev-builtin-path_id: SAS wide ports must have num_phys > 1

Some kernel SAS drivers (e.g. smartpqi) expose ports with num_phys = 0. udev
shouldn't treat these ports as wide ports.  SAS wide ports always have
num_phys > 1. See comments for sas_port_add_phy() in the kernel sources.

Sample data from a smartpqi system to illustrate the issue below.
Here the phy device is attached to port 0:0, which has no end devices attached
and the SAS end device (where sda is attached) is associated with SAS
port 0:1, which has no associated phy device. Thus num_phys for port-0:1 is 0.
This is arguably wrong, but it's how smartpqi has always set up its devices in
sysfs.

/sys/class/sas_phy/phy-0:0 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/sas_phy/phy-0:0
/sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:0/phy-0:0 -> ../phy-0:0
/sys/devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/phy-0:0/port -> ../port-0:0

/sys/class/sas_device/end_device-0:1 -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/sas_device/end_device-0:1
/sys/class/block/sda -> ../../devices/pci0000:46/0000:46:02.0/0000:47:00.0/host0/scsi_host/host0/port-0:1/end_device-0:1/target0:0:0/0:0:0:0/block/sda

Signed-off-by: Martin Wilck <mwilck@suse.com>
13 months agoopenssl-util: Query engine/provider pin via ask-password (#34948)
Daan De Meyer [Sun, 3 Nov 2024 11:54:20 +0000 (12:54 +0100)]
openssl-util: Query engine/provider pin via ask-password (#34948)

In mkosi, we want to support signing via a hardware token. We already
support this in systemd-repart and systemd-measure. However, if the
hardware token is protected by a pin, the pin is asked as many as 20
times when building an image as the pin is not cached and thus requested
again for every operation.

Let's introduce a custom openssl ui when we use engines and providers
and plug systemd-ask-password into the process. With
systemd-ask-password, the pin can be cached in the kernel keyring,
allowing us to reuse it without querying the user again every time to
enter the pin.

We use the private key URI as the keyring identifier so that the cached
pin can be shared across multiple tools.

13 months agobootctl: Add --secure-boot-auto-enroll
Daan De Meyer [Thu, 31 Oct 2024 22:33:36 +0000 (23:33 +0100)]
bootctl: Add --secure-boot-auto-enroll

When specified, bootctl install will also set up secure boot
auto-enrollment. For now, We sign all variables using the same
certificate and key pair.

13 months agoopenssl-util: Query engine/provider pin via ask-password
Daan De Meyer [Wed, 30 Oct 2024 14:47:58 +0000 (15:47 +0100)]
openssl-util: Query engine/provider pin via ask-password

In mkosi, we want to support signing via a hardware token. We already
support this in systemd-repart and systemd-measure. However, if the
hardware token is protected by a pin, the pin is asked as many as 20
times when building an image as the pin is not cached and thus requested
again for every operation.

Let's introduce a custom openssl ui when we use engines and providers
and plug systemd-ask-password into the process. With systemd-ask-password,
the pin can be cached in the kernel keyring, allowing us to reuse it without
querying the user again every time to enter the pin.

We use the private key URI as the keyring identifier so that the cached pin
can be shared across multiple tools.

Note that if the private key is pin protected, openssl will prompt both when
loading the private key using the pkcs11 engine and when actually signing the
roothash. To make sure our custom UI is used when signing the roothash, we have
to also configure it with ENGINE_ctrl() which takes a non-owning pointer to
the UI_METHOD object and its userdata object which we have to keep alive so we
introduce a new AskPasswordUserInterface struct which we use to keep both objects
alive together with the EVP_PKEY object.

Because the AskPasswordRequest struct stores non-owning pointers to its fields,
we change repart to store the private key URI as a global variable again instead
of the EVP_PKEY object so that we can use the private key argument as the keyring
field of the AskPasswordRequest instance without running into lifetime issues.

13 months agoefivars: Remove STRINGIFY() helper macros
Daan De Meyer [Thu, 31 Oct 2024 12:54:33 +0000 (13:54 +0100)]
efivars: Remove STRINGIFY() helper macros

The names of these conflict with macros from efi.h that we'll move
to efi-fundamental.h in a later commit. Let's avoid the conflict by
getting rid of these helpers. Arguably this also improves readability
by clearly indicating we're passing arbitrary strings and not constants
to the macros when we invoke them.

13 months agoask-password: Add $SYSTEMD_ASK_PASSWORD_KEYRING_TYPE
Daan De Meyer [Wed, 30 Oct 2024 22:45:38 +0000 (23:45 +0100)]
ask-password: Add $SYSTEMD_ASK_PASSWORD_KEYRING_TYPE

Currently ask_password_auto() will always try to store the password into
the user keyring. Let's make this configurable so that we can configure
ask_password_auto() into the session keyring. This is required when working
with user namespaces, as the user keyring is namespaced by user namespaces
which makes it impossible to share cached keys across user namespaces by using
the user namespace while this is possible with the session keyring.

13 months agoask-password: Drop "default" for SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC
Daan De Meyer [Fri, 1 Nov 2024 11:45:29 +0000 (12:45 +0100)]
ask-password: Drop "default" for SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC

Users can simply unset the environment variable to achieve the same effect.

13 months agoask-password: Use default timeout if SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC is...
Daan De Meyer [Fri, 1 Nov 2024 12:48:58 +0000 (13:48 +0100)]
ask-password: Use default timeout if SYSTEMD_ASK_PASSWORD_KEYRING_TIMEOUT_SEC is unset

Follow-up for d9f4dad986dcebd51bdaeb8ba3d2c00cdc0d701e

13 months agomkosi: Add extra tools tree packages required to run integration tests
Daan De Meyer [Sat, 2 Nov 2024 21:13:31 +0000 (22:13 +0100)]
mkosi: Add extra tools tree packages required to run integration tests

With https://github.com/systemd/mkosi/pull/3164, we'll be able to run
arbitrary commands in the mkosi sandbox, which has /usr from the tools
tree if one is configured. Let's add the required packages to be able to
run meson to setup the integration tests. This allows running the integration
tests without having to install meson or other build dependencies on the
host system.

"""
mkosi sandbox meson setup build
mkosi sandbox meson compile -C build mkosi
mkosi sandbox env SYSTEMD_INTEGRATION_TESTS=1 meson test -C build ...
"""

13 months agobuild(deps): bump systemd/mkosi
dependabot[bot] [Sat, 2 Nov 2024 21:18:57 +0000 (21:18 +0000)]
build(deps): bump systemd/mkosi

Bumps [systemd/mkosi](https://github.com/systemd/mkosi) from 2a35f9958bc6b82d95d1eac02dc245e9bb068765 to 8976a0abb19221e65300222f2d33067970cca0f1.
- [Release notes](https://github.com/systemd/mkosi/releases)
- [Commits](https://github.com/systemd/mkosi/compare/2a35f9958bc6b82d95d1eac02dc245e9bb068765...8976a0abb19221e65300222f2d33067970cca0f1)

---
updated-dependencies:
- dependency-name: systemd/mkosi
  dependency-type: direct:production
...

Signed-off-by: dependabot[bot] <support@github.com>
13 months agoTwo integration test fixes (#34984)
Daan De Meyer [Sat, 2 Nov 2024 21:12:27 +0000 (22:12 +0100)]
Two integration test fixes (#34984)

13 months agoTEST-64-UDEV-STORAGE: Don't hardcode device name in long-sysfs-path test
Daan De Meyer [Fri, 1 Nov 2024 20:27:52 +0000 (21:27 +0100)]
TEST-64-UDEV-STORAGE: Don't hardcode device name in long-sysfs-path test

There's no guarantee our device will be named /dev/vda, so give it
a serial so we can query for its devname inside the test.

13 months agoTEST-17-UDEV: Don't hardcode root device name
Daan De Meyer [Fri, 1 Nov 2024 20:27:08 +0000 (21:27 +0100)]
TEST-17-UDEV: Don't hardcode root device name

There's no guarantee the root device will be /dev/sda, so let's use
bootctl to get the actual path instead of harcoding it.

13 months agopam: quiet a spurious debug message
Ronan Pigott [Sat, 2 Nov 2024 02:44:18 +0000 (19:44 -0700)]
pam: quiet a spurious debug message

This singular debug message gets printed even if debug is not enabled.
Quiet this message when debug is not enabled for consistency.

13 months agouser-record: add missing comma to list of strings
Luca Boccassi [Sat, 2 Nov 2024 11:06:18 +0000 (11:06 +0000)]
user-record: add missing comma to list of strings

Follow-up for ad03f2d5f0d7f87b775357e5a2727dbcbc973fce

13 months agomachine: introduce io.systemd.MachineImage.{Clone, Remove} methods (#34853)
Luca Boccassi [Sat, 2 Nov 2024 12:06:23 +0000 (12:06 +0000)]
machine: introduce io.systemd.MachineImage.{Clone, Remove} methods (#34853)

This PR introduces io.systemd.MachineImage.Clone and Remove methods.
They are 1:1 mapping to DBus alternatives.

13 months agoAdd support for id-mapped mounts to Exec directories (#34078)
Luca Boccassi [Sat, 2 Nov 2024 12:04:49 +0000 (12:04 +0000)]
Add support for id-mapped mounts to Exec directories (#34078)

Currently, bind-mounted directories within a user/mount namespace get
the uid/gid stored on their files. If the host creates a file in the
source directory, it will still show as root in the namespace.
Id-mapping is a filesystem feature that allows a mount namespace to show
a different uid than what is actually stored on a file. Add support for
id-mappings to exec directories, so that the files within the mount
namespace are owned by the unprivileged uid/gid.

Example:

Using unit:
```
[Unit]
Description=Sample service

[Service]
MountAPIVFS=yes
DynamicUser=yes
PrivateUsers=yes
TemporaryFileSystem=/run /var/opt /var/lib /vol
UMask=0000
ExecStart=/bin/bash -c 'while true; do echo "ping"; sleep 5; done'
StateDirectory=andresstatedir:sampleservice

[Install]
WantedBy=multi-user.target
```

In the host namespace, creating a file "test":
```
root@abeltran-test:/var/lib/andresstatedir# ls -lah
total 8.0K
drwxr-xr-x 2 root root 4.0K Aug 21 23:48 .
drwx------ 3 root root 4.0K Aug 21 23:47 ..
-rw-r--r-- 1 root root    0 Aug 21 23:48 test
```

Within the unit namespace:
```
root@abeltran-test:/var/lib/sampleservice# ls -lah
total 4.0K
drwxr-xr-x 2 63750 63750 4.0K Aug 21 23:48 .
drwxr-xr-x 3 root  root    60 Aug 21 23:47 ..
-rw-r--r-- 1 63750 63750    0 Aug 21 23:48 test
```
```
root@abeltran-test:/# mount | grep and
/dev/sda1 on /var/lib/private/andresstatedir type ext4 (rw,nosuid,noexec,relatime,idmapped,discard,errors=remount-ro,commit=30)
```

13 months agologind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers (#34969)
Luca Boccassi [Sat, 2 Nov 2024 11:27:28 +0000 (11:27 +0000)]
logind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers (#34969)

The check for the old flag was not restored when the weak blocker was
added, add it back. Also skip polkit check for root for the weak
blocker, to keep compatibility with the previous behaviour.

Partially fixes https://github.com/systemd/systemd/issues/34091

Follow-up for 804874d26ac73e0af07c4c5d7165c95372f03f6d

13 months agocore: add id-mapped mount support for Exec directories
Andres Beltran [Mon, 5 Aug 2024 23:43:29 +0000 (23:43 +0000)]
core: add id-mapped mount support for Exec directories

13 months agonamespace-util: add util function to check if id-mapped mounts are supported for...
Andres Beltran [Wed, 30 Oct 2024 17:51:53 +0000 (17:51 +0000)]
namespace-util: add util function to check if id-mapped mounts are supported for a given path

13 months agocore/service: don't propagate stop jobs if RestartMode=direct (#34768)
Lennart Poettering [Fri, 1 Nov 2024 16:25:49 +0000 (17:25 +0100)]
core/service: don't propagate stop jobs if RestartMode=direct (#34768)

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

13 months agoresolve: remove always-true superflous check and rename label
Luca Boccassi [Fri, 1 Nov 2024 13:51:57 +0000 (13:51 +0000)]
resolve: remove always-true superflous check and rename label

Fixes https://github.com/systemd/systemd/security/code-scanning/2900

13 months agologind: ensure the stronger inhibitor currently in place is taken into account
Luca Boccassi [Fri, 1 Nov 2024 14:39:51 +0000 (14:39 +0000)]
logind: ensure the stronger inhibitor currently in place is taken into account

13 months agologind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers
Luca Boccassi [Thu, 31 Oct 2024 16:02:38 +0000 (16:02 +0000)]
logind: respect SD_LOGIND_ROOT_CHECK_INHIBITORS with weak blockers

The check for the old flag was not restored when the weak
blocker was added, add it back. Also skip polkit check for
root for the weak blocker, to keep compatibility with the
previous behaviour.

Partially fixes https://github.com/systemd/systemd/issues/34091

Follow-up for 804874d26ac73e0af07c4c5d7165c95372f03f6d

13 months agomachine: remove redundant --more in TEST-13-NSPAWN.machined
Ivan Kruglov [Tue, 22 Oct 2024 09:16:53 +0000 (11:16 +0200)]
machine: remove redundant --more in TEST-13-NSPAWN.machined

13 months agomachine: tests for io.systemd.MachineImage.{Clone, Remove} methods
Ivan Kruglov [Mon, 21 Oct 2024 11:58:30 +0000 (13:58 +0200)]
machine: tests for io.systemd.MachineImage.{Clone, Remove} methods

13 months agomachine: use ImageUpdateParameters in io.systemd.MachineImage.Update
Ivan Kruglov [Tue, 22 Oct 2024 09:00:41 +0000 (11:00 +0200)]
machine: use ImageUpdateParameters in io.systemd.MachineImage.Update

13 months agomachine: reuse VARLINK_DEFINE_IMAGE_LOOKUP_AND_POLKIT_FIELDS in io.systemd.MachineIma...
Ivan Kruglov [Mon, 21 Oct 2024 11:54:58 +0000 (13:54 +0200)]
machine: reuse VARLINK_DEFINE_IMAGE_LOOKUP_AND_POLKIT_FIELDS in io.systemd.MachineImage.Update declaration

13 months agomachine: introduce io.systemd.MachineImage.Remove method
Ivan Kruglov [Mon, 21 Oct 2024 11:54:42 +0000 (13:54 +0200)]
machine: introduce io.systemd.MachineImage.Remove method

13 months agomachine: introduce io.systemd.MachineImage.Clone method
Ivan Kruglov [Mon, 21 Oct 2024 11:53:38 +0000 (13:53 +0200)]
machine: introduce io.systemd.MachineImage.Clone method

13 months agomachine: use report_errno_and_exit() in dbus code
Ivan Kruglov [Thu, 31 Oct 2024 10:01:16 +0000 (11:01 +0100)]
machine: use report_errno_and_exit() in dbus code

13 months agomachine: introduce report_errno_and_exit()
Ivan Kruglov [Thu, 31 Oct 2024 09:58:21 +0000 (10:58 +0100)]
machine: introduce report_errno_and_exit()

13 months agomachine: align polkit verb of io.systemd.MachineImage.Update with the rest of the...
Ivan Kruglov [Mon, 21 Oct 2024 11:51:22 +0000 (13:51 +0200)]
machine: align polkit verb of io.systemd.MachineImage.Update with the rest of the code

13 months agohwdb: update for v257 (#34976)
Luca Boccassi [Fri, 1 Nov 2024 12:32:56 +0000 (12:32 +0000)]
hwdb: update for v257 (#34976)

13 months agoupdate hwdb
Lennart Poettering [Fri, 1 Nov 2024 09:17:58 +0000 (10:17 +0100)]
update hwdb

13 months agohwdb: import newest autosuspend rules from chromeos
Lennart Poettering [Fri, 1 Nov 2024 09:14:09 +0000 (10:14 +0100)]
hwdb: import newest autosuspend rules from chromeos

13 months agomkosi: Set BuildSourcesEphemeral=no in mkosi.clangd
Daan De Meyer [Fri, 1 Nov 2024 12:05:46 +0000 (13:05 +0100)]
mkosi: Set BuildSourcesEphemeral=no in mkosi.clangd

We're just running a language server so no need to put a writable
overlay on top of the build sources to prevent modifications. This
hopefully helps the language server track modifications to the source
files better.

13 months agocoredump: lock down EnterNamespace= mount even more (#34975)
Luca Boccassi [Fri, 1 Nov 2024 12:25:35 +0000 (12:25 +0000)]
coredump: lock down EnterNamespace= mount even more (#34975)

Let's disable symlink following if we attach a container's mount tree to
our own mount namespace. We afte rall mount the tree to a different
location in the mount tree than where it was inside the container, hence
symlinks (if they exist) will all point to the wrong places (even if
relative, some might point to other places). And since symlink attacks
are a thing, and we let libdw operate on the tree, let's lock this down
as much as we can and simply disable symlink traversal entirely.

13 months agobuild(deps): bump meson from 1.5.2 to 1.6.0 in /.github/workflows
dependabot[bot] [Fri, 1 Nov 2024 09:28:07 +0000 (09:28 +0000)]
build(deps): bump meson from 1.5.2 to 1.6.0 in /.github/workflows

Bumps [meson](https://github.com/mesonbuild/meson) from 1.5.2 to 1.6.0.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.5.2...1.6.0)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
13 months agoUpdate NEWS
Luca Boccassi [Fri, 1 Nov 2024 11:39:26 +0000 (11:39 +0000)]
Update NEWS

13 months agoutil-lib/systemd-run: implement race-free PTY peer opening (#34953)
Luca Boccassi [Fri, 1 Nov 2024 11:29:19 +0000 (11:29 +0000)]
util-lib/systemd-run: implement race-free PTY peer opening (#34953)

This makes use of the new TIOCGPTPEER pty ioctl() for directly opening a
PTY peer, without going via path names. This is nice because it closes a
race around allocating and opening the peer. And also has the nice
benefit that if we acquired an fd originating from some other
namespace/container, we can directly derive the peer fd from it, without
having to reenter the namespace again.

13 months agotweaks to ANSI sequence (OSC) handling (#34964)
Luca Boccassi [Fri, 1 Nov 2024 11:18:57 +0000 (11:18 +0000)]
tweaks to ANSI sequence (OSC) handling (#34964)

Fixes: #34604

Prompted by that I realized we do not correctly recognize both "ST"
sequences we want to recognize, fix that.

13 months agoHomed update policy: user changing own settings (#31153)
Luca Boccassi [Fri, 1 Nov 2024 11:14:04 +0000 (11:14 +0000)]
Homed update policy: user changing own settings (#31153)

Rework of #30109 to deal with changes in #30840 and discussed changes to
behavior

Depends on and includes #30840

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

13 months agonetwork: update tunnel or vxlan with Local=dhcp4 and friends (#34957)
Luca Boccassi [Fri, 1 Nov 2024 11:10:21 +0000 (11:10 +0000)]
network: update tunnel or vxlan with Local=dhcp4 and friends (#34957)

Fixes #24854.

13 months agocore: add read-only flag for exec directories
Luca Boccassi [Mon, 28 Oct 2024 19:58:58 +0000 (19:58 +0000)]
core: add read-only flag for exec directories

When an exec directory is shared between services, this allows one of the
service to be the producer of files, and the other the consumer, without
letting the consumer modify the shared files.
This will be especially useful in conjunction with id-mapped exec directories
so that fully sandboxed services can share directories in one direction, safely.

13 months agotest: Test user record selfModifiable behavior
Adrian Vovk [Wed, 24 Apr 2024 23:41:03 +0000 (19:41 -0400)]
test: Test user record selfModifiable behavior

13 months agohomed: Allow user to change parts of their record
Adrian Vovk [Fri, 2 Feb 2024 03:53:09 +0000 (22:53 -0500)]
homed: Allow user to change parts of their record

This allows an unprivileged user that is active at the console to change
the fields that are in the selfModifiable allowlists (introduced in a
previous commit) without authenticating as a system administrator.

Administrators can disable this behavior per-user by setting the
relevant selfModifiable allowlists, or system-wide by changing the
policy of the org.freedesktop.home1.update-home-by-owner Polkit action.

13 months agouser-record: Introduce selfModifiable fields
Adrian Vovk [Wed, 24 Apr 2024 22:12:54 +0000 (18:12 -0400)]
user-record: Introduce selfModifiable fields

Allows the system administrator to configure what fields the user is
allowed to edit about themself, along with hard-coded defaults.

13 months agobuild(deps): bump actions/checkout from 4.2.0 to 4.2.2
dependabot[bot] [Fri, 1 Nov 2024 09:01:41 +0000 (09:01 +0000)]
build(deps): bump actions/checkout from 4.2.0 to 4.2.2

Bumps [actions/checkout](https://github.com/actions/checkout) from 4.2.0 to 4.2.2.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/d632683dd7b4114ad314bca15554477dd762a938...11bd71901bbe5b1630ceea73d27597364c9af683)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
13 months agoman: <strong> is not a valid docbook tag, but <emphasis> is
Lennart Poettering [Fri, 1 Nov 2024 09:03:15 +0000 (10:03 +0100)]
man: <strong> is not a valid docbook tag, but <emphasis> is

13 months agoupdate NEWS
Lennart Poettering [Fri, 1 Nov 2024 09:02:55 +0000 (10:02 +0100)]
update NEWS

13 months agocoredump: rename gather_pid_mount_tree_fd() → acquire_pid_mount_tree_fd()
Lennart Poettering [Fri, 1 Nov 2024 09:05:32 +0000 (10:05 +0100)]
coredump: rename gather_pid_mount_tree_fd() → acquire_pid_mount_tree_fd()

From my understanding of the english language "gather" imples there are
multiple things to gather. But here there's only one, hence use
"acquire"

13 months agocoredump: lock down EnterNamespace= mount even more
Lennart Poettering [Fri, 1 Nov 2024 09:03:26 +0000 (10:03 +0100)]
coredump: lock down EnterNamespace= mount even more

Let's disable symlink following if we attach a container's mount tree to
our own mount namespace. We afte rall mount the tree to a different
location in the mount tree than where it was inside the container, hence
symlinks (if they exist) will all point to the wrong places (even if
relative, some might point to other places). And since symlink attacks
are a thing, and we let libdw operate on the tree, let's lock this down
as much as we can and simply disable symlink traversal entirely.

13 months agocoredump: rework protocol between coredump pattern handler and processing service...
Lennart Poettering [Fri, 1 Nov 2024 07:15:05 +0000 (08:15 +0100)]
coredump: rework protocol between coredump pattern handler and processing service (#34970)

In
https://github.com/systemd/systemd/commit/68511cebe58977ea68ae4f57c6462e979efd1cff
the ability to pass the
coredump's mount namespace fd from the coredump patter handler was added
to systemd-coredump. For this the protocol was augmented, in attempt to
provide both forward and backward compatibility.

The protocol as of v256: one or more datagrams with journal log fields
about the coredump are sent via an SOCK_SEQPACKET connection. It is
finished with a zero length datagram which carries the coredump fd (this
last datagram is called "sentinel" sometimes).

The protocol after
https://github.com/systemd/systemd/commit/68511cebe58977ea68ae4f57c6462e979efd1cff
is extended
so that after the sentinal a 2nd sentinel is sent, with a pair of fds:
the coredump fd *again* and a mount fd (acquired via open_tree()) of the
container's mount tree. It's a bit ugly to send the coredump fd a 2nd
time, but what's more important the implementation didn't work: since on
SOCK_SEQPACKET a zero sized datagram cannot be distinguished from EOF
(which is a Linux API design mistake), an early EOF would be
misunderstood as a zero size datagram lacking any fd, which resulted in
protocol termination.

Moreover, I think if we touch the protocol we should make the move to
pidfs at the same time.

All of the above is what this protocol rework addresses.

1. A pidfd is now sent as well

2. The protocol is now payload, followed by the coredump fd datagram (as
   before).  But now followed by a second empty datagram with a pidfd,
   and a third empty datagram with the mount tree fd. Of this the latter
   two or last are optional. Thus, it's now a stream of payload
   datagrams with one, two or three fd-laden datagrams as sentinel. If
   we read the 2nd or 3rd sentinel without an attached fd we assume this
   is actually an EOF (whether it actually is one or not doesn't matter
   here). This should provide nice up and down compatibility.

3. The mount_tree_fd is moved into the Context object. The pidfd is
   placed there too, as a PidRef. Thus the data we pass around is now
   the coredump fd plus the context, which is simpler and makes a lot
   more semantical sense I think.

4. The "first" boolean is replaced by an explicit state engine enum

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

13 months agocoredump: make check that all argv[] meta data fields are passed strict
Lennart Poettering [Thu, 31 Oct 2024 16:02:59 +0000 (17:02 +0100)]
coredump: make check that all argv[] meta data fields are passed strict

Otherwise, if some field is not supplied we might end up parsing a NULL
string later. Let's catch that early.

13 months agocoredump: use memory_startswith() when looking at a data blob
Lennart Poettering [Thu, 31 Oct 2024 15:53:39 +0000 (16:53 +0100)]
coredump: use memory_startswith() when looking at a data blob

13 months agoiovw: normalize destructors
Lennart Poettering [Thu, 31 Oct 2024 15:05:49 +0000 (16:05 +0100)]
iovw: normalize destructors

instead of passing a boolean picking the destruction method just have
different functions. That's much nicer in context of _cleanup_, and how
we usually do things.

13 months agoiovw: add simpler iovw_done() destructor
Lennart Poettering [Thu, 31 Oct 2024 15:00:13 +0000 (16:00 +0100)]
iovw: add simpler iovw_done() destructor

13 months agocoredump: move to _cleanup_ for destroying iovw object
Lennart Poettering [Thu, 31 Oct 2024 14:44:54 +0000 (15:44 +0100)]
coredump: move to _cleanup_ for destroying iovw object

13 months agocoredump: parse rlimit field at same place as other fields
Lennart Poettering [Thu, 31 Oct 2024 14:37:09 +0000 (15:37 +0100)]
coredump: parse rlimit field at same place as other fields

13 months agocoredump: parse signal number at the same time as parsing other fields
Lennart Poettering [Thu, 31 Oct 2024 14:33:44 +0000 (15:33 +0100)]
coredump: parse signal number at the same time as parsing other fields

13 months agocoredump: rename save_context() → context_parse_iovw()
Lennart Poettering [Thu, 31 Oct 2024 14:15:33 +0000 (15:15 +0100)]
coredump: rename save_context() → context_parse_iovw()

The function doesn't "save" anything, it just parses iovw into the
individual fields, hence name the function accordingly.

13 months agocoredump: acquire some process fields via pidref
Lennart Poettering [Thu, 31 Oct 2024 14:11:39 +0000 (15:11 +0100)]
coredump: acquire some process fields via pidref

Use pidref to acquire some fields. This just makes use of the pidref
helpers we already have. We acquire a lot of other data via classic pids
still, but for that we first have to write race-free pidref getters,
hence leave that for another time.

13 months agocoredump: rework protocol between coredump pattern handler and processing service
Lennart Poettering [Thu, 31 Oct 2024 13:52:43 +0000 (14:52 +0100)]
coredump: rework protocol between coredump pattern handler and processing service

In 68511cebe58977ea68ae4f57c6462e979efd1cff the ability to pass the
coredump's mount namespace fd from the coredump patter handler was added
to systemd-coredump. For this the protocol was augmented, in attempt to
provide both forward and backward compatibility.

The protocol as of v256: one or more datagrams with journal log fields
about the coredump are sent via an SOCK_SEQPACKET connection. It is
finished with a zero length datagram which carries the coredump fd (this
last datagram is called "sentinel" sometimes).

The protocol after 68511cebe58977ea68ae4f57c6462e979efd1cff is extended
so that after the sentinal a 2nd sentinel is sent, with a pair of fds:
the coredump fd *again* and a mount fd (acquired via open_tree()) of the
container's mount tree. It's a bit ugly to send the coredump fd a 2nd
time, but what's more important the implementation didn't work: since on
SOCK_SEQPACKET a zero sized datagram cannot be distinguished from EOF
(which is a Linux API design mistake), an early EOF would be
misunderstood as a zero size datagram lacking any fd, which resulted in
protocol termination.

Moreover, I think if we touch the protocol we should make the move to
pidfs at the same time.

All of the above is what this protocol rework addresses.

1. A pidfd is now sent as well

2. The protocol is now payload, followed by the coredump fd datagram (as
   before).  But now followed by a second empty datagram with a pidfd,
   and a third empty datagram with the mount tree fd. Of this the latter
   two or last are optional. Thus, it's now a stream of payload
   datagrams with one, two or three fd-laden datagrams as sentinel. If
   we read the 2nd or 3rd sentinel without an attached fd we assume this
   is actually an EOF (whether it actually is one or not doesn't matter
   here). This should provide nice up and down compatibility.

3. The mount_tree_fd is moved into the Context object. The pidfd is
   placed there too, as a PidRef. Thus the data we pass around is now
   the coredump fd plus the context, which is simpler and makes a lot
   more semantical sense I think.

4. The "first" boolean is replaced by an explicit state engine enum

Fixes: #34130

13 months agocoredump: correct debug log message
Lennart Poettering [Thu, 31 Oct 2024 13:51:06 +0000 (14:51 +0100)]
coredump: correct debug log message

13 months agocoredump: minor modernizations
Lennart Poettering [Thu, 31 Oct 2024 13:50:41 +0000 (14:50 +0100)]
coredump: minor modernizations

13 months agocoredump: rename pid → leader_pid
Lennart Poettering [Thu, 31 Oct 2024 13:45:38 +0000 (14:45 +0100)]
coredump: rename pid → leader_pid

Let's rename this local variable, since we are not operating on the
coredump process here after all, but on the leader of the namespace the
coredump process in, which is quite different, hence let's make this
very clear via the name.

13 months agoupdate TODO
Lennart Poettering [Thu, 31 Oct 2024 22:07:48 +0000 (23:07 +0100)]
update TODO

13 months agosd-varlink: suppress one log message when callback already successfully enqueued...
Yu Watanabe [Thu, 31 Oct 2024 19:02:54 +0000 (04:02 +0900)]
sd-varlink: suppress one log message when callback already successfully enqueued an error response

Follow-up for d2ebf5cc1d59e29139f06efaa3a9b2c184cdaa25.

The detailed error response is already logged, hence not necessary to
log again with the errno converted from the error response, which typically
less informative, e.g.
===
varlink-26-26: Setting state idle-server
varlink-26-26: Received message: {"method":"io.systemd.UserDatabase.GetUserRecord","parameters":{"service":""}}
varlink-26-26: Changing state idle-server → processing-method
varlink-26-26: Sending message: {"error":"io.systemd.UserDatabase.BadService","parameters":{}}
varlink-26-26: Changing state processing-method → processed-method
varlink-26-26: Callback for io.systemd.UserDatabase.GetUserRecord returned error: Invalid request descriptor
varlink-26-26: Changing state processed-method → idle-server
varlink-26-26: Got POLLHUP from socket.
===

13 months agoRework sysupdate meson options (#34832)
Luca Boccassi [Thu, 31 Oct 2024 21:10:28 +0000 (21:10 +0000)]
Rework sysupdate meson options (#34832)

systemd-sysupdated is still unstable and we'd like to make breaking
changes to it even after the v257 release, so we document it as such and
disable building it by default in release builds. The distro can still
opt-in, and we still build it in developer mode so it has CI coverage

13 months agomeson: add separate option for sysupdated, disable in release builds
Zbigniew Jędrzejewski-Szmek [Wed, 30 Oct 2024 13:21:09 +0000 (14:21 +0100)]
meson: add separate option for sysupdated, disable in release builds

This commit introduces a build-time option to enable/disable sysupdated
separately from sysupdate. 'auto' translated to enabled by default in
developer builds.

13 months agoDrop trailing NUL in .sbat/.sdmagic sections (#34950)
Lennart Poettering [Thu, 31 Oct 2024 20:48:18 +0000 (21:48 +0100)]
Drop trailing NUL in .sbat/.sdmagic sections (#34950)

13 months agologind/systemctl: one follow-up for DesignatedMaintenanceWindow (#34966)
Lennart Poettering [Thu, 31 Oct 2024 20:47:45 +0000 (21:47 +0100)]
logind/systemctl: one follow-up for DesignatedMaintenanceWindow (#34966)

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

13 months agomachine: several follow-ups for recent change (#34882)
Lennart Poettering [Thu, 31 Oct 2024 20:43:18 +0000 (21:43 +0100)]
machine: several follow-ups for recent change (#34882)

Follow-ups for #34761.

13 months agosd-json: don't accidentally convert between unsigned/signed when parsing signal
Lennart Poettering [Thu, 31 Oct 2024 14:39:34 +0000 (15:39 +0100)]
sd-json: don't accidentally convert between unsigned/signed when parsing signal

13 months agoposix_spawn_wrapper: do not set POSIX_SPAWN_SETSIGDEF flag
Mike Gilbert [Thu, 24 Oct 2024 16:24:35 +0000 (12:24 -0400)]
posix_spawn_wrapper: do not set POSIX_SPAWN_SETSIGDEF flag

Setting this flag is a noop without a corresponding call to
posix_spawnattr_setsigdefault.

If we call posix_spawnattr_setsigdefault with a full signal set,
it causes glibc's posix_spawn implementation to call sigaction 63 times,
once for each signal. That seems wasteful.

This feature is really only useful for signals which have their
disposition set to SIG_IGN. Otherwise the dispostion gets set to
SIG_DFL automatically, either by clone(CLONE_CLEAR_SIGHAND) or the
subsequent execve.

As far as I can tell, systemd does not have any signals set to SIG_IGN
under normal operating conditions.

13 months agobus-common-errors: use more appropriate errno for BUS_ERROR_DESIGNATED_MAINTENANCE_TI...
Mike Yuan [Thu, 31 Oct 2024 14:46:27 +0000 (15:46 +0100)]
bus-common-errors: use more appropriate errno for BUS_ERROR_DESIGNATED_MAINTENANCE_TIME_NOT_SCHEDULED

Fixes #33429

13 months agosystemctl: don't fall back to immediate shutdown silently if we cannot schedule one
Mike Yuan [Thu, 31 Oct 2024 14:45:15 +0000 (15:45 +0100)]
systemctl: don't fall back to immediate shutdown silently if we cannot schedule one

The previous behavior of systemctl --when= seems absurd, i.e.
if we fail to schedule shutdown in the future it's performed
immediately. Let's instead hard fail, which also removes the need
of specializing on certain errnos (preparation for later commits).

13 months agologind-dbus: return appropriate errno for unexpected errors
Mike Yuan [Thu, 31 Oct 2024 14:33:07 +0000 (15:33 +0100)]
logind-dbus: return appropriate errno for unexpected errors

Follow-up for 0e10c3d8724b0a5d07871c9de71565ac91dd55b7

13 months agosystemctl: use the retval of must_be_root()
Mike Yuan [Sat, 17 Aug 2024 18:33:12 +0000 (20:33 +0200)]
systemctl: use the retval of must_be_root()

13 months agoboot: stop appending NUL to .sdmagic and .sbat sections
Zbigniew Jędrzejewski-Szmek [Wed, 30 Oct 2024 14:30:53 +0000 (15:30 +0100)]
boot: stop appending NUL to .sdmagic and .sbat sections

Those text sections had a trailing NUL byte. It's debatable whether this is a
good idea or not. Correctly written consumers will look at the section size so
they wouldn't need this. Shim doesn't use a trailing NUL, so let's follow suit.

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

898e9edc469f87fdb6018128bac29eef0a5fe698 reworked this code, but didn't actually
change the logic. We have always been appending the trailing zero by using a
NUL-terminated string as the section contents. (I checked this with v253.18
from before the elf2efi rework.)

.sdmagic contains a string like "#### LoaderInfo: systemd-boot 257~devel ####",
which changes with each version, so previous versions would compare unequal
anyway, so we don't need to worry about backwards compatibility.

13 months agomkosi: Install gdb in centos/fedora build image
Daan De Meyer [Thu, 31 Oct 2024 11:44:13 +0000 (12:44 +0100)]
mkosi: Install gdb in centos/fedora build image

Lack of gdb-add-index has become a fatal error in Rawhide/c10s so
let's install gdb to make rpmbuild happy.

13 months agostring-util: also check for 0x1b 0x5c ST when stripping ANSI from strings
Lennart Poettering [Thu, 31 Oct 2024 10:22:39 +0000 (11:22 +0100)]
string-util: also check for 0x1b 0x5c ST when stripping ANSI from strings

13 months agoterminal-util: define ANSI_OSC as macro for the OSC terminal sequence prefix
Lennart Poettering [Thu, 31 Oct 2024 09:37:02 +0000 (10:37 +0100)]
terminal-util: define ANSI_OSC as macro for the OSC terminal sequence prefix

13 months agoptyfwd: document why we only honour two of the three kinds of ST
Lennart Poettering [Thu, 31 Oct 2024 09:10:37 +0000 (10:10 +0100)]
ptyfwd: document why we only honour two of the three kinds of ST

13 months agotree-wide: prefer generating 0x1B 0x5C as ANSI sequence "ST"
Lennart Poettering [Thu, 31 Oct 2024 09:05:13 +0000 (10:05 +0100)]
tree-wide: prefer generating 0x1B 0x5C as ANSI sequence "ST"

OSC sequences can be closed with one of three terminators:

1. ASCII code 7, aka BEL, aka ^G, aka \x07, aka \a
2. ASCII code 156, aka \x9c
2. Pair of ASCII code 27 followed by ASCII code 92, aka \x1b\x5c

Of these, in some corner case scenarios BEL makes problem (see #34604).
Hence switch away from that wherever we use it, and prefer the \x1b\x5c
instead. That's preferable over \x9c, since the latter is also a valid
UTF-8 codepoint. See discussion here for example:

https://gist.github.com/egmontkob/eb114294efbcd5adb1944c9f3cb5feda#the-escape-sequence

Fixes: #34604

13 months agostring-util: it's called OSC sequence, not CSO sequence
Lennart Poettering [Thu, 31 Oct 2024 08:51:32 +0000 (09:51 +0100)]
string-util: it's called OSC sequence, not CSO sequence

13 months agoresolve: do not try to send varlink error more than once
Yu Watanabe [Thu, 31 Oct 2024 02:59:10 +0000 (11:59 +0900)]
resolve: do not try to send varlink error more than once

After d2ebf5cc1d59e29139f06efaa3a9b2c184cdaa25, sd_varlink_error() and
friends return negative errno.

Fixes https://github.com/systemd/systemd/pull/34946#discussion_r1823703636.

13 months agotest-network: add test case for tunnel Local=dhcp4
Yu Watanabe [Mon, 28 Oct 2024 17:18:05 +0000 (02:18 +0900)]
test-network: add test case for tunnel Local=dhcp4

For issue #24854.

13 months agonetwork: update tunnel or vxlan interface if the local address is changed
Yu Watanabe [Mon, 28 Oct 2024 16:23:54 +0000 (01:23 +0900)]
network: update tunnel or vxlan interface if the local address is changed

If a tunnel or vxlan is configured with Local=dhcp4 or so, then the
local address needs to be changed when it is changed.

Fixes #24854.

13 months agomachine: lookup_machine_by_name_or_pidref() returns negative errno on failure
Yu Watanabe [Thu, 31 Oct 2024 01:24:06 +0000 (10:24 +0900)]
machine: lookup_machine_by_name_or_pidref() returns negative errno on failure

This effectively reverts d2c1451b7398f13439b694450a23def3cf31c8db.

After the commit d2ebf5cc1d59e29139f06efaa3a9b2c184cdaa25, sd_varlink_error()
returns negative errno, hence the function always return negative errno
on failure.

13 months agomachine: use JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY()
Yu Watanabe [Fri, 25 Oct 2024 17:17:29 +0000 (02:17 +0900)]
machine: use JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY()

Also use JSON_BUILD_PAIR_UNSIGNED_NOT_EQUAL().

13 months agosd-json: introduce JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY() macro
Yu Watanabe [Fri, 25 Oct 2024 17:09:01 +0000 (02:09 +0900)]
sd-json: introduce JSON_BUILD_PAIR_STRV_ENV_PAIR_NON_EMPTY() macro

It is similar to JSON_BUILD_PAIR_STRV_NON_EMPTY, but takes the
list of environment variables.

13 months agosd-json: use strv_env_get_merged()
Yu Watanabe [Fri, 25 Oct 2024 17:07:02 +0000 (02:07 +0900)]
sd-json: use strv_env_get_merged()

13 months agoenv-util: introduce strv_env_get_merged()
Yu Watanabe [Fri, 25 Oct 2024 17:01:19 +0000 (02:01 +0900)]
env-util: introduce strv_env_get_merged()