Commit graph

64248 commits

Author SHA1 Message Date
Daan De Meyer 4d56d084d8 meson: Search for diff program
diff is required by a few of the unit tests so let's make sure its
available when configuring the build.
2023-05-01 14:58:08 +02:00
Yu Watanabe 8c59feed5e missing_fs: also define struct file_clone_range
Follow-up for b640e274a7.

Addresses b640e274a7 (r110996661).
2023-04-29 07:03:09 +02:00
Lennart Poettering c23e9b6a64 pid1: unify implemenation of /run/ disk space safety check a bit
reload/reexec currently used a separate implementation of the /run/ disk
space check, different from the one used for switch-root, even though
the code is mostly the same. The one difference is that the former
checks are authoritative, the latter are just informational (that's
because refusing a reload/reexec is relatively benign, but refusing a
switch-root quite troublesome, since this code is entered when it's
already "too late" to turn turn back, i.e. when the preparatory
transaction to initiate the switch root are already fully executed.

Let's share some code, and unify codepaths.

(This is preparation for later addition of a "userspace reboot" concept)

No change in behaviour, just refactoring.
2023-04-28 23:27:20 +01:00
Lennart Poettering 5ae89ef347 core/systemctl: when switching root default to /sysroot/
We hardcode the path the initrd uses to prepare the final mount point at
so many places, let's also imply it in "systemctl switch-root" if not
specified.

This adds the fallback both to systemctl and to PID 1 (this is because
both to — different – checks on the path).
2023-04-28 23:26:20 +01:00
Daan De Meyer 77b7026668 libsystemd: Add missing memory pressure functions to public symbols 2023-04-28 21:19:38 +02:00
Mike Yuan 0102857b52
Merge pull request #27445 from poettering/reflink-fix
remove duplication reflink ioctl invocation
2023-04-29 01:33:21 +08:00
Lennart Poettering 4b7fda8731 systemctl: rework 'if' to 'switch' statement 2023-04-29 01:23:24 +08:00
Luca Boccassi 398d858d1c
Merge pull request #27437 from mrc0mmand/pstore
test: add a couple of tests for systemd-pstore
2023-04-28 16:14:09 +01:00
Lennart Poettering 535358ad2e copy: shortcut reflink_range() to reflink() in some cases 2023-04-28 15:16:30 +02:00
Lennart Poettering 427ad121c2 copy: don't call clone ioctls twice
The btrfs name and the generic name have the same values, hence there's
no point in bothering with the former.
2023-04-28 15:10:24 +02:00
Frantisek Sumsal 6858e32d73 test: add a couple of tests for systemd-pstore 2023-04-28 13:16:45 +02:00
Luca Boccassi 91010bd6cc
Merge pull request #27440 from yuwata/reflink-follow-ups
copy: follow ups for reflink()
2023-04-28 11:34:41 +01:00
Frantisek Sumsal ad5980803a pstore: avoid opening the dmesg.txt file if not requested
Even with Storage=journal we would still attempt to open the final
dmesg.txt file which causes a lot of noise in the journal:

```
[    5.764111] H testsuite-82.sh[658]: + systemctl start systemd-pstore
[    5.806385] H systemd[1]: Starting modprobe@efi_pstore.service...
[    5.808656] H systemd[1]: modprobe@efi_pstore.service: Deactivated successfully.
[    5.808971] H systemd[1]: Finished modprobe@efi_pstore.service.
[    5.818845] H kernel: audit: type=1130 audit(1682630623.637:114): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=modprobe@efi_pstore comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? termin>
[    5.818865] H kernel: audit: type=1131 audit(1682630623.637:115): pid=1 uid=0 auid=4294967295 ses=4294967295 subj=kernel msg='unit=modprobe@efi_pstore comm="systemd" exe="/usr/lib/systemd/systemd" hostname=? addr=? termin>
[    5.816052] H systemd[1]: Starting systemd-pstore.service...
[    5.840703] H systemd-pstore[806]: PStore dmesg-efi-168263062313014.
[    5.841239] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.841428] H systemd-pstore[806]: PStore dmesg-efi-168263062312014.
[    5.841575] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.841712] H systemd-pstore[806]: PStore dmesg-efi-168263062311014.
[    5.841839] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.841989] H systemd-pstore[806]: PStore dmesg-efi-168263062310014.
[    5.842141] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.842274] H systemd-pstore[806]: PStore dmesg-efi-168263062309014.
[    5.842423] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.842589] H systemd-pstore[806]: PStore dmesg-efi-168263062308014.
[    5.842722] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.842865] H systemd-pstore[806]: PStore dmesg-efi-168263062307014.
[    5.843003] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.843153] H systemd-pstore[806]: PStore dmesg-efi-168263062306014.
[    5.843280] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.843434] H systemd-pstore[806]: PStore dmesg-efi-168263062305014.
[    5.843570] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.843702] H systemd-pstore[806]: PStore dmesg-efi-168263062304014.
[    5.843831] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.843958] H systemd-pstore[806]: PStore dmesg-efi-168263062303014.
[    5.844093] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.844250] H systemd-pstore[806]: PStore dmesg-efi-168263062302014.
[    5.844412] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.844619] H systemd-pstore[806]: PStore dmesg-efi-168263062301014.
[    5.844781] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.844956] H systemd-pstore[806]: PStore dmesg-efi-168263062300014.
[    5.845168] H systemd-pstore[806]: Failed to open file /var/lib/systemd/pstore/1682630623/014/dmesg.txt: Operation not permitted
[    5.851101] H systemd[1]: Finished systemd-pstore.service.
```
2023-04-28 12:00:42 +02:00
Yu Watanabe 657152a459 network-generator: shorten code a bit 2023-04-28 18:50:47 +09:00
Yu Watanabe 75fd8ad008
Merge pull request #27424 from dtardon/auto-cleanup
More automatic cleanup
2023-04-28 18:46:36 +09:00
Frantisek Sumsal a95d96a243 pstore: explicitly set the base when converting record ID 2023-04-28 11:41:52 +02:00
David Tardon 360179ea46 logind-session-dbus: use _cleanup_ 2023-04-28 09:29:04 +02:00
David Tardon 80e52052db logind-session-device: modernize session_device_free() 2023-04-28 09:29:03 +02:00
David Tardon fc447921a8 homed-manager-bus: use _cleanup_ 2023-04-28 09:29:03 +02:00
David Tardon 7fb1cc85ab transaction: make transaction_free() static
... as it's not needed outside transaction.c anymore.
2023-04-28 09:28:25 +02:00
David Tardon 32620826cf manager: use _cleanup_ in manager_propagate_reload() 2023-04-28 09:27:37 +02:00
David Tardon c7e3eb5dd5 manager: use _cleanup_ in manager_add_job() 2023-04-28 09:27:37 +02:00
David Tardon 542fe40845 transaction: introduce transaction_abort_and_free()
Will be used in following commits.
2023-04-28 09:26:20 +02:00
Yu Watanabe d6f96778b1 missing_fs: mention commit hash and version of ioctl commands introduced 2023-04-28 14:18:48 +09:00
Yu Watanabe 71e84b4be6 copy: rename reflink_full() -> reflink_range()
The commit b640e274a7 introduced reflink()
and reflink_full(). We usually name function xyz_full() for fully
parameterized version of xyz(), and xyz() is typically a inline alias of
xyz_full(). But in this case, reflink() and reflink_full() call
different ioctl().
Moreover, reflink_full() does partial reflink, while reflink() does full
file reflink. That's super confusing.
Let's rename reflink_full() to reflink_range(), the new name is
consistent with ioctl name, and should be fine.
2023-04-28 14:06:00 +09:00
David Edmundson c63dde8099 xdg-autostart-service: handle gnome autostart phase better on other desktops
Autostart files which contain the line gnome-autostart-phase are currently
completely skipped by systemd. This is because these are handled internally by
gnome startup through other means.

The problem is a number of desktop files that need to run on KDE too have this
flag set. Ideally they should just create systemd user units, but we're not at
this point universally yet.

This patch changes the logic so if the flag is set, we set NotShowIn-gnome,
which in turn would just not load decided at runtime.

As an optimisation if we would get conflicting OnlyShowIn lines we still
skip the file completely.

Example:
  $ rg 'Exec|Autostart-Phase' /etc/xdg/autostart/gnome-keyring-pkcs11.desktop
  Exec=/usr/bin/gnome-keyring-daemon --start --components=pkcs11
  X-GNOME-Autostart-Phase=PreDisplayServer

  $ cat '/tmp/xxx/app-gnome\x2dkeyring\x2dpkcs11@autostart.service'
  # Automatically generated by systemd-xdg-autostart-generator
  [Unit]
  SourcePath=/etc/xdg/autostart/gnome-keyring-pkcs11.desktop
  ...
  [Service]
  ...
  ExecCondition=/usr/lib/systemd/systemd-xdg-autostart-condition "Unity:MATE" "GNOME"

Co-authored-by: Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
2023-04-28 12:32:53 +08:00
Daan De Meyer b640e274a7 copy: Introduce reflink() and reflink_full()
The kernel has had filesystem independent reflink ioctls for a
while now, let's try to use them and fall back to the btrfs specific
ones if they're not supported.
2023-04-28 00:57:03 +01:00
David Tardon 12da8805e7 transaction: modernize transaction_free() 2023-04-27 21:42:38 +02:00
David Tardon 0a956e8e02 initctl: use _cleanup_ 2023-04-27 21:42:38 +02:00
David Tardon 70bbf65942 initctl: add assert 2023-04-27 21:42:38 +02:00
David Tardon 1cc3a1302f specifier: use _cleanup_ 2023-04-27 21:42:38 +02:00
David Tardon 3cbbefc2a7 path-util: use _cleanup_ 2023-04-27 21:42:38 +02:00
David Tardon 5ce8ce908d logind: rename function to avoid confusion 2023-04-27 21:42:38 +02:00
David Tardon 3d01bfa7db logind-core: drop unneeded check for NULL 2023-04-27 21:42:38 +02:00
David Tardon 737e0f12d9 logind-core: modernize button_free() 2023-04-27 21:42:38 +02:00
David Tardon 93eceb59e6 env-util: use more _cleanup_ in replace_env_argv() 2023-04-27 21:42:38 +02:00
David Tardon cc09d8a5a1 env-util: use _cleanup_ in replace_env_argv() 2023-04-27 21:42:38 +02:00
David Tardon 5013d6def3 env-util: rename variable 2023-04-27 21:42:38 +02:00
David Tardon 480a7919bc env-util: use _cleanup_ in strv_env_delete() 2023-04-27 21:42:38 +02:00
Luca Boccassi fafded0ce0
Merge pull request #27346 from poettering/pam-fixes
pam-systemd: be more careful with sharing bus connections
2023-04-27 20:31:57 +01:00
Lennart Poettering dbecd3d6ee shutdown: paranoia – close all fds we might get passed in
We don't expect any fds (beyond 0…2) to be passed from the service
manager into systemd-shutdown, but let's better be safe then sorry.
2023-04-27 17:56:24 +01:00
Lennart Poettering ba8d00e859 pam-systemd: disconnect bus connection when leaving session hook, even on error
This adds support for systematically destroying connections in
pam_sm_session_open() even on failure, so that under no circumstances
unserved dbus connection are around while the invoking process waits for
the session to end.  Previously we'd only do this on success, now do it
in all cases.

This matters since so far we suggested people hook pam_systemd into
their pam stacks prefixed with "-", so that login proceeds even if
pam_systemd fails. This however means that in an error case our
cached connection doesn't get disconnected even if the session then is
invoked. This fixes that.
2023-04-27 17:04:05 +02:00
Lennart Poettering 402014086d pam-util: include PID in PAM data field id
Let's systematically avoid sharing cached busses between processes (i.e.
from parent and child after fork()), by including the PID in the field
name.

