]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
2 years agotest_ukify: add test for combining config and cmdline 27262/head
Zbigniew Jędrzejewski-Szmek [Thu, 4 May 2023 13:17:27 +0000 (15:17 +0200)] 
test_ukify: add test for combining config and cmdline

2 years agoman: describe all the changes to ukify
Zbigniew Jędrzejewski-Szmek [Mon, 24 Apr 2023 10:40:08 +0000 (12:40 +0200)] 
man: describe all the changes to ukify

As in mkosi(1), let's describe the config file and commandline options
together. This is nice for us, because we don't need to duplicate descriptions
and we're less likely to forget to update one place or the other. This is also
nice for users, because they can easily figure out what can be configured
where.

The options are now ordered by config file section.

--summary was not described before.

More examples are added.

2 years agoci: install pytest-flakes
Zbigniew Jędrzejewski-Szmek [Sat, 22 Apr 2023 11:17:32 +0000 (13:17 +0200)] 
ci: install pytest-flakes

Some web searches say that it's packaged for those distros and not the others…

v2:
- drop arch. https://aur.archlinux.org/packages/python-pytest-flakes exists,
  but installation fails in CI.

2 years agotest_ukify: rework how --flakes argument is appended
Zbigniew Jędrzejewski-Szmek [Sat, 22 Apr 2023 11:10:28 +0000 (13:10 +0200)] 
test_ukify: rework how --flakes argument is appended

The usual approach is to put 'addopts = --flakes' in setup.cfg. Unfortunately
this fails badly when pytest-flakes is not installed:
  ERROR: usage: test_ukify.py [options] [file_or_dir] [file_or_dir] [...]
  test_ukify.py: error: unrecognized arguments: --flakes

pytest-flakes is not packaged everywhere, and this test is not very important,
so let's just do it only if pytest-flakes is available. We now detect if
pytest-flakes is available and only add '--flakes' conditionally. This
unfortunately means that when invoked via 'pytest' or directly as
'src/ukify/test/test_ukify.py', '--flakes' will not be appended automatically.
But I don't see a nice way to achieve previous automatic behaviour.

(I first considered making 'setup.cfg' templated. But then it is created
in the build directory, but we would need it in the source directory for
pytest to load it automatically. So to load the file, we'd need to give an
argument to pytest anyway, so we don't gain anything with this more complex
approach.)

2 years agotest_ukify: propagate failure
Zbigniew Jędrzejewski-Szmek [Sat, 22 Apr 2023 09:20:11 +0000 (11:20 +0200)] 
test_ukify: propagate failure

Oops. This explains why the tests were "passing" in CI even
though a direct pytest invocation would fail.

2 years agoukify: appease mypy
Zbigniew Jędrzejewski-Szmek [Fri, 21 Apr 2023 16:43:50 +0000 (18:43 +0200)] 
ukify: appease mypy

Note to self: PEP 585 introduced using collection types as types,
and is available since 3.9. PEP 604 allows writing unions with "|",
but is only available since 3.10, so not yet here because we maintain
compat with 3.9.

2 years agoTODO: remove two entries
Zbigniew Jędrzejewski-Szmek [Fri, 14 Apr 2023 16:53:49 +0000 (18:53 +0200)] 
TODO: remove two entries

0ccfd3564b2532a4da6526a9e030362c4a142b77 implemented one of the items, and this
pull requests handles the other one.

2 years agotest/60-ukify: override stub location in tests
Zbigniew Jędrzejewski-Szmek [Fri, 14 Apr 2023 16:45:24 +0000 (18:45 +0200)] 
test/60-ukify: override stub location in tests

Without this, build would fail if the stub is not available in /usr/lib/.

2 years agotest-kernel-install: test 60-ukify.install and 90-uki-copy.install
Zbigniew Jędrzejewski-Szmek [Thu, 13 Apr 2023 16:11:39 +0000 (18:11 +0200)] 
test-kernel-install: test 60-ukify.install and 90-uki-copy.install

We install a kernel with layout=uki and uki_generator=ukify, and test
that a UKI gets installed in the expected place. The two plugins cooperate,
so it's easiest to test them together.

2 years ago60-ukify: kernel-install plugin that calls ukify to create a UKI
Zbigniew Jędrzejewski-Szmek [Thu, 13 Apr 2023 16:07:22 +0000 (18:07 +0200)] 
60-ukify: kernel-install plugin that calls ukify to create a UKI

60-ukify.install calls ukify with a config file, so singing and policies and
splash will be done through the ukify config file, without 60-ukify.install
knowing anything directly.

In meson.py, the variable for loaderentry.install.in is used just once, let's
drop it. (I guess this approach was copied from kernel_install_in, which is
used in another file.)

The general idea is based on cvlc12's #27119, but now in Python instead of
bash.

