Commit Graph
43182 Commits
Author SHA1 Message Date
Daan De Meyer fecbce1fc6 sulogin: Read SYSTEMD_SULOGIN_FORCE from kernel cmdline
This allows setting it on the kernel cmdline and having it work
automatically without having to write any dropins or such.

Also enable the option in mkosi so that we can debug the initrd
properly with a locked root account.
2023-05-13 09:16:55 +02:00
Luca Boccassi 27cead47be Merge pull request #27633 from DaanDeMeyer/repart-dropin
repart: Make sure we look up dropin files in the root directory
2023-05-12 21:29:38 +01:00
Daan De Meyer 34f2fd5096 repart: Make sure we look up dropin files in the root directory 2023-05-12 17:52:47 +02:00
Daan De Meyer 947f59ba2b conf-parser: Add root argument to config_parse_many() 2023-05-12 17:52:32 +02:00
Frantisek Sumsal e8dba80626 core: fix memory leak during deserialization
when activation-details-unit-name is encountered multiple times.

Resolves: #27623
2023-05-13 00:42:25 +09:00
Daan De Meyer 9b05a3715b repart: Make sure r is declared last 2023-05-12 17:38:00 +02:00
Daan De Meyer 4b047310f6 repart: Read arguments directly instead of passing them in 2023-05-12 17:38:00 +02:00
Daan De Meyer 153d5dfd87 core: Try to initialize TERM from systemd.tty.term.console as well
We already have the systemd.tty.xxx kernel cmdline arguments for
configuring tty's for services, let's make sure the term cmdline
argument applies to pid1 as well.
2023-05-12 08:38:20 +02:00
Daan De Meyer 32b0be0eb8 Merge pull request #27565 from yuwata/static-destruct
static-destruct: support clearing array on exit
2023-05-12 08:36:43 +02:00
Daan De Meyer 2bc161dddb mkfs-util: Add quiet argument to make_filesystem()
We default to quiet operation everywhere except for repart, where
we disable quiet and have the mkfs tools write to stdout.

We also make sure --quiet or equivalent is implemented for all mkfs
tools.
2023-05-12 07:51:50 +02:00
Daan De Meyer aaa27e2e21 core: Check if any init exists before switching root
If we switch root and can't execute an init program afterwards, we're
completely stuck as we can't go back to the initramfs to start
emergency.service as it will have been completely removed by the switch
root operation.

To prevent leaving users with a completely undebuggable system, let's
at least check before we switch root whether at least one of the init
programs we might want to execute actually exist, and fail early if
none of them exists.
2023-05-12 07:48:50 +02:00
Daan De Meyer 3f92250f4c core: Make sure systemctl exit <X> works outside of a container
When running in a VM, we now support propagating the exit status
via a vsock notify socket, so drop the restrictions on propagating
an exit status when not in a container to make sure this works
properly.
2023-05-12 07:48:29 +02:00
Yu Watanabe f466e828db Merge pull request #27618 from DaanDeMeyer/fstab-generator
Fstab generator fixes
2023-05-12 04:23:54 +09:00
Yu Watanabe db4afb95c2 Merge pull request #27611 from yuwata/core-mount-escape-utf8
core/mount: escape invalid utf8 chars
2023-05-12 01:40:32 +09:00
Daan De Meyer 32fe629abc fstab-generator: Fix log message 2023-05-11 14:44:16 +02:00
Daan De Meyer 338da50141 fstab-generator: Unset kernel cmdline options if empty value is given 2023-05-11 14:44:16 +02:00
Daan De Meyer 200268c6db fstab-generator: Take systemd.verity= into account
Disable verity logic if systemd.verity= switch is disabled.
2023-05-11 14:44:14 +02:00
Frantisek Sumsal b0582f6b63 cryptenroll: actually allow using multiple "special" strings when wiping
The systemd-cryptenroll man page states:

    Takes a comma separated list of numeric slot indexes, or the special
    strings ..., or any combination of these strings or numeric
    indexes, in which case all slots matching either are wiped.

but we'd allow only one special string at any given time as the value
was not ORed when assigning. So, for example, --wipe=recovery,password
would actually become --wipe=password, etc.
2023-05-11 13:12:08 +01:00
Yu Watanabe 4804da5853 core/mount: escape invalid UTF8 char in dbus reply
When What= or Options= may contain invalid UTF8 chars.

