1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00
Commit Graph

1167 Commits

Author SHA1 Message Date
Lennart Poettering
9551aa707d tpm2: move measurement log to /run/log/ (from /var/log/)
I have no idea what went on in my mind when I used a path in /var/ for
the tpm2 event log we now keep for userspace measurements. The
measurements are only valid for the current boot, hence should not be
persisted (in particular as they cannot be rotated, hence should not
grow without bounds).

Fix that, simply move from /var/log/ to /run/log/.
2023-09-29 14:35:56 +02:00
Daan De Meyer
4444564a95
Merge pull request #29193 from keszybz/path-util-adjustment
Make unit mangling follow paths
2023-09-29 11:33:12 +02:00
Maanya Goenka
f660c7fa56 fix: do not check/verify slice units if recursive errors are to be ignored
Before this fix, when recursive-errors was set to 'no' during a systemd-analyze
verification, the parent slice was checked regardless. The 'no' setting means that,
only the specified unit should be looked at and verified and errors in the slices should be
ignored. This commit fixes that issue.

Example:

Say we have a sample.service file:

[Unit]
Description=Sample Service

[Service]
ExecStart=/bin/echo "a"
Slice=support.slice

Before Change:

systemd-analyze verify --recursive-errors=no maanya/sample.service
Assertion 'u' failed at src/core/unit.c:153, function unit_has_name(). Aborting.
Aborted (core dumped)

After Change:
systemd-analyze verify --recursive-errors=no maanya/sample.service
{No errors}
2023-09-28 23:32:02 +01:00
Luca Boccassi
1e49f4ed8b
Merge pull request #28545 from bluca/softreboot_survive
pid1: add SurviveFinalKillSignal= to skip units on final sigterm/sigkill spree
2023-09-28 17:12:03 +01:00
Luca Boccassi
3cb5d34ce0
Merge pull request #29295 from valentindavid/valentindavid/sysupdate-patterns-in-directory
sysupdate: Allow patterns to match path with directories
2023-09-28 15:18:45 +01:00
Frantisek Sumsal
d37b9154a7 test: check soft-reboot behavior wrt argv[0][0] == '@' 2023-09-28 13:48:14 +01:00
Luca Boccassi
559214cbbd pid1: add SurviveFinalKillSignal= to skip units on final sigterm/sigkill spree
Add a new boolean for units, SurviveFinalKillSignal=yes/no. Units that
set it will not have their process receive the final sigterm/sigkill in
the shutdown phase.

This is implemented by checking if a process is part of a cgroup marked
with a user.survive_final_kill_signal xattr (or a trusted xattr if we
can't set a user one, which were added only in kernel v5.7 and are not
supported in CentOS 8).
2023-09-28 13:48:14 +01:00
Zbigniew Jędrzejewski-Szmek
5342eb4633 Rework unit_name_mangle_with_suffix() to (very slightly) simplify the path
'systemctl status /../dev' now looks for 'dev.mount', not '-..-dev.service',
and 'systemctl status /../foo' looks for 'foo.mount', not '-..-foo.service'. I
think this much more useful. I think the escaping is not very useful, so I plan
to submit a later series which changes that behaviour. But I think this first
step here is already useful on its own.

Note that the patch is smaller than it seems: before, is_device_path() would
return true only for absolute paths, so moving of is_device_path() under the
path_is_absolute() conditional doesn't influence the logic.
2023-09-28 13:09:25 +02:00
Bertrand Jacquin
bdf58b47c3 resolved: never respond to .alt pseudo-TLD.
From RFC 9476:

Because names beneath .alt are in an alternative namespace, they have no
significance in the regular DNS context. DNS stub and recursive
resolvers do not need to look them up in the DNS context.

See: https://datatracker.ietf.org/doc/html/rfc9476#name-the-alt-namespace
2023-09-28 12:07:47 +02:00
Valentin David
8b051623cd
sysupdate: Allow patterns to match path with directories
`MatchPattern` for regular-file and directory as target can now match
subdirectories This is useful to install files for examples in `.extra.d`
directories:

```
[Target]
Type=regular-file
Path=/EFI/Linux
PathRelativeTo=boot
MatchPattern=gnomeos_@v.efi.extra.d/apparmor.addon.efi
```