2 years agotest_ukify: add tests for the new functionality
Zbigniew Jędrzejewski-Szmek [Fri, 21 Apr 2023 14:06:53 +0000 (16:06 +0200)] 
test_ukify: add tests for the new functionality

2 years agoukify: PeError → PEError
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2023 18:23:18 +0000 (20:23 +0200)] 
ukify: PeError → PEError

We don't lowercase acronyms in systemd usually.
Remove unnused f'' prefix to avoid a pylint warning.

2 years agoukify: rework option parsing to support a config file
Zbigniew Jędrzejewski-Szmek [Thu, 20 Apr 2023 18:22:25 +0000 (20:22 +0200)] 
ukify: rework option parsing to support a config file

In some ways this is similar to mkosi: we have a argparse.ArgumentParser()
with a bunch of options, and a configparser.ConfigParser() with an
overlapping set of options. Many options are settable in both places, but
not all. In mkosi, we define this in three places (a dataclass, and a
function for argparse, and a function for configparser). Here, we have one
huge list of ConfigItem instances. Each instance specifies the full metadata
for both parsers. Argparse generates a --help string for all the options,
and we also append a config file sample to --help based on the ConfigItem
data:

$ python src/ukify/ukify.py --help|tail -n 25
config file:
  [UKI]
  Linux = LINUX
  Initrd = INITRD…
  Cmdline = TEXT|@PATH
  OSRelease = TEXT|@PATH
  DeviceTree = PATH
  Splash = BMP
  PCRPKey = KEY
  Uname = VERSION
  EFIArch = ia32|x64|arm|aa64|riscv64
  Stub = STUB
  PCRBanks = BANK…
  SigningEngine = ENGINE
  SecureBootPrivateKey = SB_KEY
  SecureBootCertificate = SB_CERT
  SignKernel = SIGN_KERNEL

  [PCRSignature:NAME]
  PCRPrivateKey = PATH
  PCRPublicKey = PATH
  Phases = PHASE-PATH…

While writing this I needed to check the argument parsing, so I added
a --summary switch. It just pretty-prints the resulting option dictionary:

$ python src/ukify/ukify.py /efi//3a9d668b4db749398a4a5e78a03bffa5/6.2.11-300.fc38.x86_64/linux /efi//3a9d668b4db749398a4a5e78a03bffa5/6.2.11-300.fc38.x86_64/initrd --pcr-private-key=PRIV.key --pcr-public-key=PUB.key --config=man/ukify-example.conf --summary
Host arch 'x86_64', EFI arch 'x64'
{'_groups': [0, 'initrd', 'system'],
 'cmdline': 'A1 B2 C3',
 'config': 'man/ukify-example.conf',
 'devicetree': None,
 'efi_arch': 'x64',
 'initrd': [PosixPath('initrd1'),
            PosixPath('initrd2'),
            PosixPath('initrd3'),
            PosixPath('/efi/3a9d668b4db749398a4a5e78a03bffa5/6.2.11-300.fc38.x86_64/initrd')],
 'linux': PosixPath('/efi/3a9d668b4db749398a4a5e78a03bffa5/6.2.11-300.fc38.x86_64/linux'),
 'measure': None,
 'os_release': PosixPath('/etc/os-release'),
 'output': 'linux.efi',
 'pcr_banks': ['sha1', 'sha384'],
 'pcr_private_keys': [PosixPath('PRIV.key'),
                      PosixPath('pcr-private-initrd-key.pem'),
                      PosixPath('pcr-private-system-key.pem')],
 'pcr_public_keys': [PosixPath('PUB.key'),
                     PosixPath('pcr-public-initrd-key.pem'),
                     PosixPath('pcr-public-system-key.pem')],
 'pcrpkey': None,
 'phase_path_groups': [None,
                       ['enter-initrd'],
                       ['enter-initrd:leave-initrd',
                        'enter-initrd:leave-initrd:sysinit',
                        'enter-initrd:leave-initrd:sysinit:ready']],
 'sb_cert': PosixPath('mkosi.secure-boot.crt'),
 'sb_key': PosixPath('mkosi.secure-boot.key'),
 'sections': [],
 'sign_kernel': None,
 'signing_engine': None,
 'splash': None,
 'stub': PosixPath('/usr/lib/systemd/boot/efi/linuxx64.efi.stub'),
 'summary': True,
 'tools': None,
 'uname': None}

With --summary, existence of input paths is not checked. I think we'll
want to show them, instead of throwing an error, but in red, similarly to
'bootctl list'.

This also fixes tests which were failing with e.g.
E       FileNotFoundError: [Errno 2] No such file or directory: '/ARG1'
=========================== short test summary info ============================
FAILED ../src/ukify/test/test_ukify.py::test_parse_args_minimal - FileNotFoun...
FAILED ../src/ukify/test/test_ukify.py::test_parse_args_many - FileNotFoundEr...
FAILED ../src/ukify/test/test_ukify.py::test_parse_sections - FileNotFoundErr...
=================== 3 failed, 10 passed, 3 skipped in 1.51s ====================