Replaces aaf7b0e411 (#27541).
2023-05-11 19:25:38 +09:00
Yu Watanabe bcf58ff559 Revert "core/mount: replace invalid UTF-8 code points in "what" and "options""
This reverts commit aaf7b0e411.

Not only /proc/mountinfo, .mount units not started yet may contain
invalid UTF-8 chars.
2023-05-11 19:24:42 +09:00
Luca Boccassi fcb4ba6c14 Merge pull request #27539 from esposem/ukify_pesign
ukify: support pesign as alternative to sbsign
2023-05-11 10:45:59 +01:00
Yu Watanabe d698679112 Merge pull request #27596 from yuwata/drop-pure
drop two more inappropriate _pure_ attributes and several cleanups
2023-05-11 16:49:40 +09:00
Daan De Meyer 1fd5ec5697 tmpfiles: Add merge support for copy files action
If '+' is specified with 'C', let's merge the tree with any existing
tree.
2023-05-10 18:08:07 +02:00
Daan De Meyer e57b7020d2 repart: Fix deny list logic
Until now, we always excluded the top level directories that were
covered by child partition mount points, regardless of the source
directory and the target directory of the copy files operation.
This means that even if we were populating a XBOOTLDR partition, if
there was an EFI partition in the image, we'd exclude /boot
unconditionally, leading to the XBOOTLDR partition to be empty.

Also, because of the same cause, if we were copying a nested source
directory (e.g. /abc/def) to the root directory in the root
partition, if /abc/def/usr existed and was populated with files and
directories, the root partition would have those files under /usr,
even if a /usr partition was defined.

To fix these issues, instead of unconditionally excluding the top
level partition mount points under <source>, let's make sure that
when we're copying files from any source directory to the root
directory of a root partition, that we exclude the partition mount
point directories under the source directory instead of the top
level ones.
2023-05-10 18:07:47 +02:00
Emanuele Giuseppe Esposito 4e906270a3 src/ukify/test/test_ukify: fix skipped tests
Some tests are skipped because initrd extracted from bootctl
is "/boot/initramfs-5.14.0-284.el9.x86_64.img $tuned_initrd"
and not just "/boot/initramfs-5.14.0-284.el9.x86_64.img".
Therefore split and remove the additional garbage.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2023-05-10 09:20:46 -04:00
Emanuele Giuseppe Esposito ff5618c7c0 src/ukify/test/test_ukify: add pesign unit test
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2023-05-10 09:20:46 -04:00
Emanuele Giuseppe Esposito c1e8d1727b ukify: support pesign as alternative to sbsign
sbsign is not available everywhere, for example RHEL does not have it.
Add pesign as alternative to it.

pesign will use options "--secureboot-certificate-name" (mandatory) and
"--secureboot-certificate-dir" (optional), while sbsign will use
"--secureboot-private-key" and "--secureboot-certificate".

By default, use sbsign. If no key/cert is provided or sbsign is not found,
try pesign.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2023-05-10 09:18:27 -04:00
Emanuele Giuseppe Esposito e673c5c2d9 ukify: typo in doc and print when package is missing
If a package is missing, a subprocess is started with None as
command argument. Error raised by subprocess is therefore not helpful
at all to understand what needs to be done to fix that error.

Also fix doc since systemd-stub will look for .cmdline files, and not
.cmdline.efi files.

Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
2023-05-10 09:18:25 -04:00
Yu Watanabe 39a39f18f2 udev: do not set ID_PATH and by-path symlink for nvmf disks
Prompted by #27391.
2023-05-10 19:42:49 +08:00
Yu Watanabe 6112c86139 core: replace hashmap_get() with hashmap_contains() where appropriate 2023-05-10 15:06:44 +09:00
Yu Watanabe 735f0645db core: drop unused argument 2023-05-10 15:06:39 +09:00
Yu Watanabe fcd7e0b7ed core: several cleanups for job_get_timeout()
- add missing assertion,
- rename the argument for storing result,
- always initialize result on success.
2023-05-10 15:06:39 +09:00
Yu Watanabe bc52801034 tree-wide: drop _pure_ attribute from non-pure functions
Prompted by #27595.
Follow-ups for 6723c28f36.
2023-05-10 15:06:24 +09:00
Sam James eb29296937 dirent: conditionalize dirent assert based on dirent64 existence
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: https://github.com/systemd/systemd/pull/25809
2023-05-10 15:05:18 +09:00
Mike Yuan 8707dcdf3b network/tc: rename settings in log messages too
Follow-up for c03ef420fa
2023-05-10 14:21:28 +09:00
Xi Ruoyao 6723c28f36 sd-bus: bus_message_type_from_string is not pure
GCC document [1] says:

    The pure attribute prohibits a function from modifying the state
    of the program that is observable by means other than inspecting
    the function’s return value.

And there is an example:

    `int hash (char *) __attribute__ ((pure));`
    ... Even though hash takes a non-const pointer argument it must
    not modify the array it points to, ...

But we are modifying the object pointed to by the pointer u, which is
clearly a violation of the semantic of pure.

With -ftrivial-auto-var-init (enabled by -Dmode=release), on some
targets (GCC 12.2 on AArch64 and GCC 13.1 on x86_64) performs an
optimization: as the variable "u" in bus_match_parse has been
zero-initialized (by the -ftrivial-auto-var-init option) and never
modified (because a "pure" bus_message_type_from_string is not allowed
to modify it), "u" will be always 0.

Then 0 is used to initialize .value_u8 field of struct
bus_match_component.  This then causes a infinite event loop, so
"systemctl restart" never stops, and pam_systemd timeouts communicating
with logind, etc.

So we should remove the "pure" attribute here.

Fixes #26395.

[1]:https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute
2023-05-10 14:21:01 +09:00
Yu Watanabe 18449960b9 Merge pull request #27597 from mrc0mmand/more-test-shenanigans
test: slightly extend systemd-cryptenroll coverage
2023-05-10 08:16:29 +09:00
Michal Sekletar aaf7b0e411 core/mount: replace invalid UTF-8 code points in "what" and "options"
Previously, these strings were copied w/o any modification. However, if
mount table contained e.g. remote fs mount like NFS or CIFS that was
mounted from server running with non UTF-8 locale then those strings
might have contained some non UTF-8 characters.

If then client asked about status of such mount unit we tried to forward
these non UTF-8 strings over D-Bus. That is the violation of the
protocol and we ended up kicked from the bus.
2023-05-10 00:01:32 +01:00
Frantisek Sumsal 0e43ab6d24 cryptenroll: fix an assertion with weak passwords
Passing 0 to log_xxx_errno() leads to an assertion, so let's not do that:

$ NEWPASSWORD="" build-san/systemd-cryptenroll --unlock-key-file=/tmp/password --password "$img"
/tmp/password has 0644 mode that is too permissive, please adjust the ownership and access mode.
Assertion '(_error) != 0' failed at src/cryptenroll/cryptenroll-password.c:164, function enroll_password(). Aborting.
Aborted (core dumped)
2023-05-09 22:17:15 +02:00
Yu Watanabe 251ca88230 sd-dhcp-client: client ID always has non-zero data
Follow-up for f04c991a2f.
Fixes CID#1510978.
2023-05-09 14:41:55 +01:00
Yu Watanabe c093bfe0ad Merge pull request #27534 from keszybz/deperlify
Rewrite udev-test.pl in Python
2023-05-09 18:06:51 +09:00
Yu Watanabe 9695b0c01b static-destruct: introduce STATIC_ARRAY_DESTRUCTOR_REGISTER() 2023-05-09 17:53:42 +09:00
Yu Watanabe 555ead8985 static-destruct: several cleanups
No functional changes, preparation for later commits.
2023-05-09 17:53:42 +09:00
Yu Watanabe 3facdc7da8 memory-util: make ArrayCleanup passed to array_cleanup() const
Should not change any behavior, preparation for later commits.
2023-05-09 17:53:42 +09:00
Zbigniew Jędrzejewski-Szmek 0454cf05d3 test: rework how udev-test is invoked
As part of the build, we would populate build/test/sys/ using
sys-script.py, and then udev-test.p[ly] would create a tmpfs instance
on build/test/tmpfs and copy the sys tree to build/test/tmpfs/sys.

Also, we had udev-test.p[ly] which called test-udev. test-udev was
marked as a manual test and installed, but neither udev-test.p[ly] or
sys-script.py were.

test-udev is renamed to udev-rule-runner, which reduces confusion and
frees up the test-udev name. udev-test.py is renamed to test-udev.py.
All three files are now installed.

test-udev.py is modified to internally call sys-script.py to set up the
sys tree. Copying and creating it from scratch should take the same
amount of time. We avoid having a magic directory, everything is now
done underneath a temporary directory.

test-udev.py is now a normal installed test, and run-unit-tests.py will
pick it up. When test-udev.py is invoked from meson, the path to
udev-rule-runner is passed via envvar; when it is invoked via
run-unit-tests.py or directly, it looks for udev-rule-runner in a relative
path.

The goal of this whole change is to let Debian drop the 'udev' test.
It called sys-script.py and udev-test.pl from the source directory and
had to recreate a bunch of the logic. Now test-udev.py will now be called
via 'upstream'.
2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek 083e2ba445 pid1: drop duplicate include 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek 7d3d147c4a test_ukify: print message when skipping whole test file 2023-05-09 08:11:10 +02:00
Zbigniew Jędrzejewski-Szmek fb5578b3c3 test-udev: add an optional timeout argument
The tests wants to call some workers with a delay. This implements the delay
directly in test-udev so that the caller can be simplified.

Note that the argument is to be used by the other test file, so this is
purposefully implemented in a simple way.
2023-05-09 08:10:20 +02:00
Yu Watanabe d94027ad16 bus-util: drop unnecessary continue 2023-05-09 08:08:53 +09:00
Daan De Meyer d0287dc1d7 test-journal-verify: Use a more thorough machine ID check
Let's not only check if the file exists but also check if it contains
a valid machine ID.
2023-05-09 06:09:43 +09:00