]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agoscope: allow unprivileged delegation on scopes
Michal Sekletar [Wed, 1 Jun 2022 08:15:06 +0000 (10:15 +0200)] 
scope: allow unprivileged delegation on scopes

Previously it was possible to set delegate property for scope, but you
were not able to allow unprivileged process to manage the scope's cgroup
hierarchy. This is useful when launching manager process that  will run
unprivileged but is supposed to manage its own (scope) sub-hierarchy.

Fixes #21683

2 years agotest: skip the relevant test case if systemd-measure is not present
Frantisek Sumsal [Thu, 4 Aug 2022 09:00:10 +0000 (11:00 +0200)] 
test: skip the relevant test case if systemd-measure is not present

systemd-measure is not built without gnu-efi, which is the case, for
example, on ppc64le. Let's skip the relevant test case in this case
instead of failing.

```
The Meson build system
Version: 0.58.2
...
Host machine cpu family: ppc64
Host machine cpu: ppc64le
...
Message: Skipping systemd-measure.1 because HAVE_GNU_EFI is false
...
[  115.711775] testsuite-70.sh[745]: + cat
[  115.741996] testsuite-70.sh[832]: + /usr/lib/systemd/systemd-measure calculate --linux=/tmp/tpmdata1 --initrd=/tmp/tpmdata2
[  115.754015] testsuite-70.sh[833]: + cmp - /tmp/result
[  115.758004] testsuite-70.sh[832]: /usr/lib/systemd/tests/testdata/units/testsuite-70.sh: line 56: /usr/lib/systemd/systemd-measure: No such file or directory
[  115.773851] testsuite-70.sh[833]: cmp: EOF on - which is empty
[  115.983681] sh[835]: + systemctl poweroff --no-block
```

2 years agodocs: add disabled PR template for code freeze
Luca Boccassi [Tue, 26 Jul 2022 17:01:09 +0000 (18:01 +0100)] 
docs: add disabled PR template for code freeze

To be enabled on rc1, and disabled again after the final release.
Gives contributors a clear warning that new features/APIs will be
postponed.

2 years agorepart: Only lock block device once
Daan De Meyer [Wed, 3 Aug 2022 09:37:17 +0000 (11:37 +0200)] 
repart: Only lock block device once

Let's lock the backing fd instead of locking/unlocking multiple
times when doing multiple operations with repart. It doesn't make
much sense for anything else to touch the block device while there
are still repart operations pending on it. By keeping the lock over
the full duration of repart, we avoid anything else from interfering
with the block device inbetween operations.

2 years agoMerge pull request #24141 from DaanDeMeyer/dissect-umount
Luca Boccassi [Thu, 4 Aug 2022 00:02:55 +0000 (01:02 +0100)] 
Merge pull request #24141 from DaanDeMeyer/dissect-umount

dissect: Add systemd-dissect --umount

2 years agointegritysetup: do not use crypt_init_data_device after crypt_init
Luca Boccassi [Wed, 3 Aug 2022 17:41:13 +0000 (18:41 +0100)] 
integritysetup: do not use crypt_init_data_device after crypt_init

crypt_init_data_device() replaces the crypt_device struct with a
new allocation, losing the old one, which we get from crypt_init().
Use crypt_set_data_device() instead.

Enhance the test to cover this option too.

2 years agoman: Clarify that tools should prefer mount units over editing fstab
Daan De Meyer [Wed, 3 Aug 2022 13:52:29 +0000 (15:52 +0200)] 
man: Clarify that tools should prefer mount units over editing fstab

2 years agodissect: Add systemd-dissect --umount 24141/head
Daan De Meyer [Wed, 27 Jul 2022 23:55:11 +0000 (01:55 +0200)] 
dissect: Add systemd-dissect --umount

This command takes a mountpoint, unmounts it and makes sure the
underlying partition devices and block device are removed before
exiting.

To mirror the --mount operation, we also add a --rmdir option which
does the opposite of --mkdir, and a -U option which is a shortcut
for --umount --rmdir.

2 years agoblockdev-util: Add block_device_remove_all_partitions()
Daan De Meyer [Fri, 29 Jul 2022 10:19:09 +0000 (12:19 +0200)] 
blockdev-util: Add block_device_remove_all_partitions()

This function takes a block device, uses sd-device to iterate all
the partitions, and removes them one by one.

2 years agoloop-util: Add loop_device_unrelinquish()
Daan De Meyer [Wed, 27 Jul 2022 23:49:07 +0000 (01:49 +0200)] 
loop-util: Add loop_device_unrelinquish()

Allows taking ownership of a loop device which makes sure that
loop_device_unrefp() will try to destroy it when it runs.

2 years agoblockdev-util: Introduce block_device_add/remove_partition()
Daan De Meyer [Wed, 27 Jul 2022 22:54:16 +0000 (00:54 +0200)] 
blockdev-util: Introduce block_device_add/remove_partition()

Extracted from dissect-image.c.

2 years agoblockdev-util: Introduce fd_get_whole_disk()
Daan De Meyer [Wed, 27 Jul 2022 21:11:37 +0000 (23:11 +0200)] 
blockdev-util: Introduce fd_get_whole_disk()

Extracted from find_devno() in udevadm-lock.c.

2 years agoman: fix docbook
Lennart Poettering [Wed, 3 Aug 2022 16:51:45 +0000 (18:51 +0200)] 
man: fix docbook

2 years agojournal: remove unnecessary HAVE_PCRE2 check
Quentin Deslandes [Mon, 25 Jul 2022 13:53:12 +0000 (15:53 +0200)] 
journal: remove unnecessary HAVE_PCRE2 check

Since HAVE_PCRE2 checks are performed in pcre2-util.c, there is no
need for this extra check in journalctl.c.

2 years agocore: drop unused BUS_UNIT_QUEUE_RETURN_SKIP_ON_CONDITION_FAIL flag
Luca Boccassi [Mon, 18 Apr 2022 20:46:52 +0000 (22:46 +0200)] 
core: drop unused BUS_UNIT_QUEUE_RETURN_SKIP_ON_CONDITION_FAIL flag