2 years agotest_ukify: fix two failing tests
Zbigniew Jędrzejewski-Szmek [Fri, 21 Apr 2023 06:32:09 +0000 (08:32 +0200)] 
test_ukify: fix two failing tests

Fixup for 22ad038ac6e4fe5e4a68555f0e70bd0a16fb5616 and
3fc5eed47091363247012454df458e1a3303bf12. It seems that the tests are
not executed properly in CI. Nevertheless, test-ukify appears in logs:

rpm-build:fedora-rawhide-x86_64:
 409/1191 systemd / test-ukify    OK   0.16s

This is strange.

2 years agotest_ukify: fix loop iteration
Zbigniew Jędrzejewski-Szmek [Fri, 21 Apr 2023 06:27:21 +0000 (08:27 +0200)] 
test_ukify: fix loop iteration

We'd try to access 'linux' or 'initrd' after failing to set it.

2 years agomeson: allow building .standalone on demand
Zbigniew Jędrzejewski-Szmek [Fri, 14 Apr 2023 16:19:48 +0000 (18:19 +0200)] 
meson: allow building .standalone on demand

We can always build the standalone version whenever we build the normal version
(the dependencies are the same). In most builds standalone binaries would be
disabled. But it is occasionally useful to have them for testing, so move the
conditional to install:, so the binaries can be build by giving the explicit
target name.

The default of 'build_by_default' for executable() is sadly true (since meson
0.38.0), so need to specify build_by_default: too.

Also add systemd-shutdown.standalone to public_programs for additional testing.

2 years agomeson: avoid building executables that won't be installed
Zbigniew Jędrzejewski-Szmek [Fri, 14 Apr 2023 16:10:58 +0000 (18:10 +0200)] 
meson: avoid building executables that won't be installed

When executable() or custom_target() has install: that is conditional as is
false (i.e. not install:true), it won't be built by default. (build_by_default:
defaults to install:). But if that program is added to public_programs, it will
be build by default because it is pulled in by the test, effectively defeating
the disablement.

While at it, make 'ukify' follow the same pattern as 'kernel-install'.
They will be used later together.

2 years agoukify: add missing header
Zbigniew Jędrzejewski-Szmek [Thu, 13 Apr 2023 15:58:52 +0000 (17:58 +0200)] 
ukify: add missing header

This file is installed, so it should have the long header.

2 years agoukify: use UPPERCASE for parameter names
Zbigniew Jędrzejewski-Szmek [Thu, 13 Apr 2023 15:53:18 +0000 (17:53 +0200)] 
ukify: use UPPERCASE for parameter names

We generally nowadays use UPPERCASE for parameters in variuos help text.
Let's be consistent here too, and also drop duplicated 'usage:':
$ ukify -h
usage: ukify [options…] LINUX INITRD…
       ukify -h | --help

Build and sign Unified Kernel Images

positional arguments:
  LINUX                 vmlinuz file [.linux section]
  INITRD…               initrd files [.initrd section]
...

2 years ago90-loaderentry: make sure that variables are set
Zbigniew Jędrzejewski-Szmek [Thu, 13 Apr 2023 15:50:07 +0000 (17:50 +0200)] 
90-loaderentry: make sure that variables are set

We unconditionally use the variables later on, so let's make sure
that they were passed as expected.

2 years agoMerge pull request #27499 from yuwata/sd-journal-fix-loop
Yu Watanabe [Wed, 3 May 2023 04:30:47 +0000 (13:30 +0900)] 
Merge pull request #27499 from yuwata/sd-journal-fix-loop

sd-journal: check .next_entry_array_offset earlier

2 years agoRevert "sd-journal: introduce simple loop detection for entry array objects" 27499/head
Yu Watanabe [Tue, 2 May 2023 16:30:23 +0000 (01:30 +0900)] 
Revert "sd-journal: introduce simple loop detection for entry array objects"

This reverts commit a8fbcc0e3c033a43e511550052cace6b0dcf3df7.

The commit is not necessary, as the invalid entry array object is
filtered earlier by the previous commit.

2 years agosd-journal: check .next_entry_array_offset earlier
Yu Watanabe [Tue, 2 May 2023 16:29:08 +0000 (01:29 +0900)] 
sd-journal: check .next_entry_array_offset earlier

Then, if it is invalid, refuse to use the entry array object.

Follow-up for a8fbcc0e3c033a43e511550052cace6b0dcf3df7.
Fixes #27489.

2 years agoboot: Use correct memory type for allocations
Jan Janssen [Tue, 2 May 2023 17:41:58 +0000 (19:41 +0200)] 
boot: Use correct memory type for allocations

We were using the wrong memory type when allocating pool memory. This
does not seem to cause a problem on x86, but the kernel will fail to
boot at least on ARM in QEMU.

