Commit Graph

77399 Commits

Author SHA1 Message Date
Daan De Meyer
29a8e71d9c 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.
2024-11-02 20:43:19 +01:00
Ronan Pigott
f4092cb974 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.
2024-11-02 22:47:17 +09:00
Luca Boccassi
5cae569818 user-record: add missing comma to list of strings
Follow-up for ad03f2d5f0
2024-11-02 22:46:45 +09:00
Yu Watanabe
500c61ee49 network/ipv4ll: not necessary to set initial address on each start 2024-11-02 22:42:01 +09:00
Yu Watanabe
fecd205d3e network/dhcp4: do not restart IPv4LL client when KeepConfiguration=dhcp
When KeepConfiguration=dhcp, we do not remove acquired address, hence
not necessary to restart IPv4LL client.
2024-11-02 22:42:01 +09:00
Luca Boccassi
89099136d7
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.
2024-11-02 12:06:23 +00:00
Luca Boccassi
c7e818fc1a
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)
```
2024-11-02 12:04:49 +00:00
Luca Boccassi
c166969137
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 804874d26a
2024-11-02 11:27:28 +00:00
Andres Beltran
eae5127246 core: add id-mapped mount support for Exec directories 2024-11-01 18:45:28 +00:00
Andres Beltran
edae62120f namespace-util: add util function to check if id-mapped mounts are supported for a given path 2024-11-01 18:41:27 +00:00
Lennart Poettering
acc35e5129
core/service: don't propagate stop jobs if RestartMode=direct (#34768)
Fixes https://github.com/systemd/systemd/issues/34758
2024-11-01 17:25:49 +01:00
Luca Boccassi
ffd81a1202 resolve: remove always-true superflous check and rename label
Fixes https://github.com/systemd/systemd/security/code-scanning/2900
2024-11-01 15:44:01 +00:00
Luca Boccassi
93445c2e89 logind: ensure the stronger inhibitor currently in place is taken into account 2024-11-01 15:43:14 +00:00
Luca Boccassi
845f95b9e0 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 804874d26a
2024-11-01 15:43:14 +00:00
Ivan Kruglov
b50fe8a0d9 machine: remove redundant --more in TEST-13-NSPAWN.machined 2024-11-01 15:30:39 +01:00
Ivan Kruglov
0c16936acc machine: tests for io.systemd.MachineImage.{Clone, Remove} methods 2024-11-01 15:30:39 +01:00
Ivan Kruglov
88d0b72833 machine: use ImageUpdateParameters in io.systemd.MachineImage.Update 2024-11-01 15:30:39 +01:00
Ivan Kruglov
cc060c2910 machine: reuse VARLINK_DEFINE_IMAGE_LOOKUP_AND_POLKIT_FIELDS in io.systemd.MachineImage.Update declaration 2024-11-01 15:30:39 +01:00
Ivan Kruglov
1663455b63 machine: introduce io.systemd.MachineImage.Remove method 2024-11-01 15:30:39 +01:00
Ivan Kruglov
38a0cf4172 machine: introduce io.systemd.MachineImage.Clone method 2024-11-01 15:30:34 +01:00
Ivan Kruglov
95d5b9097b machine: use report_errno_and_exit() in dbus code 2024-11-01 15:21:22 +01:00
Ivan Kruglov
30a34657b8 machine: introduce report_errno_and_exit() 2024-11-01 15:21:22 +01:00
Ivan Kruglov
a52ce4a29d machine: align polkit verb of io.systemd.MachineImage.Update with the rest of the code 2024-11-01 15:20:59 +01:00
Luca Boccassi
74a17f875f
hwdb: update for v257 (#34976) 2024-11-01 12:32:56 +00:00
Lennart Poettering
d248e1a8d6 update hwdb 2024-11-01 12:32:06 +00:00
Lennart Poettering
2e4432507b hwdb: import newest autosuspend rules from chromeos 2024-11-01 12:32:06 +00:00
Daan De Meyer
70af6703b0 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.
2024-11-01 13:30:45 +01:00
Luca Boccassi
c77f4f5df7
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.
2024-11-01 12:25:35 +00:00
dependabot[bot]
593b125a30 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>
2024-11-01 11:45:37 +00:00
Luca Boccassi
e7bbcbb27c Update NEWS 2024-11-01 11:39:26 +00:00
Luca Boccassi
fdccba15be
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.
2024-11-01 11:29:19 +00:00
Luca Boccassi
d86e9b64e4
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.
2024-11-01 11:18:57 +00:00
Luca Boccassi
1006022e4c
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
2024-11-01 11:14:04 +00:00
Luca Boccassi
57b908caef
network: update tunnel or vxlan with Local=dhcp4 and friends (#34957)
Fixes #24854.
2024-11-01 11:10:21 +00:00
Luca Boccassi
890bdd1d77 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.
2024-11-01 10:46:55 +00:00
Adrian Vovk
6a2d4a233d test: Test user record selfModifiable behavior 2024-11-01 10:41:46 +00:00
Adrian Vovk
a192250eda 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.
2024-11-01 10:41:46 +00:00
Adrian Vovk
ad03f2d5f0 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.
2024-11-01 10:41:46 +00:00
dependabot[bot]
7fdcd903ab 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](d632683dd7...11bd71901b)

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

Signed-off-by: dependabot[bot] <support@github.com>
2024-11-01 11:25:37 +01:00
Lennart Poettering
cbddc201e5 man: <strong> is not a valid docbook tag, but <emphasis> is 2024-11-01 10:12:44 +01:00
Lennart Poettering
f0a1d44939 update NEWS 2024-11-01 10:12:41 +01:00
Lennart Poettering
00f7398049 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"
2024-11-01 10:07:55 +01:00
Lennart Poettering
4c9c8b8d09 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.
2024-11-01 10:05:53 +01:00
Lennart Poettering
e64ccd2242
coredump: rework protocol between coredump pattern handler and processing service (#34970)
In
68511cebe5
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
68511cebe5
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
2024-11-01 08:15:05 +01:00
Lennart Poettering
098c3975ac 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.
2024-10-31 23:09:14 +01:00
Lennart Poettering
b1694040af coredump: use memory_startswith() when looking at a data blob 2024-10-31 23:08:11 +01:00
Lennart Poettering
0e3e075b56 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.
2024-10-31 23:08:11 +01:00
Lennart Poettering
811aa36ab6 iovw: add simpler iovw_done() destructor 2024-10-31 23:08:11 +01:00
Lennart Poettering
2865561eaa coredump: move to _cleanup_ for destroying iovw object 2024-10-31 23:08:11 +01:00
Lennart Poettering
19455dd600 coredump: parse rlimit field at same place as other fields 2024-10-31 23:08:11 +01:00