We'll refactor and implement the feature in a different way

2 years agorepart: Remove unnecessary newlines from JSON output
Daan De Meyer [Wed, 3 Aug 2022 13:39:12 +0000 (15:39 +0200)] 
repart: Remove unnecessary newlines from JSON output

Before

```
➜  systemd git:(dissect-have-blkid) SYSTEMD_LOG_LEVEL=err build/systemd-repart --definitions definitions/ --dry-run=yes --empty=create --size=100M --json=pretty abc
[
        {
                "type" : "root-x86-64",
                "label" : "root-x86-64",
                "uuid" : "2f7c902c-6b2a-4b47-a44b-dca765f38cd2",
                "file" : "root.conf",
                "node" : "abc1",
                "offset" : 1048576,
                "old_size" : 0,
                "raw_size" : 103788544,
                "old_padding" : 0,
                "raw_padding" : 0,
                "activity" : "create"
        }
]

➜  systemd git:(dissect-have-blkid)
```

After:

```
➜  systemd git:(repart-newlines) SYSTEMD_LOG_LEVEL=err build/systemd-repart --definitions definitions/ --dry-run=yes --empty=create --size=100M --json=pretty abc
[
        {
                "type" : "root-x86-64",
                "label" : "root-x86-64",
                "uuid" : "2f7c902c-6b2a-4b47-a44b-dca765f38cd2",
                "file" : "root.conf",
                "node" : "abc1",
                "offset" : 1048576,
                "old_size" : 0,
                "raw_size" : 103788544,
                "old_padding" : 0,
                "raw_padding" : 0,
                "activity" : "create"
        }
]
➜  systemd git:(repart-newlines)
```

2 years agotest: optionally wait a bit when checking the mount unit
Frantisek Sumsal [Wed, 3 Aug 2022 10:35:49 +0000 (12:35 +0200)] 
test: optionally wait a bit when checking the mount unit

On fast systems we might race against systemd and check the mount unit
after mounting it way too early before systemd had a chance to react to
the change.

```
[    4.677701] H systemd[1]: Event source 0x210b3b0 (mount-monitor-dispatch) entered rate limit state.
...
[    4.863731] H testsuite-64.sh[812]: + mount /logsysfsRxx
[    4.865918] H kernel: EXT4-fs (vda2): mounted filesystem with ordered data mode. Opts: (null)
[    4.866213] H testsuite-64.sh[812]: + systemctl status /logsysfsRxx
[    4.877502] H testsuite-64.sh[919]: ○ logsysfsRxx.mount - /logsysfsRxx
[    4.877502] H testsuite-64.sh[919]:      Loaded: loaded (/etc/fstab; generated)
[    4.877502] H testsuite-64.sh[919]:      Active: inactive (dead)
[    4.877502] H testsuite-64.sh[919]:       Where: /logsysfsRxx
[    4.877502] H testsuite-64.sh[919]:        What: /dev/disk/by-uuid/deadbeef-dead-dead-beef-222222222222
[    4.877502] H testsuite-64.sh[919]:        Docs: man:fstab(5)
[    4.877502] H testsuite-64.sh[919]:              man:systemd-fstab-generator(8)
[    4.877502] H testsuite-64.sh[919]: Aug 03 10:10:10 H systemd[1]: logsysfsRxx.mount: Processing implicit device dependencies
[    4.877502] H testsuite-64.sh[919]: Aug 03 10:10:10 H systemd[1]: logsysfsRxx.mount: Added Requires dependency on /dev/disk/by-uuid/deadbeef-dead-dead-beef-222222222222
[    4.877502] H testsuite-64.sh[919]: Aug 03 10:10:10 H systemd[1]: logsysfsRxx.mount: Added StopPropagatedFrom dependency on /dev/disk/by-uuid/deadbeef-dead-dead-beef-222222222222
[    4.895683] H sh[920]: + systemctl poweroff --no-block
[    4.906533] H systemd[1]: Found unit logsysfsRxx.mount at /run/systemd/generator/logsysfsRxx.mount (regular file)
[    4.906594] H systemd[1]: Preset files don't specify rule for logsysfsRxx.mount. Enabling.
[    4.906990] H systemd[1]: testsuite-64.service: Main process exited, code=exited, status=3/NOTIMPLEMENTED
[    4.907057] H systemd[1]: testsuite-64.service: Failed with result 'exit-code'.
[    4.907287] H systemd[1]: Failed to start testsuite-64.service.
[    4.955293] H systemd[1]: Starting end.service...
[    4.955736] H systemd-logind[809]: The system will power off now!
[    4.955868] H systemd-logind[809]: System is powering down.
[    4.975781] H systemd[1]: Event source 0x210b3b0 (mount-monitor-dispatch) left rate limit state.
[    4.975821] H systemd[1]: logsysfsRxx.mount: Processing implicit device dependencies
[    4.975857] H systemd[1]: logsysfsRxx.mount: Added Requires dependency on /dev/vda2
[    4.975893] H systemd[1]: logsysfsRxx.mount: Added StopPropagatedFrom dependency on /dev/vda2
[    4.975928] H systemd[1]: Unit blockdev@dev-vda2.target has alias blockdev@.target.
[    4.975967] H systemd[1]: logsysfsRxx.mount: Added After dependency on /dev/vda2
[    4.976081] H systemd[1]: logsysfsRxx.mount: Changed dead -> mounted
```

2 years agobpf: fix is_allow_list section
James Hilliard [Mon, 1 Aug 2022 01:11:47 +0000 (01:11 +0000)] 
bpf: fix is_allow_list section

The llvm bpf compiler appears to place const volatile variables in
a non-standard section which creates an incompatibility with the gcc
bpf compiler.

To fix this force GCC to also use the rodata section.

Note this does emit an assembler warning:
Generating src/core/bpf/restrict_ifaces/restrict-ifaces.bpf.unstripped.o with a custom command
/tmp/ccM2b7jP.s: Assembler messages:
/tmp/ccM2b7jP.s:87: Warning: setting incorrect section attributes for .rodata

See:
https://github.com/llvm/llvm-project/issues/56468