The if the directories in the path do not exist, they will be created.  Whereas
the part in `Path` is not created.
2023-09-28 11:41:29 +02:00
Topi Miettinen
435d523956 test: testing for core NFTSet= feature 2023-09-27 18:10:11 +00:00
Zbigniew Jędrzejewski-Szmek
e071384dc5 Merge pull request #29296 from yuwata/sd-journal-several-cleanups-for-boot-id 2023-09-27 14:56:48 +02:00
Frantisek Sumsal
c1b129f4ad test: introduce TEST-09-REBOOT
To test stuff involving state preserved across (multiple) reboots, like
journal boot IDs.
2023-09-27 14:50:19 +02:00
Luca Boccassi
578840bdf9
Merge pull request #29296 from keszybz/make-cryptsetup-offical-and-add-docs
Make cryptsetup offical and add docs
2023-09-27 13:31:11 +01:00
Zbigniew Jędrzejewski-Szmek
ab68c6fb08 TEST-70: use new cryptsetup path 2023-09-26 17:03:26 +02:00
Lennart Poettering
32295fa08f pcrphase: rename binary to pcrextend
The tool initially just measured the boot phase, but was subsequently
extended to measure file system and machine IDs, too. At AllSystemsGo
there were request to add more, and make the tool generically
accessible.

Hence, let's rename the binary (but not the pcrphase services), to make
clear the tool is not just measureing the boot phase, but a lot of other
things too.

The tool is located in /usr/lib/ and still relatively new, hence let's
just rename the binary and be done with it, while keeping the unit names
stable.

While we are at it, also move the tool out of src/boot/ and into its own
src/pcrextend/ dir, since it's not really doing boot related stuff
anymore.
2023-09-25 17:17:20 +02:00
Mike Yuan
2b344ea808
test: introduce TEST-83-BTRFS
The Ubuntu CIs are deny-listed because the shipped
btrfs-progs is too old, i.e. doesn't support the
recently-added 'filesystem mkswapfile' command.
2023-09-19 21:45:27 +08:00
Lennart Poettering
065e478a4a ci: add test for poll limit 2023-09-18 18:56:59 +02:00
Luca Boccassi
e4aab5cf1a logind: add PrepareForShutdownWithMetadata signal
The existing signal doesn't say which type of shutdown is going to happen.
With the introduction of soft-reboot, it is useful to have this information
broadcasted, so that clients can choose to do different things based on the
reboot type.
Add a{sv} as the payload so that more metadata can be added later if
needed, without needing to add yet another signal.
Send both old and new signal for backward compatibility, and send the new
one first so that clients can just wait for the first one on both old and
new systems.
2023-09-11 12:56:00 +01:00
Zbigniew Jędrzejewski-Szmek
1c5d54b2df test: use 'until' instead of 'while !'
In general, it's better to avoid a negation. And "!" is special, because it is
used for history expansion, i.e. the same command would behave differently if
pasted on the command line.

Inspired by 4a899c5a23.
2023-09-06 19:54:29 +01:00
Frantisek Sumsal
89562f08c9 test: create the "global" dropins in /run
So the test doesn't fail if run multiple times in a succession.
2023-09-05 15:55:52 +02:00
Frantisek Sumsal
04bf0452a5 test: set ncat's idle timeout as well
Otherwise we'll get stuck waiting indefinitely if the test socket unit
fails to fail due the trigger limit, i.e.:

[  111.104906] testsuite-07.sh[743]: + systemctl start issue2467.socket
[  OK  ] Listening on issue2467.socket.
[  111.746465] testsuite-07.sh[743]: + nc -w20 -U /run/test.ctl
         Starting systemd-tmpfiles-clean.service...
[  OK  ] Finished systemd-tmpfiles-clean.service.
qemu-system-x86_64: terminating on signal 15 from pid 565814 (timeout)
E: Test timed out after 1800s

With the idle timeout we should give up after 20 seconds, allowing the next
statement to properly fail:

[   34.233084] testsuite-07.sh[450]: + systemctl start issue2467.socket
[   35.475392] testsuite-07.sh[450]: + nc -i20 -w20 -U /run/test.ctl
[   56.122941] testsuite-07.sh[458]: Ncat: Idle timeout expired (20000 ms).
[   56.140871] testsuite-07.sh[450]: + :
[   56.145460] testsuite-07.sh[450]: + timeout 10 bash -c 'while ! [[ "$(systemctl show issue2467.socket -P ActiveState)" == failed ]]; do sleep .5; done'
[   66.197623] testsuite-07.sh[446]: + echo 'Subtest /usr/lib/systemd/tests/testdata/units/testsuite-07.issue-2467.sh failed'
2023-09-05 13:30:12 +02:00
Luca Boccassi
626a9eba09
Merge pull request #28988 from keszybz/sd128-arbitrary-values
Add sd-id128 and systemd-id128 functionality to do "app specific" with any "base"
2023-09-03 14:05:32 +01:00
Zbigniew Jędrzejewski-Szmek
b37e8184a5 id128: allow combining --app with show
This effectively exposes sd_id128_get_app_specific() on the commandline.

Fixes https://github.com/systemd/systemd/issues/27514.
2023-09-02 14:17:29 +03:00
Lennart Poettering
a4e941ee1f test: add test for new measurement log 2023-08-30 13:08:17 +02:00
Zbigniew Jędrzejewski-Szmek
782902f217 id128: add option -P to only show value
We have '-P' in systemctl with similar meaning.

Partially closes https://github.com/systemd/systemd/issues/27514.
2023-08-29 17:06:47 +03:00
Mike Yuan
08a5bc4f48 Revert "Revert "test: add test case for systemd-update-utmp vs daemon-reexec""
This reverts commit 837773add4.

The original issue #27287 is fixed by #28123. Let's
reintroduce the test for systemd-update-utmp.
2023-08-28 17:43:57 +01:00
Yu Watanabe
927e20fa49 nspawn: check validity of the internal interface name only explicitly specified
Follow-up for 2f091b1b49.

Fixes #28844.
2023-08-24 15:55:32 +02:00
Frantisek Sumsal
9541addff0 test: use the correct file name when restoring the original fstab 2023-08-24 07:54:13 +00:00
Daan De Meyer
1ffa5cfb38 repart: Add partno to output 2023-08-23 15:12:23 +02:00
Luca Boccassi
2322c6c735 sd-mount: allow creating tmpfs
Mount units can do it, but the command line tool cannot, as it needs a
valid 'what'. If --tmpfs/-T if passed, parse the argument as 'where'
and send a literal 'tmpfs' as the 'what' if not specified.
2023-08-21 11:45:15 +02:00
Mathieu Tortuyaux
41712cd1c0 sysext: support EXTENSION_RELOAD_MANAGER metadata
This metadata (EXTENSION_RELOAD_MANAGER) can be set to "1" to reload the manager
when merging/refreshing/unmerging a system extension image. This can be useful in case the sysext
image provides systemd units that need to be loaded.

With `--no-reload`, one can deactivate the EXTENSION_RELOAD_MANAGER metadata interpretation.

Signed-off-by: Mathieu Tortuyaux <mtortuyaux@microsoft.com>
2023-08-21 11:13:54 +02:00
Luca Boccassi
663e27564f core: stage /run/host/os-release with a symlink to avoid possible race condition
If someone reads /run/host/os-release at the exact same time it is being updated, and it
is large enough, they might read a half-written file. This is very unlikely as
os-release is typically small and very rarely changes, but it is not
impossible.

Bind mount a staging directory instead of the file, and symlink the file
into into, so that we can do atomic file updates and close this gap.
Atomic replacement creates a new inode, so existing bind mounts would
continue to see the old file, and only new services would see the new file.
The indirection via the directory allows to work around this, as the
directory is fixed and never changes so the bind mount is always valid,
and its content is shared with all existing services.

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