This is caused by mixing different allocation types which ended up
breaking the kernel or EDK2 during boot services exit. Commit
2f3c3b0bee5534f2338439f04b0aa517479f8b76 appears to fix this boot
failure because it was replacing the gnu-efi xpool_print with xasprintf
thereby unifying the allocation type.
But this same issue can also happen without this fix somehow when the
random-seed logic is in use.

Fixes: #27371
2 years agocore: check for SERVICE_RELOAD_NOTIFY in manager_dbus_is_running
msizanoen1 [Tue, 2 May 2023 09:59:07 +0000 (16:59 +0700)] 
core: check for SERVICE_RELOAD_NOTIFY in manager_dbus_is_running

This ensures that systemd won't erronously disconnect from the system
bus in case a bus recheck is triggered immediately after the bus service
emits `RELOADING=1`.

This fixes an issue where systemd-logind sometimes randomly stops
receiving `UnitRemoved` after a system update.

This also handles SERVICE_RELOAD_SIGNAL just in case somebody ever
creates a D-Bus broker implementation that uses `Type=notify-reload`.

2 years agojournal: handle EADDRNOTAVAIL in two more cases gracefully
Lennart Poettering [Tue, 2 May 2023 10:23:07 +0000 (12:23 +0200)] 
journal: handle EADDRNOTAVAIL in two more cases gracefully

Follow-up for #27488.

2 years agoMerge pull request #27493 from poettering/generate-sym-test-tweaks
Yu Watanabe [Tue, 2 May 2023 15:12:48 +0000 (00:12 +0900)] 
Merge pull request #27493 from poettering/generate-sym-test-tweaks

fixes/additions for generate-sym-test

2 years agoMerge pull request #27492 from poettering/base-filesystem-000
Mike Yuan [Tue, 2 May 2023 12:53:35 +0000 (20:53 +0800)] 
Merge pull request #27492 from poettering/base-filesystem-000

base-filesystem: create /proc, /sys, /dev mount points as 555

2 years agogenerators: skip private tmpfs if /tmp does not exist
Luca Boccassi [Sun, 30 Apr 2023 18:21:23 +0000 (19:21 +0100)] 
generators: skip private tmpfs if /tmp does not exist

When spawning generators within a sandbox we want a private /tmp, but it
might not exist, and on some systems we might be unable to create it
because users want a BTRFS subvolume instead.

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

2 years agotree-wide: Handle EADDRNOTAVAIL as journal corruption
Daan De Meyer [Tue, 2 May 2023 07:16:16 +0000 (09:16 +0200)] 
tree-wide: Handle EADDRNOTAVAIL as journal corruption

Journal corruption is not only indicated by EBADMSG but also by
EADDRNOTAVAIL so treat that as corruption in a few more cases.

2 years agomount-setup: use size_t when iterating through array indexes 27492/head
Lennart Poettering [Tue, 2 May 2023 10:03:32 +0000 (12:03 +0200)] 
mount-setup: use size_t when iterating through array indexes

2 years agobase-filesystem: create /proc, /sys, /dev mount points as 0555
Lennart Poettering [Tue, 2 May 2023 08:44:14 +0000 (10:44 +0200)] 
base-filesystem: create /proc, /sys, /dev mount points as 0555

These inodes are going to be overmounted anyway, hence let's create them
with access mode 555, so that they are as close to being immutable as
regular UNIX access modes allow them to be. In other words: this takes
the "w" mode away for root. This of course usually has little effect --
unless CAP_DAC_OVERRIDE is dropped. But at the very least it makes the
point clear that inodes should be considered immutable.

(I intended to make this 0000 originally, but that doesn't work, as many
tools – including our own – have fallback paths that when they see
ENOENT in /proc/ they can handle this gracefully. But changing the mode
to 000 would turn this to EACCES - something they usually have no
fallback path for)

2 years agogenerate-sym-test: only look in .c and .h files 27493/head
Lennart Poettering [Tue, 2 May 2023 09:22:22 +0000 (11:22 +0200)] 
generate-sym-test: only look in .c and .h files

Otherwise it might find backup files and such, which triggered all kinds
of false positives (at least on my devel machine).

2 years agogenerate-sym-test: search for missing symbols
Lennart Poettering [Tue, 2 May 2023 09:21:23 +0000 (11:21 +0200)] 
generate-sym-test: search for missing symbols

This slightly extends the symbol file test and checks which symbols are
listed in one list but missing in the other. This is tremendously useful
to quickly determine which symbols wheren't exposed properly but should
have been.

(This is is implemented in pure C, no systemd helpers, to ensure we see
libsystemd.so API as any other tool would.)