With that we're never tempted to use a bus object the parent created in
the child.

(Note this is about *use*, not about *destruction*. Destruction needs to
be checked by other means.)
2023-04-27 17:02:49 +02:00
Franck Bui fd34e27fb9 test: dont use anchor char '$' to match a part of a string
When anchoring the pattern using '$' regular expression operator it forces '=~'
operator to match the entire string.
2023-04-27 22:42:51 +08:00
Mike Yuan 82060b62c9
Merge pull request #25622 from YHNdnzj/tmpfiles-X-bit-support
tmpfiles: add conditionalized execute permission (X) support
2023-04-27 22:40:09 +08:00
Lennart Poettering a84e741b36
Merge pull request #27376 from poettering/subcgroup
pid1: add DelegateSubgroup= option
2023-04-27 16:37:06 +02:00
Lennart Poettering 969f5f3cea test: extend test 19 to also verify DelegateSubgroup= works 2023-04-27 14:15:50 +02:00
Lennart Poettering 1a3704dcc3 nspawn: port over to /supervisor/ subcgroup being delegated to nspawn
Let's make use of the new DelegateSubgroup= feature and delegate the
/supervisor/ subcgroup already to nspawn, so that moving the supervisor
process there is unnecessary.
2023-04-27 12:18:32 +02:00
Lennart Poettering f8371dbd56 udev: port to DelegateSubgroup= 2023-04-27 12:18:32 +02:00
Lennart Poettering 3975e3f8ae units: make system service manager create init.scope subcgroup for user service manager
This one is basically for free, since the service manager is already
prepared for being invoked in init.scope. Hence let's start it in the
right cgroup right-away.
2023-04-27 12:18:32 +02:00