Follow-up for 3f37a82545
2023-08-16 16:17:41 +01:00
Maanya Goenka
b856f1dfc5 test: add test for confext service-scoped support 2023-08-15 18:34:57 +00:00
Michael A Cassaniti
c380047bf4 repart: Add verity configuration section and options 2023-08-15 15:32:09 +01:00
Kiran Vemula
a67e5c6e37
resolved: fixed bugs reported in varlink statistics (#28796)
Fixes https://github.com/systemd/systemd/issues/28791

Follow-up for bc837621a3
2023-08-15 11:45:58 +01:00
Michael A Cassaniti
eeee486159 sysupdate: Use sector size for partition size calculations 2023-08-15 09:17:12 +02:00
Frantisek Sumsal
01febfcdce test: explicitly specify a UTF-8 locale for UTF-8 shenanigans
As things don't work well without it:

$ LANG=C printf "\ufffe\n"
\uFFFE
2023-08-14 20:09:31 +02:00
Frantisek Sumsal
3ba954dd57 test: add coverage for #27953 2023-08-14 19:35:37 +02:00
Frantisek Sumsal
39f17be437 test: drop unnecessary log level setup
As we do that globally via a dropin.
2023-08-14 19:31:20 +02:00
Yu Watanabe
c208bf3324 test: fix expected result of systemd-repart
Follow-up for e1536d1fb0.

Fixes #28807.
Replaces #28802.
2023-08-12 18:11:46 +01:00
Yu Watanabe
ba77e00659
Merge pull request #28801 from mrc0mmand/initrd-shutdown-test
test: introduce TEST-08-INITRD
2023-08-12 20:04:06 +09:00
Frantisek Sumsal
7294632c2c test: introduce TEST-08-INITRD
And move the initrd related tests from TEST-01-BASIC there.

Additionally, this should provide coverage for recemt shutdown initrd
related issues, see:
  - https://github.com/systemd/systemd/issues/28645
  - https://github.com/systemd/systemd/pull/28648
  - https://github.com/systemd/systemd/pull/28793
2023-08-12 10:13:56 +02:00
Yu Watanabe
353c8497b1
Merge pull request #28784 from yuwata/udev-vs-tmpfiles-take-3
Udev vs tmpfiles take 3
2023-08-12 13:12:10 +09:00
Yu Watanabe
bb7f485f4b units: introduce systemd-tmpfiles-setup-dev-early.service
This makes tmpfiles, sysusers, and udevd invoked in the following order:
1. systemd-tmpfiles-setup-dev-early.service
   Create device nodes gracefully, that is, create device nodes anyway
   by ignoring unknown users and groups.
2. systemd-sysusers.service
   Create users and groups, to make later invocations of tmpfiles and
   udevd can resolve necessary users and groups.
3. systemd-tmpfiles-setup-dev.service
   Adjust owners of previously created device nodes.
4. systemd-udevd.service
   Process all devices. Especially to make block devices active and can
   be mountable.
5. systemd-tmpfiles-setup.service
   Setup basic filesystem.

Follow-up for b42482af90.

Fixes #28653.
Replaces #28681 and #28732.
2023-08-12 07:55:20 +09:00
Yu Watanabe
12aac8ea45 Revert "unit: make udev rules really take precedence over tmpfiles"
This reverts commits 112a41b6ec,
3178698bb5, and
b768379e8b.

The commit 112a41b6ec introduces #28765,
as systemd-tmpfiles-setup.service has ordering after local-fs.target,
but usually the target requires block devices processed by udevd.
Hence, the service can only start after the block devices timed out.

Fixes #28765.
2023-08-12 07:55:20 +09:00
Luca Boccassi
bf85c2395e core: copy os-release with COPY_TRUNCATE
Otherwise if the os-release file shrinks between updates, there
will be a merge of the two.
Also remove redundant ENOENT check.

Follow-up for 3f37a82545
2023-08-11 17:14:09 +01:00
Daan De Meyer
e1536d1fb0 repart: Allow specifying --copy-from more than once
Definitions will be synthesized from each of the given images.
2023-08-11 11:05:31 +02:00
Yu Watanabe
7e1850e54b
Merge pull request #28732 from yuwata/udev-vs-tmpfiles-take-2
Udev vs tmpfiles take 2
2023-08-10 08:48:51 +09:00
Yu Watanabe
7a05926fbe udev: re-introduce symlinks for loopback block device
But the directories are changed from /dev/loop/by-ref/ -> /dev/disk/by-loop-ref/
and /dev/loop/by-inode/ -> /dev/disk/by-loop-inode/.
As /dev/loop/ is used by losetup command for other purpose.
See issue #28475.

This effectively reverts commits 9915cc6086,
5022fab15f, and
c0d998248e.
2023-08-10 07:05:47 +09:00