Fixes:
../src/core/restrict-ifaces.c:45:14: error: ‘struct
restrict_ifaces_bpf’ has no member named ‘rodata’; did you mean
‘data’?
   45 |         obj->rodata->is_allow_list = is_allow_list;
      |              ^~~~~~
      |              data

2 years agoFix 24172: __STDC_VERSION__ may be defined in C++
Loïc Collignon [Wed, 3 Aug 2022 09:42:28 +0000 (11:42 +0200)] 
Fix 24172: __STDC_VERSION__ may be defined in C++

According to the C++ ISO standard, a conformant compiler is allowed to
define this macro to any value for any reason as it is implementation
defined: https://timsong-cpp.github.io/cppwp/cpp.predefined#2.3

This mean that it cannot be assumed that it is not defined in a C++.
Change the condition to reflect that.

2 years agoAdded DERE DBook D10 (#24173)
Gio [Wed, 3 Aug 2022 08:26:03 +0000 (04:26 -0400)] 
Added DERE DBook D10 (#24173)

* Added DERE DBook D10

2 years ago This patch adds support for enrolling secure boot boot keys from sd-boot.
Vincent Dagonneau [Mon, 9 May 2022 18:13:28 +0000 (14:13 -0400)] 
 This patch adds support for enrolling secure boot boot keys from sd-boot.

***DANGER*** NOTE ***DANGER***

This feature might result in your device becoming soft-brick as outlined
below, please use this feature carefully.

***DANGER*** NOTE ***DANGER***

If secure-boot-enrollment is set to no, then no action whatsoever is performed,
no matter the files on the ESP.

If secure boot keys are found under $ESP/loader/keys and secure-boot-enrollment
is set to either manual or force then sd-boot will generate enrollment entries
named after the directories they are in. The entries are shown at the very bottom
of the list and can be selected by the user from the menu. If the user selects it,
the user is shown a screen allowing for cancellation before a timeout. The enrollment
proceeds if the action is not cancelled after the timeout.

Additionally, if the secure-boot-enroll option is set to 'force' then the keys
located in the directory named 'auto' are going to be enrolled automatically. The user
is still going to be shown a screen allowing them to cancel the action if they want to,
however the enrollment will proceed automatically after a timeout without
user cancellation.

After keys are enrolled, the system reboots with secure boot enabled therefore, it is
***critical*** to ensure that everything needed for the system to boot is signed
properly (sd-boot itself, kernel, initramfs, PCI option ROMs).

This feature currently only allows loading the most simple set of variables: PK, KEK
and db.

The files need to be prepared with cert-to-efi-sig-list and then signed with
sign-efi-sig-list.

Here is a short example to generate your own keys and the right files for
auto-enrollement.

`
keys="PK KEK DB"
uuid="{$(systemd-id128 new -u)}"
for key in ${keys}; do
openssl req -new -x509 -subj "/CN=${key}/ -keyout "${key}.key" -out "${key}.crt"
openssl x509 -outform DER -in "${key}.crt" -out "${key}.cer"
cert-to-efi-sig-list -g "${uuid}" "${key}.crt" "${key}.esl.nosign"
done

sign-efi-sig-list -c PK.crt -k PK.key PK PK.esl.nosign PK.esl
sign-efi-sig-list -c PK.crt -k PK.key KEK KEK.esl.nosign KEK.esl
sign-efi-sig-list -c KEK.crt -k KEK.key db db.esl.nosign db.esl
`

Once these keys are enrolled, all the files needed for boot ***NEED*** to be signed in
order to run. You can sign the binaries with the sbsign tool, for example:

`
sbsign --key db.key --cert db.crt bzImage --output $ESP/bzImage
`

Example:

Assuming the system has been put in Setup Mode:

`
$ESP/loader/keys/auto/db.esl
$ESP/loader/keys/auto/KEK.esl
$ESP/loader/keys/auto/PK.esl
$ESP/loader/keys/Linux Only/db.esl
$ESP/loader/keys/Linux Only/KEK.esl
$ESP/loader/keys/Linux Only/PK.esl
$ESP/loader/keys/Linux and Windows/db.esl
$ESP/loader/keys/Linux and Windows/KEK.esl
$ESP/loader/keys/Linux and Windows/PK.esl
`

If auto-enroll is set, then the db, KEK and then PK are enrolled from the 'auto'
directory.

If not, three new boot entries are available to the user in order to enroll either the
'Linux Only', 'Linux And Windows' or 'auto' set of keys.

2 years ago"auto" is the default LogTarget of user service manager
Einsler Lee [Tue, 2 Mar 2021 12:24:23 +0000 (20:24 +0800)] 
"auto" is the default LogTarget of user service manager

"auto"  (not console) is the default LogTarget of user service manager.

2 years agomain: reopen /dev/console for user service manager
Einsler Lee [Tue, 2 Mar 2021 12:21:21 +0000 (20:21 +0800)] 
main: reopen /dev/console for user service manager

Now the console_fd of user service manager is 2. Even if LogTarget=console is set in /etc/systemd/user.conf,there is no log in the console.
This reopen the /dev/console, so the log of user service can be output in the console.

2 years agoMerge pull request #24178 from mrc0mmand/libgcc_s
Frantisek Sumsal [Wed, 3 Aug 2022 07:22:19 +0000 (07:22 +0000)] 
Merge pull request #24178 from mrc0mmand/libgcc_s

test: install libgcc_s.so.1 explicitly if available

2 years agosystemctl: clarify that "status" is about the most recent invocation of a service
Lennart Poettering [Tue, 2 Aug 2022 15:27:29 +0000 (17:27 +0200)] 
systemctl: clarify that "status" is about the most recent invocation of a service

And point people to "journalctl --unit=" for information of prior runs.

Inspired by: #24159

2 years agorepart: when keeping ref to backing inode/devnode, use fd_reopen() rathern than F_DUPFD
Lennart Poettering [Tue, 2 Aug 2022 16:16:21 +0000 (18:16 +0200)] 
repart: when keeping ref to backing inode/devnode, use fd_reopen() rathern than F_DUPFD

Via the "backing_fd" variable we intend to pin the backing inode through
our entire code. So far we typically created the fd via F_DUPFD_CLOEXEC,
and thus any BSD lock taken one the original fd is shared with our
backing_fd reference. And if the origina fd is closed but our backing_fd
is not, we'll keep the BSD lock open, even if we then reopen the block
device through the backing_fd. If hit, this results in a deadlock.

Let's fix that by creating the backing_fd via fd_reopen(), so that the
locks are no longer shared, and if the original fd is closed all BSD
locks on it that are in effect are auto-released.

(Note the deadlock is only triggered if multiple operations on the same
backing inode are executed, i.e. factory reset, resize and applying of
partitions.)

Replaces: #24181

2 years agomkosi: Update to latest
Daan De Meyer [Tue, 2 Aug 2022 18:15:02 +0000 (20:15 +0200)] 
mkosi: Update to latest

Fixed centos stream 8 builds that were hitting a nonexisting mirror
url

2 years agoupdate TODO
Lennart Poettering [Tue, 2 Aug 2022 15:09:34 +0000 (17:09 +0200)] 
update TODO

2 years agomountpoint-util: make fd_is_mountpoint() work reasonably with AT_EMPTYPATH
Lennart Poettering [Tue, 2 Aug 2022 11:58:09 +0000 (13:58 +0200)] 
mountpoint-util: make fd_is_mountpoint() work reasonably with AT_EMPTYPATH

Inspired by: https://github.com/systemd/systemd/pull/24141

Calling fd_is_mountpoint() with AT_EMPTYPATH and an empty filename can
only work if we have new statx() available. If we do not, we can still
make things work for directories, but not for other inodes (since there
we cannot query information about the parent inode to compare things.)

Hence, let's handle and test this explicitly, to support this to the
level this is possible.

2 years agoresolved: fix single-label resolution over DNS
Jacek Migacz [Wed, 27 Jul 2022 16:38:12 +0000 (18:38 +0200)] 
resolved: fix single-label resolution over DNS

Fixes: #23494 (when ResolveUnicastSingleLabel=yes)
2 years agotest: be a bit more verbose about shared library symlinks 24178/head
Frantisek Sumsal [Tue, 2 Aug 2022 16:28:43 +0000 (18:28 +0200)] 
test: be a bit more verbose about shared library symlinks

For example:
```
D: Installing /usr/lib64/libz.so.1.2.11
D: Creating symlink /usr/lib64/libz.so.1.2.11 -> /usr/lib64/libz.so.1
D: Creating extra symlink: /lib64/libz.so
D: Installing /usr/lib64/libgcc_s-12-20220507.so.1
D: Creating symlink /usr/lib64/libgcc_s-12-20220507.so.1 -> /usr/lib64/libgcc_s.so.1
```

2 years agotest: install libgcc_s.so.1 explicitly if available
Frantisek Sumsal [Tue, 2 Aug 2022 11:54:57 +0000 (13:54 +0200)] 
test: install libgcc_s.so.1 explicitly if available

Since the library is dlopen()ed by libpthread and required during
pthread_exit()/pthread_cancel(), let's install it explicitly if available to
avoid unexpected fails in tests. This also consolidates all related
workarounds for this library across the test scripts.

2 years agoMerge pull request #24146 from poettering/efi-stub-measure-payload
Luca Boccassi [Tue, 2 Aug 2022 13:42:33 +0000 (14:42 +0100)] 
Merge pull request #24146 from poettering/efi-stub-measure-payload

stub: measure kernel/initrd/parameters into clean PCRs 11/12/13, and add "systemd-measure" tool to be able to pre-calculate values

2 years agoupdate TODO
Lennart Poettering [Tue, 2 Aug 2022 12:01:29 +0000 (14:01 +0200)] 
update TODO

2 years agomkosi: Update to latest commit
Daan De Meyer [Tue, 2 Aug 2022 09:51:40 +0000 (11:51 +0200)] 
mkosi: Update to latest commit

With this update, Arch Linux keyring updates will be automatically
pulled in instead of having to update to a new mkosi commit every
time the keyring gets outdated.

2 years agoupdate TODO 24146/head
Lennart Poettering [Wed, 27 Jul 2022 13:46:42 +0000 (15:46 +0200)] 
update TODO

2 years agotest: add trivial test for systemd-measure
Lennart Poettering [Fri, 29 Jul 2022 16:45:53 +0000 (18:45 +0200)] 
test: add trivial test for systemd-measure

2 years agomeasure: add new tool to precalculate PCR values for a kernel image
Lennart Poettering [Mon, 25 Jul 2022 22:13:16 +0000 (00:13 +0200)] 
measure: add new tool to precalculate PCR values for a kernel image

For now, this simply outputs the PCR hash values expected for a kernel
image, if it's measured like sd-stub would do it.

(Later on, we can extend the tool, to optionally sign these
pre-calculated measurements, in order to implement signed PCR policies
for disk encryption.)

2 years agobootctl: suppress "Boot Loaders Listed in EFI Variables" section header if section...
Lennart Poettering [Thu, 28 Jul 2022 08:48:16 +0000 (10:48 +0200)] 
bootctl: suppress "Boot Loaders Listed in EFI Variables" section header if section empty

Some more cosmetics.

2 years agobootctl: prettify tree output of discovered boot loaders a bit
Lennart Poettering [Wed, 27 Jul 2022 15:23:25 +0000 (17:23 +0200)] 
bootctl: prettify tree output of discovered boot loaders a bit

Previously, the tree output of discovered boot laoders in the ESP would
look like this:

Available Boot Loaders on ESP:
          ESP: /efi (/dev/disk/by-partuuid/0c6f41ed-2573-4723-8c84-23681f9d1c28)
         File: └─/EFI/systemd/systemd-bootx64.efi (systemd-boot v250.7-1.fc36)
         File: └─/EFI/BOOT/BOOTX64.EFI (systemd-boot v250.7-1.fc36)

With this change the tree branches are corrected to look like this:

Available Boot Loaders on ESP:
          ESP: /efi (/dev/disk/by-partuuid/0c6f41ed-2573-4723-8c84-23681f9d1c28)
         File: ├─/EFI/systemd/systemd-bootx64.efi (systemd-boot v250.7-1.fc36)
               └─/EFI/BOOT/BOOTX64.EFI (systemd-boot v250.7-1.fc36)

Ahhh! So much nicer. This incorrect tree drawing has been bugging me for
so long. Finally I can sleep at night again!

2 years agobootctl: underline sections in status output
Lennart Poettering [Wed, 27 Jul 2022 15:07:12 +0000 (17:07 +0200)] 
bootctl: underline sections in status output

Let's give the output a bit more structure, inspired by the way our
newer --help texts use underlining to separate out sections a bit.

2 years agoboot: add hexdump helper call
Lennart Poettering [Thu, 28 Jul 2022 08:47:05 +0000 (10:47 +0200)] 
boot: add hexdump helper call

This is not actually used (or even supposed to be used) in clean
codepaths, but is tremendously useful when verifying things work
correctly, as a debugging tool.

2 years agoboot: add three new boot loader feature flags
Lennart Poettering [Wed, 27 Jul 2022 14:39:13 +0000 (16:39 +0200)] 
boot: add three new boot loader feature flags

Report whether the devicetree + sort-key boot loader spec type #1
fields are supported, and whether the "@saved" pseudo-entry is
supported.

Strictly speaking, thes features have been added in versions that are
already released (250+), so by adding this those version even though
they support the features will be considered not supporting them, but
that should be OK (the opposite would be a problem though, i.e. if we'd
assume a boot loader had a feature it actually does not).

These three features are features relevant to userspace, as it allows
userspace to tweak/genereate BLS entries or set EFI vars correctly.
Other features (i.e. that have no impliciations to userspace) are not
reported.

2 years agobootctl: show stub feature set in status output
Lennart Poettering [Wed, 27 Jul 2022 13:28:55 +0000 (15:28 +0200)] 
bootctl: show stub feature set in status output

2 years agostub: clean up kernel command line when converting to ASCII
Lennart Poettering [Thu, 28 Jul 2022 15:11:47 +0000 (17:11 +0200)] 
stub: clean up kernel command line when converting to ASCII

Let's be a bit more careful when converting the UTF-16 cmdline to ASCII.
Let's convert all characters out of the printable ASCII range to spaces,
instead of blindly relying on C's downcasting behaviour.

2 years agostub: introduce StubFeatures, similar to LoaderFeatures
Lennart Poettering [Wed, 27 Jul 2022 13:25:59 +0000 (15:25 +0200)] 
stub: introduce StubFeatures, similar to LoaderFeatures

systemd-boot reports its features via the LoaderFeatures EFI variable.
Let's add something similar for stub features, given they have been
growing.

For starters only define four feature flags. One is a baseline feature
we pretty much always supported (see comment in code), two are features
added in one of the most recently released systemd version, and the
final one, is a feature we added a few commits ago.

This is useful for userspace to figure out what is supported and what
not.

2 years agoboot: move unified kernel PE section definitions into 'fundamental' code
Lennart Poettering [Wed, 27 Jul 2022 08:58:29 +0000 (10:58 +0200)] 
boot: move unified kernel PE section definitions into 'fundamental' code

Le's share this code between userspace and uefispace. This is useful
later when pre-measuring expected PCRs from userspace.

2 years agoboot: split out TPM PCR defines into header file we can share between userspace and...
Lennart Poettering [Wed, 27 Jul 2022 08:43:34 +0000 (10:43 +0200)] 
boot: split out TPM PCR defines into header file we can share between userspace and kernel space

2 years agosd-stub: measure sysext images picked up by sd-stub into PCR 13
Lennart Poettering [Tue, 26 Jul 2022 09:35:57 +0000 (11:35 +0200)] 
sd-stub: measure sysext images picked up by sd-stub into PCR 13

Let's grab another so far unused PCR, and measure all sysext images into
it that we load from the ESP. Note that this is possibly partly redundant,
since sysext images should have dm-verity enabled, and that is hooked up
to IMA. However, measuring this explicitly has the benefit that we can
measure filenames too, easily, and that all without need for IMA or
anything like that.

This means: when booting a unified sd-stub kernel through sd-boot we'll
now have:

1. PCR 11: unified kernel image payload (i.e. kernel, initrd, boot
   splash, dtb, osrelease)

2. PCR 12: kernel command line (i.e. the one embedded in the image, plus
   optionally an overriden one) + any credential files picked up by
   sd-stub

3. PCR 13: sysext images picked up by sd-stub

And each of these three PCRs should carry just the above, and start from
zero, thus be pre-calculatable.

Thus, all components and parameters of the OS boot process (i.e.
everything after the boot loader) is now nicely pre-calculable.

NOTE: this actually replaces previous measuring of the syext images into
PCR 4. I added this back in 845707aae23b3129db635604edb95c4048a5922a,
following the train of thought, that sysext images for the initrd should
be measured like the initrd itself they are for, and according to my
thinking that would be a unified kernel which is measured by firmware
into PCR 4 like any other UEFI executables.

However, I think we should depart from that idea. First and foremost
that makes it harder to pre-calculate PCR 4 (since we actually measured
quite incompatible records to the TPM event log), but also I think
there's great value in being able to write policies that bind to the
used sysexts independently of the earlier boot chain (i.e. shim, boot
loader, unified kernel), hence a separate PCR makes more sense.

Strictly speaking, this is a compatibility break, but I think one we can
get away with, simply because the initrd sysext images are currently not
picked up by systemd-sysext yet in the initrd, and because of that we
can be reasonably sure noone uses this yet, and hence relies on the PCR
register used. Hence, let's clean this up before people actually do
start relying on this.

2 years agostub: measure PE sections in a defined order, and include all sections
Lennart Poettering [Mon, 25 Jul 2022 22:13:06 +0000 (00:13 +0200)] 
stub: measure PE sections in a defined order, and include all sections

2 years agoefi: from the stub measure the ELF kernel + built-in initrd and so on into PCR 11
Lennart Poettering [Mon, 25 Jul 2022 15:44:24 +0000 (17:44 +0200)] 
efi: from the stub measure the ELF kernel + built-in initrd and so on into PCR 11

Here we grab a new – on Linux so far unused (by my Googling skills, that
is) – and measure all static components of the PE kernel image into.
This is useful since for the first time we'll have a PCR that contains
only a PCR of the booted kernel, nothing else. That allows putting
together TPM policies that bind to a specific kernel (+ builtin initrd),
without having to have booted that kernel first. PCRs can be
pre-calculated. Yay!

You might wonder, why we measure just the discovered PE sections we are
about to use, instead of the whole PE image. That's because of the next
step I have in mind: PE images should also be able to carry an
additional section that contains a signature for its own expected,
pre-calculated PCR values. This signature data should then be passed
into the booted kernel and can be used there in TPM policies. Benefit:
TPM policies can now be bound to *signatures* of PCRs, instead of the
raw hash values themselves. This makes update management a *lot* easier,
as policies don't need to be updated whenever a kernel is updated, as
long as the signature is available. Now, if the PCR signature is
embedded in the kernel PE image it cannot be of a PCR hash of the kernel
PE image itself, because that would be a chicken-and-egg problem. Hence,
by only measuring the relavent payload sections (and that means
excluding the future section that will contain the PCR hash signature)
we avoid this problem, naturally.

2 years agoefi: tell userspace where the stub measured the kernel command line/credentials into
Lennart Poettering [Tue, 26 Jul 2022 16:32:21 +0000 (18:32 +0200)] 
efi: tell userspace where the stub measured the kernel command line/credentials into

This is useful for userspace to know, so that policies can be put
together safely, matching what the stub actually measured.

2 years agoefi: optionally report when measuring to TPM whether we actually did
Lennart Poettering [Mon, 25 Jul 2022 15:35:16 +0000 (17:35 +0200)] 
efi: optionally report when measuring to TPM whether we actually did

the measurement calls can succeed either when they actually measured
something, or when they skipped measurement because the local system
didn't support TPMs.

Let's optionally return a boolean saying which case it is. This is later
useful to tell userspace how and if we measured something.

2 years agoupdate TODO
Lennart Poettering [Tue, 2 Aug 2022 08:28:15 +0000 (10:28 +0200)] 
update TODO

2 years agoMerge pull request #24174 from yuwata/network-link-local-address
Yu Watanabe [Tue, 2 Aug 2022 03:56:01 +0000 (12:56 +0900)] 
Merge pull request #24174 from yuwata/network-link-local-address

network: fix link local address handling

2 years agotest-network: add test case for #23197 24174/head
Yu Watanabe [Mon, 1 Aug 2022 18:43:04 +0000 (03:43 +0900)] 
test-network: add test case for #23197

2 years agonetwork: make link_may_have_ipv6ll() optionally check Multicast= setting
Yu Watanabe [Mon, 1 Aug 2022 18:33:21 +0000 (03:33 +0900)] 
network: make link_may_have_ipv6ll() optionally check Multicast= setting

Fixes the IPv6LL issue in #23197.

2 years agonetwork: fix possible NULL-pointer dereference
Yu Watanabe [Mon, 1 Aug 2022 18:32:55 +0000 (03:32 +0900)] 
network: fix possible NULL-pointer dereference

2 years agonetwork: do not try to start ipv4acd on non-supported interfaces
Yu Watanabe [Mon, 1 Aug 2022 18:04:59 +0000 (03:04 +0900)] 
network: do not try to start ipv4acd on non-supported interfaces

Fixes IPv4LL issue reported in #23197.

2 years agonetwork: split link_ipv4ll_enabled() into two
Yu Watanabe [Mon, 1 Aug 2022 18:01:49 +0000 (03:01 +0900)] 
network: split link_ipv4ll_enabled() into two

And move it from networkd-link.[ch] to relevant files.

2 years agonetwork: drop doubled semicolon
Yu Watanabe [Mon, 1 Aug 2022 17:44:37 +0000 (02:44 +0900)] 
network: drop doubled semicolon

2 years agotree-wide: fix typo
Yu Watanabe [Mon, 1 Aug 2022 17:43:38 +0000 (02:43 +0900)] 
tree-wide: fix typo

2 years agobuild(deps): bump meson from 0.62.2 to 0.63.0 in /.github/workflows
dependabot[bot] [Mon, 1 Aug 2022 09:05:55 +0000 (09:05 +0000)] 
build(deps): bump meson from 0.62.2 to 0.63.0 in /.github/workflows

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

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

Signed-off-by: dependabot[bot] <support@github.com>
2 years agobpf: set gcc std and compile flags
James Hilliard [Mon, 1 Aug 2022 01:34:11 +0000 (01:34 +0000)] 
bpf: set gcc std and compile flags

This should make gcc bpf compilation more reliable.

2 years agobuild(deps): bump github/codeql-action from 2.1.15 to 2.1.17
dependabot[bot] [Mon, 1 Aug 2022 09:05:28 +0000 (09:05 +0000)] 
build(deps): bump github/codeql-action from 2.1.15 to 2.1.17

Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.1.15 to 2.1.17.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](https://github.com/github/codeql-action/compare/3f62b754e23e0dd60f91b744033e1dc1654c0ec6...0c670bbf0414f39666df6ce8e718ec5662c21e03)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agobuild(deps): bump github/super-linter from 4.9.4 to 4.9.5
dependabot[bot] [Mon, 1 Aug 2022 09:05:35 +0000 (09:05 +0000)] 
build(deps): bump github/super-linter from 4.9.4 to 4.9.5

Bumps [github/super-linter](https://github.com/github/super-linter) from 4.9.4 to 4.9.5.
- [Release notes](https://github.com/github/super-linter/releases)
- [Changelog](https://github.com/github/super-linter/blob/main/docs/release-process.md)
- [Commits](https://github.com/github/super-linter/compare/a320804d310fdeb8d1a46c6c6c1e615d443b10c9...2d64ac1c067c34beaf7d24cc12733cd46236f76e)

---
updated-dependencies:
- dependency-name: github/super-linter
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agobuild(deps): bump actions/setup-node from 3.3.0 to 3.4.1
dependabot[bot] [Mon, 1 Aug 2022 09:05:24 +0000 (09:05 +0000)] 
build(deps): bump actions/setup-node from 3.3.0 to 3.4.1

Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3.3.0 to 3.4.1.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/eeb10cff27034e7acf239c5d29f62154018672fd...2fddd8803e2f5c9604345a0b591c3020ee971a93)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2 years agogcrypt: switch to system rng before gcry_check_version (#24162)
Cristian Rodríguez [Mon, 1 Aug 2022 05:04:27 +0000 (01:04 -0400)] 
gcrypt: switch to system rng before gcry_check_version (#24162)

Current docs claim this must be done before gcry_check_version.

2 years agoAdd ACCEL_MOUNT_MATRIX for OXP Mini
Joaquín Ignacio Aramendía [Sat, 30 Jul 2022 19:56:04 +0000 (16:56 -0300)] 
Add ACCEL_MOUNT_MATRIX for OXP Mini

2 years agoMerge pull request #24090 from yuwata/test-login
Frantisek Sumsal [Sat, 30 Jul 2022 20:11:50 +0000 (20:11 +0000)] 
Merge pull request #24090 from yuwata/test-login

test: hopefully fixes race in TEST-35-LOGIN

2 years agoUpdate LINGUAS
Hugo Carvalho [Sat, 30 Jul 2022 18:12:09 +0000 (19:12 +0100)] 
Update LINGUAS

Sort language codes in alphabetical order

2 years agotest: restart logind before cleaning up sessions 24090/head
Yu Watanabe [Sat, 30 Jul 2022 14:51:25 +0000 (23:51 +0900)] 
test: restart logind before cleaning up sessions

Hopefully, fixes #24040.

2 years agotest: do not restart getty@tty2 automatically
Yu Watanabe [Sat, 30 Jul 2022 15:12:48 +0000 (00:12 +0900)] 
test: do not restart getty@tty2 automatically

2 years agotest: terminate session and user on cleanup
Yu Watanabe [Sat, 30 Jul 2022 15:11:59 +0000 (00:11 +0900)] 
test: terminate session and user on cleanup

2 years agodocs: Correct StandartOutput documentation
Max Gautier [Sat, 30 Jul 2022 06:46:27 +0000 (08:46 +0200)] 
docs: Correct StandartOutput documentation

fix #2114

2 years agoMerge pull request #24154 from yuwata/meson-fixups
Luca Boccassi [Sat, 30 Jul 2022 12:48:09 +0000 (13:48 +0100)] 
Merge pull request #24154 from yuwata/meson-fixups

meson: several fixlets

2 years agomeson: fix broken boolean kwarg 24154/head
Eli Schwartz [Wed, 27 Jul 2022 01:49:48 +0000 (21:49 -0400)] 
meson: fix broken boolean kwarg

Everywhere else that `conf.get('ENABLE_*')` is used as a boolean key for
something (for example in if statements) it always checks if == 1, but
in this one case it neglects to do so. This is important because
conf.get yields the same int that was stored, but if statements require
booleans.

So does executable's "install" kwarg, at least according to the
documentation. In actuality, it accepts all types without sanity
checking, then uses python "if bool(var)", so you can actually do
`install: 'do not'` and that's treated identical to `true`. This is a
type-checking bug which Meson will eventually fix.

muon fails on the same code, today.

2 years agomeson: strip various strings before converting them to integers
Eli Schwartz [Wed, 27 Jul 2022 01:13:55 +0000 (21:13 -0400)] 
meson: strip various strings before converting them to integers

"9\n" is not intrinsically a number, although some tools might
auto-strip strings before checking if they are a number. It's not
guaranteed, anyway.

2 years agomeson: use files in run_command with relativized path
Eli Schwartz [Wed, 27 Jul 2022 01:09:07 +0000 (21:09 -0400)] 
meson: use files in run_command with relativized path

Passing a file as a command argument in string form assumes that
run_command has the current subdir as its cwd, but Meson's documentation
*explicitly* calls this out as undefined and wrong to use.

Indeed, muon has a different implementation that uses a different cwd,
and this argument cannot be found. Instead, passing a files() object
means that it's the job of meson itself to verify the file exists, then
pass it to the run_command in some format that guarantees it is a valid
path reference.

2 years agomeson: move i18n module import to only when it is used
Eli Schwartz [Thu, 19 May 2022 10:54:40 +0000 (06:54 -0400)] 
meson: move i18n module import to only when it is used

When translations are disabled, it's not necessary to `import('i18n')`
and do nothing with it. Also, importing it is (slightly) slow as Meson
needs to load another implementation file from disk, so why bother with
that work?

More particularly, muon does not yet implement this module and fails to
setup. Since there's already an option to disable using it, it makes
sense to let that option completely skip the not-implemented
functionality and actually succeed.

2 years agomeson: fix type for many build options
Eli Schwartz [Thu, 19 May 2022 10:50:35 +0000 (06:50 -0400)] 
meson: fix type for many build options

Integers and booleans are supposed to be actual integers and booleans,
not strings describing their value, but Meson silently accepted either
one. It's still wrong to do it though, and other implementations of
Meson such as muon choke on it.

2 years agomeson: use 0 for default uids, gids, and time epoch
Yu Watanabe [Sat, 30 Jul 2022 04:44:11 +0000 (13:44 +0900)] 
meson: use 0 for default uids, gids, and time epoch

0 UID and GID are special, and should not be acceptable for the settings.
Hence, we can handle 0 as unset.

Strictly speaking, time epoch with 0 is valid, but I guess no one use
0 as a valid value.

2 years agogcrypt: prefer the OS RNG
Cristian Rodríguez [Tue, 26 Jul 2022 18:24:12 +0000 (18:24 +0000)] 
gcrypt: prefer the OS RNG

by default, gcrypt defaults to an userspace RNG, this is
the wrong thing (tm) to do on linux.

Switch to the SYSTEM rng instead.

2 years agovirt: detect KubeVirt instance
Fei Li [Fri, 17 Jun 2022 11:26:28 +0000 (19:26 +0800)] 
virt: detect KubeVirt instance

Kubevirt is currently technically based on KVM (but not xen yet[1]).
The systemd-detect-virt command, used to differentiate the current
virtualization environment, works fine on x86 relying on CPUID, while
fails to get the correct value (none instead of kvm) on aarch64.

Let's fix this by adding a new 'vendor[KubeVirt] = kvm' classification
considering the sys_vendor is always KubeVirt.

[1] https://groups.google.com/g/kubevirt-dev/c/C6cUgzTOsVg

Signed-off-by: Fei Li <lifei.shirley@bytedance.com>
2 years agojournalctl: allow statically linked build
James Hilliard [Wed, 27 Jul 2022 21:28:09 +0000 (15:28 -0600)] 
journalctl: allow statically linked build

The journalctl tool may be needed on cross compilation hosts in order
to run --update-catalog against a target rootfs.

To avoid reliability issues caused by shared linking allow journalctl
to be linked statically.

2 years agounits: Simplify container getty handling
Daan De Meyer [Tue, 19 Jul 2022 08:37:05 +0000 (10:37 +0200)] 
units: Simplify container getty handling

Let's remove the baud settings for the container getty units since
they don't have any effect there anyway. On top of that, when we're
dealing with container TTYs, we can handle all the setup involved
ourselves so let's prevent agetty/login from touching the container
tty at all.

One example where this helps is that it actually makes disabling
TTYVHangup have an effect since before, login would unconditionally
call vhangup() on the tty.

2 years agoMerge pull request #24080 from rdtscp/feature/machinectl/copy-force-flag
Daan De Meyer [Thu, 28 Jul 2022 12:15:33 +0000 (14:15 +0200)] 
Merge pull request #24080 from rdtscp/feature/machinectl/copy-force-flag

Add --force flag to machinectl copy-[to|from]

2 years agoupdate TODO
Lennart Poettering [Thu, 28 Jul 2022 09:25:26 +0000 (11:25 +0200)] 
update TODO

2 years agoMerge pull request #23875 from yuwata/resolve-mdns-fix-use-after-free
Luca Boccassi [Wed, 27 Jul 2022 21:57:31 +0000 (22:57 +0100)] 
Merge pull request #23875 from yuwata/resolve-mdns-fix-use-after-free

resolve: mdns: fix use-after-free

2 years agoUse correct option name in error message
Janis Goldschmidt [Wed, 27 Jul 2022 09:23:20 +0000 (11:23 +0200)] 
Use correct option name in error message

2 years agomachinectl: Add plumbing for a `--force` flag for file copy 24080/head
Alexander Wilson [Fri, 22 Jul 2022 11:08:11 +0000 (04:08 -0700)] 
machinectl: Add plumbing for a `--force` flag for file copy
machine: Add APIs CopyTo[Machine]WithFlags + CopyFrom[Machine]WithFlags
- Same API to those without `WithFlags` (except this can take flags)
- Initially, only a flag to allow replacing a file if it already exists

2 years agocopy: Respect COPY_REPLACE flag for copy_tree
Alexander Wilson [Fri, 22 Jul 2022 11:13:31 +0000 (04:13 -0700)] 
copy: Respect COPY_REPLACE flag for copy_tree
- Add a test that asserts that copy_tree on an existing file will fail without COPY_REPLACE
- Add a test that asserts that copy_tree with COPY_MERGE and COPY_REPLACE on an existing directory will overwrite files that already exist.

2 years agocopy.[ch]: Refactor
Alexander Wilson [Fri, 22 Jul 2022 11:15:08 +0000 (04:15 -0700)] 
copy.[ch]: Refactor
- Refactor: Move HardlinkContext to header file
- Refactor: Create `fd_copy_tree_generic` which isolates the functionality to check stat type and appropriately copy.
- Refactor: Create `fd_copy_leaf` which handles copying leaf nodes of a file tree.

2 years agostub: override StubInfo EFI variable unconditionally, since *we* own it
Lennart Poettering [Mon, 25 Jul 2022 15:40:32 +0000 (17:40 +0200)] 
stub: override StubInfo EFI variable unconditionally, since *we* own it

The other variables are owned by the boot menu (i.e. sd-boot), we only
fill those in if it didn't do so for us (to support cases where our stub
kernel is directly invoked by UEFI). But StubInfo is genuinely about the
stub, hence let's simplify things and unconditionally set it from the
stub.

2 years agoboot: introduce common shortcut exit path in pack_cpio()
Lennart Poettering [Tue, 26 Jul 2022 16:23:49 +0000 (18:23 +0200)] 
boot: introduce common shortcut exit path in pack_cpio()

THis will be useful in a later commit, when we add more stuff to the
common exit path. But even without that, it's a nice simplification,
removing redundant lines.

2 years agoportable: set PrivateTmp=yes in trusted profile too
Luca Boccassi [Tue, 26 Jul 2022 16:41:51 +0000 (17:41 +0100)] 
portable: set PrivateTmp=yes in trusted profile too

When running on images you don't want to modify the /tmp
directory even if it's writable, and often it will just
be read-only. Set PrivateTmp=yes.

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

2 years agoMerge pull request #24122 from yuwata/core-mount-bind-mount-on-nfs
Luca Boccassi [Tue, 26 Jul 2022 22:17:23 +0000 (23:17 +0100)] 
Merge pull request #24122 from yuwata/core-mount-bind-mount-on-nfs

core/mount: ignore -EACCES from mkdir_p_label() on NFS

2 years agomkosi: Update to latest commit
Daan De Meyer [Tue, 26 Jul 2022 18:40:01 +0000 (20:40 +0200)] 
mkosi: Update to latest commit

Fixes an issue with Arch builds failing by updating the archlinux
keyring package.

2 years agoefi: update measure.h comments a bit
Lennart Poettering [Mon, 25 Jul 2022 15:42:54 +0000 (17:42 +0200)] 
efi: update measure.h comments a bit

2 years agoupdate TODO
Lennart Poettering [Mon, 25 Jul 2022 15:33:53 +0000 (17:33 +0200)] 
update TODO

(this basically just copies a coment from src/boot/efi/measure.h into
the TODO)