2 years agodocs: add correct `pacman` command (#27486)
Klaus [Tue, 2 May 2023 09:18:10 +0000 (11:18 +0200)] 
docs: add correct `pacman` command (#27486)

The `pacman` command in order to install packages on Arch in the documentation is invalid.
This PR fixes the command.

2 years agotest: replace sleep with timeout
Yu Watanabe [Tue, 2 May 2023 06:15:30 +0000 (15:15 +0900)] 
test: replace sleep with timeout

If the test environment is too slow, then sleeping 2 seconds may not be
sufficient.

2 years agoMerge pull request #27455 from yuwata/test-lib-sym
Yu Watanabe [Mon, 1 May 2023 19:45:30 +0000 (04:45 +0900)] 
Merge pull request #27455 from yuwata/test-lib-sym

test: check all public functions are listed in .sym file

2 years agoMerge pull request #27442 from DaanDeMeyer/presets
Luca Boccassi [Mon, 1 May 2023 19:10:58 +0000 (20:10 +0100)] 
Merge pull request #27442 from DaanDeMeyer/presets

mkosi: Switch to use mkosi presets with prebuilt initrds

2 years agotest-network: add workaround for bug in iproute2 v6.2.0
Yu Watanabe [Mon, 1 May 2023 15:11:49 +0000 (00:11 +0900)] 
test-network: add workaround for bug in iproute2 v6.2.0

Closes #27473.

2 years agostub: Relocate kernels below 4G for EFI handover
Jan Janssen [Mon, 1 May 2023 09:32:30 +0000 (11:32 +0200)] 
stub: Relocate kernels below 4G for EFI handover

Old kernels can fail to boot when they are located above the 4G
boundary even if they claim to support it.

Fixes: #27472
2 years agoboot: Fix EFI_SIZE_TO_PAGES macro
Jan Janssen [Mon, 1 May 2023 09:31:52 +0000 (11:31 +0200)] 
boot: Fix EFI_SIZE_TO_PAGES macro

2 years agomkosi: Switch to use mkosi presets with prebuilt initrds 27442/head
Daan De Meyer [Tue, 25 Apr 2023 14:04:49 +0000 (16:04 +0200)] 
mkosi: Switch to use mkosi presets with prebuilt initrds

Instead of building the initrds for the mkosi images with dracut,
let's switch to using mkosi presets to build the initrd with mkosi
as well.

This commit splits up our single image build into three separate
mkosi presets:

1. The "base" preset. This image contains systemd and all its runtime
dependencies. The sole purpose of this image is to serve as a base image
for the initrd and the final image. It's also responsible for building
systemd from source with the build script. The results are installed into
the base image. Note that we install the systemd and udev packages into this
image as well to prevent package managers from overriding the systemd we built
from source with the distro packaged systemd if it's pulled in as a dependency
by another package from the initrd or final profiles.
2. The "initrd" preset. This image provides the initrd. It's trivial and does
nothing more than packaging the base image up as a zstd compressed initramfs and
adds /init and /etc/initrd-release symlinks to the image.
3. The "final" preset. This image builds on top of the base image and adds
a kernel and extra packages that are useful for testing and debugging.

We also split out the optional kernel build into a separate set of config files
that are only included if a kernel to build is actually provided.

Note that this commit doesn't really change anything about how mkosi is used.
The commands remain the same, except that mkosi will now build all the presets
in order. "mkosi summary" will show the summary of all the presets. "mkosi qemu,
boot, shell" will always boot the final preset. With "-f", all presets will be
built and the final one is booted. "-i" makes a cache of each preset.

The only thing to keep in mind is that specifying config via the mkosi CLI will
apply to each of the presets. e.g. any extra packages added with "-p" will be
installed in both the initrd and the final image. To apply local configuration
to a single preset, create a file 00-local.conf in
mkosi.presets/<profile>/mkosi.conf.d and put all the preset specific configuration
in there.

2 years agomeson: Search for find program
Daan De Meyer [Mon, 1 May 2023 08:25:18 +0000 (10:25 +0200)] 
meson: Search for find program

find is required by a few of the unit tests so let's make sure its
available when configuring the build.

2 years agomeson: Search for diff program
Daan De Meyer [Thu, 27 Apr 2023 14:37:39 +0000 (16:37 +0200)] 
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.

2 years agoMerge pull request #27458 from mrc0mmand/test-corrupted-journals
Yu Watanabe [Mon, 1 May 2023 10:14:22 +0000 (19:14 +0900)] 
Merge pull request #27458 from mrc0mmand/test-corrupted-journals

test: test journalctl with corrupted journals

2 years agotest: test journalctl with corrupted journals 27458/head
Frantisek Sumsal [Sat, 29 Apr 2023 10:01:37 +0000 (12:01 +0200)] 
test: test journalctl with corrupted journals

Last month I monkey-patched journald to produce a small (64K) but valid
journal and used that as an input to four AFL fuzzers. After a month it
generated quite a nice corpora (4738 test cases) and after filtering
and minimizing it I was left with 619 unique journals with various
levels of corruption that probe the journal code.

It seems to detect past issues like systemd#26567, etc.

2 years agotest: clean up the test script a bit
Frantisek Sumsal [Wed, 26 Apr 2023 12:56:47 +0000 (14:56 +0200)] 
test: clean up the test script a bit

2 years agosd-journal: introduce simple loop detection for entry array objects
Yu Watanabe [Mon, 1 May 2023 05:18:08 +0000 (14:18 +0900)] 
sd-journal: introduce simple loop detection for entry array objects

If .next_entry_array_offset points to one of the previous entry or the
self entry, then the loop for entry array objects may run infinitely.
Let's assume that the offsets of each entry array object are in
increasing order, and check that in loop.

Fixes #27470.

2 years agotest: also test all _public_ functions are listed in .sym files 27455/head
Yu Watanabe [Sat, 29 Apr 2023 04:56:40 +0000 (13:56 +0900)] 
test: also test all _public_ functions are listed in .sym files

Co-authored-by: Frantisek Sumsal <frantisek@sumsal.cz>
2 years agosd-journal: tighten variable scope
Yu Watanabe [Mon, 1 May 2023 05:16:43 +0000 (14:16 +0900)] 
sd-journal: tighten variable scope

2 years agosd-journal: read entry array object again
Yu Watanabe [Mon, 1 May 2023 05:12:38 +0000 (14:12 +0900)] 
sd-journal: read entry array object again

Otherwise, the object may be invalidated by the previous call of
journal_file_move_to_object().

2 years agosd-journal: check validity of object type more strictly
Yu Watanabe [Mon, 1 May 2023 03:54:15 +0000 (12:54 +0900)] 
sd-journal: check validity of object type more strictly

Otherwise, the object with invalid type may pass check_object_header()
when the requested type is OBJECT_UNUSED.

2 years agosd-journal: add _OBJECT_TYPE_INVALID as usual
Yu Watanabe [Mon, 1 May 2023 03:52:50 +0000 (12:52 +0900)] 
sd-journal: add _OBJECT_TYPE_INVALID as usual

2 years agosd-journal: align table
Yu Watanabe [Mon, 1 May 2023 03:50:30 +0000 (12:50 +0900)] 
sd-journal: align table

2 years agosd-journal: check that the journal file is not stored in .newest_by_boot_id on free
Yu Watanabe [Sat, 29 Apr 2023 22:02:34 +0000 (07:02 +0900)] 
sd-journal: check that the journal file is not stored in .newest_by_boot_id on free

2 years agosd-journal: unset prioq index on failure
Yu Watanabe [Sat, 29 Apr 2023 22:00:31 +0000 (07:00 +0900)] 
sd-journal: unset prioq index on failure

Otherwise, potentially, the assertion in
journal_file_unlink_newest_by_bood_id() will be triggered.

2 years agosd-journal: fix use-after-free
Yu Watanabe [Sat, 29 Apr 2023 21:57:49 +0000 (06:57 +0900)] 
sd-journal: fix use-after-free

As commented in the code, we need to replace the pointer to the key,
hence, hashmap_replace() must be used, instead of hashmap_update().

Fixes #27459.

2 years agotpm2: move openssl-required ifdef code out of policy-building function
Dan Streetman [Thu, 8 Dec 2022 21:57:47 +0000 (16:57 -0500)] 
tpm2: move openssl-required ifdef code out of policy-building function

2 years agohwdb: add hardware rfkill key for Dell Latitude E6* models (#27462)
don bright [Sun, 30 Apr 2023 03:33:13 +0000 (22:33 -0500)] 
hwdb: add hardware rfkill key for Dell Latitude E6* models (#27462)

Hello

This pull req is adapting pull req #5772 (which fixed issue #5047), for the very similar computer Dell Latitude E6420 which has the same problem with the hardware switch to toggle wifi (aka rfkill). The symptom is the following repeated msgs in dmesg

[  309.010284] atkbd serio0: Use 'setkeycodes e008 <keycode>' to make it known.
[  309.016020] atkbd serio0: Unknown key pressed (translated set 2, code 0x88 on isa0060/serio0).

Adding this line to include E6 models causes these messages to stop showing in dmesg

Thank you

2 years agoman: clarify RoutingPolicyRule.TypeOfService docs
Brad Fitzpatrick [Mon, 17 Apr 2023 21:36:33 +0000 (14:36 -0700)] 
man: clarify RoutingPolicyRule.TypeOfService docs

2 years agoMerge pull request #27461 from bluca/coredumpctl_completion
Yu Watanabe [Sat, 29 Apr 2023 19:28:45 +0000 (04:28 +0900)] 
Merge pull request #27461 from bluca/coredumpctl_completion

coredumpctl: fix bash completion

2 years agocoredumpctl: add --file/--root/--image to bash completion 27461/head
Luca Boccassi [Tue, 25 Apr 2023 14:30:34 +0000 (15:30 +0100)] 
coredumpctl: add --file/--root/--image to bash completion

2 years agocoredumpctl: fix bash completion matching
Luca Boccassi [Tue, 25 Apr 2023 14:30:00 +0000 (15:30 +0100)] 
coredumpctl: fix bash completion matching

When multi-word matching string is quoted, __contains_word compares
it as a whole to the passed option, so it doesn't work.

2 years agotest: make sure the test units have a `test-` prefix
Frantisek Sumsal [Sat, 29 Apr 2023 07:44:03 +0000 (09:44 +0200)] 
test: make sure the test units have a `test-` prefix

So when collecting coverage the test-.service dropin works as
expected.

Follow-up to 969f5f3cea.

2 years agotest: match all messages with the FILE field
Frantisek Sumsal [Sat, 29 Apr 2023 07:33:18 +0000 (09:33 +0200)] 
test: match all messages with the FILE field

As the systemd-pstore process is quite short lived, it might sometimes
lack the necessary metadata to make matching against a unit or a syslog
tag work. Since we already use a cursor file to make the matching window
small as possible, let's just drop the unit match completely and hope
for the best.

Resolves: #27453

2 years agolibsystemd: add missing _public_ attributes
Yu Watanabe [Sat, 29 Apr 2023 12:05:40 +0000 (21:05 +0900)] 
libsystemd: add missing _public_ attributes

2 years agolibsystemd: drop _public_ attribute for non-exported functions
Yu Watanabe [Sat, 29 Apr 2023 04:55:55 +0000 (13:55 +0900)] 
libsystemd: drop _public_ attribute for non-exported functions

2 years agoMerge pull request #27451 from yuwata/core-path-trigger-notify
Luca Boccassi [Sat, 29 Apr 2023 11:35:24 +0000 (12:35 +0100)] 
Merge pull request #27451 from yuwata/core-path-trigger-notify

core/path: do not install new job in .trigger_notify()

2 years agomissing_fs: also define struct file_clone_range
Yu Watanabe [Sat, 29 Apr 2023 02:51:57 +0000 (11:51 +0900)] 
missing_fs: also define struct file_clone_range

Follow-up for b640e274a7c363a2b6394c9dce5671d9404d2e2a.

Addresses https://github.com/systemd/systemd/commit/b640e274a7c363a2b6394c9dce5671d9404d2e2a#r110996661.

2 years agotest: add tests for "systemctl stop" vs triggering by path unit 27451/head
Yu Watanabe [Fri, 28 Apr 2023 19:39:46 +0000 (04:39 +0900)] 
test: add tests for "systemctl stop" vs triggering by path unit

2 years agotest: create temporary units under /run
Yu Watanabe [Sat, 29 Apr 2023 00:10:11 +0000 (09:10 +0900)] 
test: create temporary units under /run

2 years agocore/path: do not enqueue new job in .trigger_notify callback
Yu Watanabe [Fri, 28 Apr 2023 19:31:53 +0000 (04:31 +0900)] 
core/path: do not enqueue new job in .trigger_notify callback

Otherwise,
1. X.path triggered X.service, and the service has waiting start job,
2. systemctl stop X.service
3. the waiting start job is cancelled to install new stop job,
4. path_trigger_notify() is called, and may reinstall new start job,
5. the stop job cannot be installed, and triggeres assertion.

So, instead, let's add a defer event source, then enqueue the new start
job after the stop (or any other type) job finished.

Fixes https://github.com/systemd/systemd/issues/24577#issuecomment-1522628906.

2 years agocore/path: align table
Yu Watanabe [Fri, 28 Apr 2023 19:30:32 +0000 (04:30 +0900)] 
core/path: align table

2 years agopid1: unify implemenation of /run/ disk space safety check a bit
Lennart Poettering [Fri, 28 Apr 2023 14:14:32 +0000 (16:14 +0200)] 
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.

2 years agocore/systemctl: when switching root default to /sysroot/
Lennart Poettering [Fri, 28 Apr 2023 14:56:39 +0000 (16:56 +0200)] 
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).

2 years agolibsystemd: Add missing memory pressure functions to public symbols
Daan De Meyer [Fri, 28 Apr 2023 14:54:57 +0000 (16:54 +0200)] 
libsystemd: Add missing memory pressure functions to public symbols

2 years agoMerge pull request #27445 from poettering/reflink-fix
Mike Yuan [Fri, 28 Apr 2023 17:33:21 +0000 (01:33 +0800)] 
Merge pull request #27445 from poettering/reflink-fix

remove duplication reflink ioctl invocation

2 years agosystemctl: rework 'if' to 'switch' statement
Lennart Poettering [Fri, 28 Apr 2023 14:30:32 +0000 (16:30 +0200)] 
systemctl: rework 'if' to 'switch' statement

2 years agoMerge pull request #27437 from mrc0mmand/pstore
Luca Boccassi [Fri, 28 Apr 2023 15:14:09 +0000 (16:14 +0100)] 
Merge pull request #27437 from mrc0mmand/pstore

test: add a couple of tests for systemd-pstore

2 years agocopy: shortcut reflink_range() to reflink() in some cases 27445/head
Lennart Poettering [Fri, 28 Apr 2023 13:16:00 +0000 (15:16 +0200)] 
copy: shortcut reflink_range() to reflink() in some cases

2 years agocopy: don't call clone ioctls twice
Lennart Poettering [Fri, 28 Apr 2023 13:10:24 +0000 (15:10 +0200)] 
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.

2 years agotest: add a couple of tests for systemd-pstore 27437/head
Frantisek Sumsal [Thu, 27 Apr 2023 21:17:52 +0000 (23:17 +0200)] 
test: add a couple of tests for systemd-pstore

2 years agoMerge pull request #27440 from yuwata/reflink-follow-ups
Luca Boccassi [Fri, 28 Apr 2023 10:34:41 +0000 (11:34 +0100)] 
Merge pull request #27440 from yuwata/reflink-follow-ups

copy: follow ups for reflink()

2 years agopstore: avoid opening the dmesg.txt file if not requested
Frantisek Sumsal [Fri, 28 Apr 2023 09:50:33 +0000 (11:50 +0200)] 
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.
```

2 years agonetwork-generator: shorten code a bit
Yu Watanabe [Fri, 28 Apr 2023 05:02:42 +0000 (14:02 +0900)] 
network-generator: shorten code a bit

2 years agoMerge pull request #27424 from dtardon/auto-cleanup
Yu Watanabe [Fri, 28 Apr 2023 09:46:36 +0000 (18:46 +0900)] 
Merge pull request #27424 from dtardon/auto-cleanup

More automatic cleanup

2 years agopstore: explicitly set the base when converting record ID
Frantisek Sumsal [Fri, 28 Apr 2023 09:09:22 +0000 (11:09 +0200)] 
pstore: explicitly set the base when converting record ID

2 years agologind-session-dbus: use _cleanup_ 27424/head
David Tardon [Fri, 21 Apr 2023 13:53:02 +0000 (15:53 +0200)] 
logind-session-dbus: use _cleanup_

2 years agologind-session-device: modernize session_device_free()
David Tardon [Fri, 21 Apr 2023 13:50:21 +0000 (15:50 +0200)] 
logind-session-device: modernize session_device_free()

2 years agohomed-manager-bus: use _cleanup_
David Tardon [Fri, 21 Apr 2023 13:30:45 +0000 (15:30 +0200)] 
homed-manager-bus: use _cleanup_

2 years agotransaction: make transaction_free() static
David Tardon [Fri, 28 Apr 2023 07:28:25 +0000 (09:28 +0200)] 
transaction: make transaction_free() static

... as it's not needed outside transaction.c anymore.

2 years agomanager: use _cleanup_ in manager_propagate_reload()
David Tardon [Fri, 21 Apr 2023 13:15:38 +0000 (15:15 +0200)] 
manager: use _cleanup_ in manager_propagate_reload()

2 years agomanager: use _cleanup_ in manager_add_job()
David Tardon [Fri, 21 Apr 2023 13:14:17 +0000 (15:14 +0200)] 
manager: use _cleanup_ in manager_add_job()

2 years agotransaction: introduce transaction_abort_and_free()
David Tardon [Fri, 21 Apr 2023 13:13:35 +0000 (15:13 +0200)] 
transaction: introduce transaction_abort_and_free()

Will be used in following commits.

2 years agomissing_fs: mention commit hash and version of ioctl commands introduced 27440/head
Yu Watanabe [Fri, 28 Apr 2023 05:18:48 +0000 (14:18 +0900)] 
missing_fs: mention commit hash and version of ioctl commands introduced

2 years agocopy: rename reflink_full() -> reflink_range()
Yu Watanabe [Fri, 28 Apr 2023 05:05:29 +0000 (14:05 +0900)] 
copy: rename reflink_full() -> reflink_range()

The commit b640e274a7c363a2b6394c9dce5671d9404d2e2a 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.

2 years agoxdg-autostart-service: handle gnome autostart phase better on other desktops
David Edmundson [Wed, 8 Feb 2023 13:28:50 +0000 (13:28 +0000)] 
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>
2 years agocopy: Introduce reflink() and reflink_full()
Daan De Meyer [Thu, 27 Apr 2023 18:37:50 +0000 (20:37 +0200)] 
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.

2 years agotransaction: modernize transaction_free()
David Tardon [Fri, 21 Apr 2023 13:06:28 +0000 (15:06 +0200)] 
transaction: modernize transaction_free()

2 years agoinitctl: use _cleanup_
David Tardon [Fri, 21 Apr 2023 13:34:11 +0000 (15:34 +0200)] 
initctl: use _cleanup_