1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-25 23:21:33 +03:00
Commit Graph

41081 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
8608fef36c
Merge pull request #25437 from YHNdnzj/systemctl-disable-warn-statically-enabled-services
systemctl: warn if trying to disable a unit with no install info
2022-12-05 10:27:24 +01:00
Daan De Meyer
2877b14720 chase-symlinks: Fix regression from 5bc244aaa9
Previously, chase_symlinks() always returned an absolute path, which
changed after 5bc244aaa9. This commit
fixes chase_symlinks() so it returns absolute paths all the time again.
2022-12-05 09:27:58 +01:00
Eric DeVolder
5fbaa75707 pstore: fixes for dmesg.txt reconstruction
This patch fixes problems with the re-assembly of the dmesg
from the records stored in pstore.

The current code simply ignores the last 6 characters of the
file name to form a base record id, which then groups any
pstore files with this base id into the reconstructed dmesg.txt.
This approach fails when the following oops generated the
following in pstore:

 -rw-------.  1 root root  1808 Oct 27 22:07 dmesg-efi-166692286101001
 -rw-------.  1 root root  1341 Oct 27 22:07 dmesg-efi-166692286101002
 -rw-------.  1 root root  1812 Oct 27 22:07 dmesg-efi-166692286102001
 -rw-------.  1 root root  1820 Oct 27 22:07 dmesg-efi-166692286102002
 -rw-------.  1 root root  1807 Oct 27 22:07 dmesg-efi-166692286103001
 -rw-------.  1 root root  1791 Oct 27 22:07 dmesg-efi-166692286103002
 -rw-------.  1 root root  1773 Oct 27 22:07 dmesg-efi-166692286104001
 -rw-------.  1 root root  1801 Oct 27 22:07 dmesg-efi-166692286104002
 -rw-------.  1 root root  1821 Oct 27 22:07 dmesg-efi-166692286105001
 -rw-------.  1 root root  1809 Oct 27 22:07 dmesg-efi-166692286105002
 -rw-------.  1 root root  1804 Oct 27 22:07 dmesg-efi-166692286106001
 -rw-------.  1 root root  1817 Oct 27 22:07 dmesg-efi-166692286106002
 -rw-------.  1 root root  1792 Oct 27 22:07 dmesg-efi-166692286107001
 -rw-------.  1 root root  1810 Oct 27 22:07 dmesg-efi-166692286107002
 -rw-------.  1 root root  1717 Oct 27 22:07 dmesg-efi-166692286108001
 -rw-------.  1 root root  1808 Oct 27 22:07 dmesg-efi-166692286108002
 -rw-------.  1 root root  1764 Oct 27 22:07 dmesg-efi-166692286109001
 -rw-------.  1 root root  1765 Oct 27 22:07 dmesg-efi-166692286109002
 -rw-------.  1 root root  1796 Oct 27 22:07 dmesg-efi-166692286110001
 -rw-------.  1 root root  1816 Oct 27 22:07 dmesg-efi-166692286110002
 -rw-------.  1 root root  1793 Oct 27 22:07 dmesg-efi-166692286111001
 -rw-------.  1 root root  1751 Oct 27 22:07 dmesg-efi-166692286111002
 -rw-------.  1 root root  1813 Oct 27 22:07 dmesg-efi-166692286112001
 -rw-------.  1 root root  1786 Oct 27 22:07 dmesg-efi-166692286112002
 -rw-------.  1 root root  1754 Oct 27 22:07 dmesg-efi-166692286113001
 -rw-------.  1 root root  1752 Oct 27 22:07 dmesg-efi-166692286113002
 -rw-------.  1 root root  1803 Oct 27 22:07 dmesg-efi-166692286114001
 -rw-------.  1 root root  1759 Oct 27 22:07 dmesg-efi-166692286114002
 -rw-------.  1 root root  1805 Oct 27 22:07 dmesg-efi-166692286115001
 -rw-------.  1 root root  1787 Oct 27 22:07 dmesg-efi-166692286115002
 -rw-------.  1 root root  1815 Oct 27 22:07 dmesg-efi-166692286116001
 -rw-------.  1 root root  1771 Oct 27 22:07 dmesg-efi-166692286116002
 -rw-------.  1 root root  1816 Oct 27 22:07 dmesg-efi-166692286117002
 -rw-------.  1 root root  1388 Oct 27 22:07 dmesg-efi-166692286701003
 -rw-------.  1 root root  1824 Oct 27 22:07 dmesg-efi-166692286702003
 -rw-------.  1 root root  1795 Oct 27 22:07 dmesg-efi-166692286703003
 -rw-------.  1 root root  1805 Oct 27 22:07 dmesg-efi-166692286704003
 -rw-------.  1 root root  1813 Oct 27 22:07 dmesg-efi-166692286705003
 -rw-------.  1 root root  1821 Oct 27 22:07 dmesg-efi-166692286706003
 -rw-------.  1 root root  1814 Oct 27 22:07 dmesg-efi-166692286707003
 -rw-------.  1 root root  1812 Oct 27 22:07 dmesg-efi-166692286708003
 -rw-------.  1 root root  1769 Oct 27 22:07 dmesg-efi-166692286709003
 -rw-------.  1 root root  1820 Oct 27 22:07 dmesg-efi-166692286710003
 -rw-------.  1 root root  1755 Oct 27 22:07 dmesg-efi-166692286711003
 -rw-------.  1 root root  1790 Oct 27 22:07 dmesg-efi-166692286712003
 -rw-------.  1 root root  1756 Oct 27 22:07 dmesg-efi-166692286713003
 -rw-------.  1 root root  1763 Oct 27 22:07 dmesg-efi-166692286714003
 -rw-------.  1 root root  1791 Oct 27 22:07 dmesg-efi-166692286715003
 -rw-------.  1 root root  1775 Oct 27 22:07 dmesg-efi-166692286716003
 -rw-------.  1 root root  1820 Oct 27 22:07 dmesg-efi-166692286717003

The "reconstructed" dmesg.txt that resulted from the above contained
the following (ignoring actual contents, just providing the Part info):

 Emergency#3 Part17
 Emergency#3 Part16
 Emergency#3 Part15
 Emergency#3 Part14
 Emergency#3 Part13
 Emergency#3 Part12
 Emergency#3 Part11
 Emergency#3 Part10
 Emergency#3 Part9
 Emergency#3 Part8
 Emergency#3 Part7
 Emergency#3 Part6
 Emergency#3 Part5
 Emergency#3 Part4
 Emergency#3 Part3
 Emergency#3 Part2
 Emergency#3 Part1
 Panic#2 Part17
 Panic#2 Part16
 Oops#1 Part16
 Panic#2 Part15
 Oops#1 Part15
 Panic#2 Part14
 Oops#1 Part14
 Panic#2 Part13
 Oops#1 Part13
 Panic#2 Part12
 Oops#1 Part12
 Panic#2 Part11
 Oops#1 Part11
 Panic#2 Part10
 Oops#1 Part10
 Panic#2 Part9
 Oops#1 Part9
 Panic#2 Part8
 Oops#1 Part8
 Panic#2 Part7
 Oops#1 Part7
 Panic#2 Part6
 Oops#1 Part6
 Panic#2 Part5
 Oops#1 Part5
 Panic#2 Part4
 Oops#1 Part4
 Panic#2 Part3
 Oops#1 Part3
 Panic#2 Part2
 Oops#1 Part2
 Panic#2 Part1
 Oops#1 Part1

The above is a interleaved mess of three dmesg dumps.

This patch fixes the above problems, and simplifies the dmesg
reconstruction process. The code now distinguishes between
records on EFI vs ERST, which have differently formatted
record identifiers. Using knowledge of the format of the
record ids allows vastly improved reconstruction process.

With this change in place, the above pstore records now
result in the following:

 # ls -alR /var/lib/systemd/pstore
 1666922861:
 total 8
 drwxr-xr-x. 4 root root   28 Nov 18 14:58 .
 drwxr-xr-x. 7 root root  144 Nov 18 14:58 ..
 drwxr-xr-x. 2 root root 4096 Nov 18 14:58 001
 drwxr-xr-x. 2 root root 4096 Nov 18 14:58 002

 1666922861/001:
 total 100
 drwxr-xr-x. 2 root root  4096 Nov 18 14:58 .
 drwxr-xr-x. 4 root root    28 Nov 18 14:58 ..
 -rw-------. 1 root root  1808 Oct 27 22:07 dmesg-efi-166692286101001
 -rw-------. 1 root root  1812 Oct 27 22:07 dmesg-efi-166692286102001
 -rw-------. 1 root root  1807 Oct 27 22:07 dmesg-efi-166692286103001
 -rw-------. 1 root root  1773 Oct 27 22:07 dmesg-efi-166692286104001
 -rw-------. 1 root root  1821 Oct 27 22:07 dmesg-efi-166692286105001
 -rw-------. 1 root root  1804 Oct 27 22:07 dmesg-efi-166692286106001
 -rw-------. 1 root root  1792 Oct 27 22:07 dmesg-efi-166692286107001
 -rw-------. 1 root root  1717 Oct 27 22:07 dmesg-efi-166692286108001
 -rw-------. 1 root root  1764 Oct 27 22:07 dmesg-efi-166692286109001
 -rw-------. 1 root root  1796 Oct 27 22:07 dmesg-efi-166692286110001
 -rw-------. 1 root root  1793 Oct 27 22:07 dmesg-efi-166692286111001
 -rw-------. 1 root root  1813 Oct 27 22:07 dmesg-efi-166692286112001
 -rw-------. 1 root root  1754 Oct 27 22:07 dmesg-efi-166692286113001
 -rw-------. 1 root root  1803 Oct 27 22:07 dmesg-efi-166692286114001
 -rw-------. 1 root root  1805 Oct 27 22:07 dmesg-efi-166692286115001
 -rw-------. 1 root root  1815 Oct 27 22:07 dmesg-efi-166692286116001
 -rw-r-----. 1 root root 28677 Nov 18 14:58 dmesg.txt

 1666922861/002:
 total 104
 drwxr-xr-x. 2 root root  4096 Nov 18 14:58 .
 drwxr-xr-x. 4 root root    28 Nov 18 14:58 ..
 -rw-------. 1 root root  1341 Oct 27 22:07 dmesg-efi-166692286101002
 -rw-------. 1 root root  1820 Oct 27 22:07 dmesg-efi-166692286102002
 -rw-------. 1 root root  1791 Oct 27 22:07 dmesg-efi-166692286103002
 -rw-------. 1 root root  1801 Oct 27 22:07 dmesg-efi-166692286104002
 -rw-------. 1 root root  1809 Oct 27 22:07 dmesg-efi-166692286105002
 -rw-------. 1 root root  1817 Oct 27 22:07 dmesg-efi-166692286106002
 -rw-------. 1 root root  1810 Oct 27 22:07 dmesg-efi-166692286107002
 -rw-------. 1 root root  1808 Oct 27 22:07 dmesg-efi-166692286108002
 -rw-------. 1 root root  1765 Oct 27 22:07 dmesg-efi-166692286109002
 -rw-------. 1 root root  1816 Oct 27 22:07 dmesg-efi-166692286110002
 -rw-------. 1 root root  1751 Oct 27 22:07 dmesg-efi-166692286111002
 -rw-------. 1 root root  1786 Oct 27 22:07 dmesg-efi-166692286112002
 -rw-------. 1 root root  1752 Oct 27 22:07 dmesg-efi-166692286113002
 -rw-------. 1 root root  1759 Oct 27 22:07 dmesg-efi-166692286114002
 -rw-------. 1 root root  1787 Oct 27 22:07 dmesg-efi-166692286115002
 -rw-------. 1 root root  1771 Oct 27 22:07 dmesg-efi-166692286116002
 -rw-------. 1 root root  1816 Oct 27 22:07 dmesg-efi-166692286117002
 -rw-r-----. 1 root root 30000 Nov 18 14:58 dmesg.txt

 1666922867:
 total 4
 drwxr-xr-x. 3 root root   17 Nov 18 14:58 .
 drwxr-xr-x. 7 root root  144 Nov 18 14:58 ..
 drwxr-xr-x. 2 root root 4096 Nov 18 14:58 003

 1666922867/003:
 total 104
 drwxr-xr-x. 2 root root  4096 Nov 18 14:58 .
 drwxr-xr-x. 3 root root    17 Nov 18 14:58 ..
 -rw-------. 1 root root  1388 Oct 27 22:07 dmesg-efi-166692286701003
 -rw-------. 1 root root  1824 Oct 27 22:07 dmesg-efi-166692286702003
 -rw-------. 1 root root  1795 Oct 27 22:07 dmesg-efi-166692286703003
 -rw-------. 1 root root  1805 Oct 27 22:07 dmesg-efi-166692286704003
 -rw-------. 1 root root  1813 Oct 27 22:07 dmesg-efi-166692286705003
 -rw-------. 1 root root  1821 Oct 27 22:07 dmesg-efi-166692286706003
 -rw-------. 1 root root  1814 Oct 27 22:07 dmesg-efi-166692286707003
 -rw-------. 1 root root  1812 Oct 27 22:07 dmesg-efi-166692286708003
 -rw-------. 1 root root  1769 Oct 27 22:07 dmesg-efi-166692286709003
 -rw-------. 1 root root  1820 Oct 27 22:07 dmesg-efi-166692286710003
 -rw-------. 1 root root  1755 Oct 27 22:07 dmesg-efi-166692286711003
 -rw-------. 1 root root  1790 Oct 27 22:07 dmesg-efi-166692286712003
 -rw-------. 1 root root  1756 Oct 27 22:07 dmesg-efi-166692286713003
 -rw-------. 1 root root  1763 Oct 27 22:07 dmesg-efi-166692286714003
 -rw-------. 1 root root  1791 Oct 27 22:07 dmesg-efi-166692286715003
 -rw-------. 1 root root  1775 Oct 27 22:07 dmesg-efi-166692286716003
 -rw-------. 1 root root  1820 Oct 27 22:07 dmesg-efi-166692286717003
 -rw-r-----. 1 root root 30111 Nov 18 14:58 dmesg.txt

Furthemore, pstore records on ERST are now able to accurately
identify the change in timestamp sequence in order to start a
new dmesg.txt, as needed.
2022-12-05 09:25:12 +01:00
Lennart Poettering
f8a8f613c6 Revert "update credentials when reloading a service"
This reverts commit 16a42b84cf.
2022-12-05 09:00:45 +01:00
Zbigniew Jędrzejewski-Szmek
d22771fc00 gpt-auto-generator: do not write "noauto" in unit options
"auto"/"noauto" only make sense in the fstab. Putting them in Options= in the
generated unit has no effect and is confusing.
2022-12-05 08:42:04 +01:00
Zbigniew Jędrzejewski-Szmek
c99070a8cb
Merge pull request #25618 from keszybz/sysctl-simplify-writing
Write sysctl values without newlines and as fixed strings
2022-12-05 08:41:00 +01:00
Ivan Shapovalov
c7779a61ac import: wire up SYSTEMD_IMPORT_BTRFS_{SUBVOL,QUOTA} to importd
Btrfs quotas are actually being enabled in systemd-importd via
setup_machine_directory(), not in systemd-{import,pull} where those
environment variables are checked. Therefore, also check them in
systemd-importd and avoid enabling quotas if requested by the user.

Fixes: #18421
Fixes: #15903
Fixes: #24387
2022-12-03 20:31:48 +04:00
Ivan Shapovalov
e9231901a2 machine-pool: simplify return values from setup_machine_directory()
Non-negative return values of setup_machine_directory() were never used
and never had clear meaning, so do not distinguish between various
non-error conditions and just return 0 in all cases.
2022-12-03 20:31:48 +04:00
Mike Yuan
0acb1459a1
rpm/systemd-update-helper: use --no-warn when disabling units
Suppress the "empty [Install] section" warning (see #25437).
2022-12-03 20:27:47 +08:00
Mike Yuan
108d35ac7d
systemctl: allow suppress the warning of no install info using --no-warn
In cases like packaging scripts, it might be desired to use
enable/disable on units without install info. So, adding an
option '--no-warn' to suppress the warning.
2022-12-03 20:26:19 +08:00
Mike Yuan
bf1bea43f1
systemctl: warn if trying to disable a unit with no install info
Trying to disable a unit with no install info is mostly useless, so
adding a warning like we do for enable (with the new dbus method
'DisableUnitFilesWithFlagsAndInstallInfo()'). Note that it would
still find and remove symlinks to the unit in /etc, regardless of
whether it has install info or not, just like before. And if there are
actually files to remove, we suppress the warning.

Fixes #17689
2022-12-03 20:26:14 +08:00
Zbigniew Jędrzejewski-Szmek
27c8ca439f manager: write net/unix/max_dgram_qlen sysctl as fixed string 2022-12-03 11:59:03 +01:00
Zbigniew Jędrzejewski-Szmek
a5fac1df27 manager: define a string constant for LONG_MAX and use that for sysctl
This moves the formatting of the constant to compilation time and let's us
avoid asprintf() in the very hot path of initial boot.
2022-12-03 11:59:03 +01:00
Zbigniew Jędrzejewski-Szmek
b47e0fac03 manager: do not append '\n' when writing sysctl settings
When booting with debug logs, we print:

   Setting '/proc/sys/fs/file-max' to '9223372036854775807
   '
   Setting '/proc/sys/fs/nr_open' to '2147483640
   '
   Couldn't write fs.nr_open as 2147483640, halving it.
   Setting '/proc/sys/fs/nr_open' to '1073741816
   '
   Successfully bumped fs.nr_open to 1073741816

The strange formatting is because we explicitly appended a newline in those two
places. It seems that the kernel doesn't care. In fact, we have a few dozen other
writes to sysctl where we don't append a newline. So let's just drop those here
too, to make the code a bit simpler and avoid strange output in the logs.
2022-12-03 11:59:03 +01:00
Lennart Poettering
c2534821dc dissect: add new helper verity_settings_data_covers()
This function checks if the external verity data referenced in
VeritySettings covers the specified partition (indicated via
designator).

Right now, we'll use that at one place, but in a later commit in more.
2022-12-03 00:22:23 +01:00
Lennart Poettering
0f958c8d4f systemctl: print a clear warning if people invoke systemctl without /proc/ 2022-12-02 23:56:20 +01:00
Lennart Poettering
2075b6dd39 chase-symlink: when converting directory O_PATH fd to real fd, don't bother with /proc/
Replaces: #25581
2022-12-02 23:55:44 +01:00
Lennart Poettering
03c16b9784 glyph-util: add warning sign special glyph 2022-12-02 23:54:50 +01:00
Lennart Poettering
d90b03f80d dissect: pick up gpt partition flags
Let's store the GPT partition flags in the dissected partition info.

Right now we won't actually use them for anything yet, but later we'll
add that, when enforcing policy on dissection.
2022-12-02 22:52:48 +01:00
Lennart Poettering
f6484e8503
Merge pull request #25570 from yuwata/dissect-rootless-image
dissect: support to unmount image without root partition
2022-12-02 18:25:53 +01:00
Lennart Poettering
1fe6e5c112 Revert "basic: add fallback in chase_symlinks_and_opendir() for cases when /proc is not mounted"
This reverts commit 3e22dfc235.
2022-12-02 17:57:10 +01:00
Michal Sekletar
3e22dfc235 basic: add fallback in chase_symlinks_and_opendir() for cases when /proc is not mounted
https://bugzilla.redhat.com/show_bug.cgi?id=2136916
2022-12-02 17:45:33 +01:00
Zbigniew Jędrzejewski-Szmek
6accdcc547
Merge pull request #25541 from medhefgo/boot-reconnect
boot: Fix huge boot delay
2022-12-02 14:37:17 +01:00
Yu Watanabe
a52efa813d dissect-image: log expected UUID for /var
Closes #25443.
2022-12-02 14:25:48 +01:00
Yu Watanabe
46dc071985 bootspec: fix null-dereference-read
Fixes [oss-fuzz#53578](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53578).
Fixes #25450.
2022-12-02 14:23:45 +01:00
Yu Watanabe
719b7d4dc2 fuzz-systemctl: limit the size of input
Fixes [oss-fuzz#53552](https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=53552).
Fixes #25445.
2022-12-02 14:22:25 +01:00
Yu Watanabe
6c2d70ce9f tree-wide: fix typo 2022-12-02 13:27:08 +09:00
Neil Moore
d833ed781f virt: Support detection of LMHS SRE guests 2022-12-02 10:29:14 +09:00
Yu Watanabe
ef6636fd18
Merge pull request #25591 from poettering/dissect-probe-offset
dissect-image: probe file system via main block device fd/image file fd
2022-12-02 09:15:20 +09:00
Phaedrus Leeds
c85c2f7930 nspawn: Use "Ctrl-" rather than "^" in info msg
Maybe most people know that "^]" means "Ctrl + ]" but for those that
don't, this should be more clear.
2022-12-02 08:28:04 +09:00
Yu Watanabe
d9a95033bf network: unset Link.ndisc_configured only when a new address or route is requested
This fixes an issue introduced by af2aea8bb6.

When an outdated address or route is passed to link_request_address()/route(),
then they return 0 and the address or route will not be assigned. Such
situation can happen when we receive RA with zero lifetime. In that
case, we should not unset Link.ndisc_configured flag, otherwise even
no new address nor route will assigned, the interface will enter to the
configuring state, and unnecessary DBus property change is emit and the state
file will be updated. That makes resolved or timesyncd triggered to
reconfigure the interface.

Fixes #25456.
2022-12-01 23:15:09 +01:00
Luca Boccassi
f7031144da
Merge pull request #25568 from yuwata/network-tiny-cleanups
network: tiny cleanups
2022-12-01 23:12:26 +01:00
Lennart Poettering
c80c9079c8 dissect-image: probe file system via main block device fd/image file fd
let's make sure we can probe file systems also when unprivileged:
instead of probing the partition block devices for file system
signatures, let's go via the original "whole" fd.

libblkid makes this easy actually, as it allows us to specify the
offset/size of the area to probe. And we have the partition
offsets/sizes anyway, so it's trivial for us to make use of.

This thus enables fs probing also when lacking privs and operating on
naked regular files without loopback devices or anything like this.
2022-12-01 22:09:30 +01:00
Lennart Poettering
59a4c0d7e3 test-loop-block: let's explicitly flush buffer cache on whole block device
Let's explicitly flush the kernel's buffer cache on the whole block
device once we ran "mkfs". This is necessary, because partition and
whole block devices maintain separate buffer caches, and thus writing
to one will not be visible on the other if cached there already, until
the latter's cache is explicitly flushed.

This is preparation for later adding support for probing file sytems
also if we have no open partition block devices, and hence want to use
the whole block device instead.
2022-12-01 22:07:36 +01:00
Lennart Poettering
9f2d9a4aab test-loop-block: also test dissection without ADD/PIN of partition block devices
Let's extend the test further, and try the codepaths where we do not
pin/add the partition block devices (i.e. which is the codepaths we use
when running without privs)
2022-12-01 22:07:36 +01:00
Lennart Poettering
02c15120a1 test-loop-block: tighten tests a bit - check fstype, too
Let's verify that we properly created the file systems once we did so.
And tets this way that our dissector works correctly.
2022-12-01 22:07:36 +01:00
Yu Watanabe
41a95b18bd dissect: support to unmount image without root partition
Fixes #25480.
2022-12-02 02:58:44 +09:00
Yu Watanabe
040d343903 dissect: use sd-device to find and open loopback block device 2022-12-02 02:52:06 +09:00
Zbigniew Jędrzejewski-Szmek
c3f0bff945 bootctl: use output mode where "[]" is written instead for empty output
It's easier for the caller if output is always a list, even if there are no
entries.
2022-12-01 18:14:52 +01:00
Zbigniew Jędrzejewski-Szmek
8525bb369a shared/json: optimize appending objects to arrays
When repeatedly appending an object to a growing array, we would create a new
array larger by one slot, insert all the old entries and the new element with
ref count bumps into the new array, and then unref the old array.

This would cause problems when building an array with more than a few thousand
elements. If userdbctl is modified to construct an array,
'userdbctl --json=pretty group >/dev/null' with 31k groups:
0.74s   (existing code)
102.17s (returning an array)
0.79s   (with this patch)

We append arrays in various places, so it seems nice to make this generally
fast.
2022-12-01 18:13:21 +01:00
Zbigniew Jędrzejewski-Szmek
b0eeb94588 shared/json: make it possible to specify source name for strings too, add tests
The source would be set implicitly when parsing from a named file. But
it's useful to specify the source also for cases where we're parsing a
ready string. I noticed the lack of this API when trying to write tests,
but it seems generally useful to be specify a source name when parsing
things.
2022-12-01 18:02:06 +01:00
Zbigniew Jędrzejewski-Szmek
b570204a97 bootctl: make --json output normal json
We would output a sequence of concatenated JSON strings. 'jq' accepts such
output without fuss, and can even automatically build an array with --slurp/-s.
Nevertheless, parsing this format is more effort for the reader, since it's not
"standard JSON". E.g. Python's json module cannot do this out-of-the-box, but
needs some loop with json.JSONDecoder.raw_decode() and then collecting the
objects into an array. Such streaming output make sense in case of logs, where
we stream the output and it has no predefined length. But here we expect at
most a few dozen entries, so it's nicer to write normal JSON that is trivial to
parse.

I'm treating this is a bugfix and not attempting to provide compatibility
backwards. I don't think the previous format was seeing much use, and it's
trivial to adapt to the new one.
2022-12-01 18:00:49 +01:00
Lennart Poettering
2e3944b872 blkid-util: define enum for blkid_do_safeprobe() return values
libblkid really should define an enum for this on its own, but it
currently doesn't and returns literal numeric values. Lets make this
more readable by adding our own symbolic names via an enum.
2022-12-01 15:43:26 +01:00
Lennart Poettering
ef1f0a14fa tree-wide: use errno_or_else() more, instead of homegrown checks 2022-12-01 15:42:46 +01:00
Daan De Meyer
003cb0e046
Merge pull request #25579 from DaanDeMeyer/copy-graceful-symlinks
repart: Ignore copy failures for unsupported file types
2022-12-01 13:47:14 +01:00
Daan De Meyer
336ae0e71d repart: Ignore copy failures for unsupported file types
e.g. vfat doesn't support symlinks, sockets, fifos, etc so let's ignore
any copy failures related to unsupported file types when populating
filesystems.
2022-12-01 12:14:35 +01:00
Lennart Poettering
f0c24a0ed8
Merge pull request #25554 from enr0n/follow-on-25509
oomd: only check prefix_uid when uid != 0
2022-12-01 12:04:23 +01:00
Lennart Poettering
73d88b806b dissect: rework DISSECT_IMAGE_ADD_PARTITION_DEVICES + DISSECT_IMAGE_OPEN_PARTITION_DEVICES
Curently, these two flags were implied by dissect_loop_device(), but
that's not right, because this means systemd-gpt-auto-generator will
dissect the root block device with these flags set and that's not
desirable: the generator should not cause the partition devices to be
created (we don't intend to use them right-away after all, but expect
udev to find/probe them first, and then mount them though .mount units).
And there's no point in opening the partition devices, since we do not
intend to mount them via fds either.

Hence, rework this: instead of implying the flags, specify them
explicitly.

While we are at it, let's also rename the flags to make them more
descriptive:

DISSECT_IMAGE_MANAGE_PARTITION_DEVICES becomes
DISSECT_IMAGE_ADD_PARTITION_DEVICES, since that's really all this does:
add the partition devices via BLKPG.

DISSECT_IMAGE_OPEN_PARTITION_DEVICES becomes
DISSECT_IMAGE_PIN_PARTITION_DEVICES, since we not only open the devices,
but keep the devices open continously (i.e. we "pin" them).

Also, drop the DISSECT_IMAGE_BLOCK_DEVICE combination flag, since it is
misleading, i.e. it suggests it was appropriate to specify on all
dissected blocking devices, but that's precisely not the case, see the
systemd-gpt-auto-generator case. My guess is that the confusion around
this was actually the cause for this bug we are addressing here.

Fixes: #25528
2022-12-01 11:32:30 +01:00
Ray Strode
9fe26523a1 terminal-util: Set OPOST when setting ONLCR
reset_terminal_fd sets certain minimum required terminal attributes
that systemd relies on.

One of those attributes is `ONLCR` which ensures that when a new line
is sent to the terminal, that the cursor not only moves to the next
line, but also moves to the very beginning of that line.

In order for `ONLCR` to work, the terminal needs to perform output
post-processing. That requires an additional attribute, `OPOST`,
which reset_terminal_fd currently fails to ensure is set.

In most cases `OPOST` (and `ONLCR` actually) are both set anyway, so
it's not an issue, but it could be a problem if, e.g., the terminal was
put in raw mode by a program and the program unexpectedly died before
restoring settings.

This commit ensures when `ONLCR` is set `OPOST` is set too, which is
the only thing that really makes sense to do.
2022-12-01 11:29:21 +01:00
Daan De Meyer
494f7fc096 copy: Add COPY_GRACEFUL_WARN
When copying between filesystems, sometimes the target filesystem
might not support symlinks/fifos/sockets/... and we want to log and
ignore  any failures to copy such files when copying. Let's introduce
a new flag to enable this behavior.
2022-12-01 10:03:31 +01:00
Yu Watanabe
6b15f2eff9 sd-netlink: fix assertion triggered by message_get_serial()
This fixes an issue introduced by 7b34bae3b1.

Fixes https://github.com/systemd/systemd/pull/25565#issuecomment-1331353945.
2022-11-30 10:16:17 +00:00
Yu Watanabe
f3c8cb27b1 mkfs-util: fix memleak
Fixes an issure introduced by c75cf0164c.

Fixes CID#1501073.
2022-11-30 08:21:40 +01:00
Yu Watanabe
4bbe559b5c network: address: use ASSERT_PTR() 2022-11-30 10:23:58 +09:00
Yu Watanabe
aaad20e0e1 network: address: always update link state when an address is removed
The removed address might be in the tentative state.
2022-11-30 10:23:33 +09:00
Yu Watanabe
f3016c40e3 network: add missing assertion 2022-11-30 10:18:03 +09:00
Michal Koutný
862be54d57 cgtop: Update code comments 2022-11-30 09:40:56 +09:00
Yu Watanabe
dc4f4c6e36
Merge pull request #25561 from poettering/btrfs-quota-opath-fix
tmpfiles: fix btrfs quota logic
2022-11-30 09:30:13 +09:00
Nick Rosbrook
3c0562778b oomd: fix doc comment for oomd_fetch_cgroup_oom_preference
Explicitly state that ManagedOOMPreference is always honored when the
unit's cgroup is owned by root.
2022-11-29 16:01:58 -05:00
Nick Rosbrook
66bc4f6fb1 oomd: only check prefix_uid when uid != 0
If the cgroup is owned by root there is no need to get prefix_uid. Only
check prefix_uid when uid != 0, and then set MANAGED_OOM_PREFERENCE_NONE
and return early if uid != prefix_uid.
2022-11-29 16:01:54 -05:00
Lennart Poettering
fb3921b823 dissect-image: merge handlers for 4 different partition designators into one
These four branches execute the exact same code these days, hence merge
them into one.
2022-11-29 18:34:59 +01:00
Lennart Poettering
df4524cb37 dissect-image: don't probe swap partitions needlessly
We already know it's swap, we can assume it's also fstype swap, and
don#t need to probe things later again.
2022-11-29 18:34:29 +01:00
Lennart Poettering
e6eb581cb0
Merge pull request #25558 from poettering/fdisk-id128
add generic uuid/id128 helpers for libfdisk too
2022-11-29 16:06:10 +01:00
Lennart Poettering
e3b9a5ff26 blkid: add helpers that get gpt partition uuid as sd_id128_t
just some refactoring to make things simpler.
2022-11-29 16:05:17 +01:00
Lennart Poettering
e6d1d4c0b3 btrfs-util: convert O_PATH if necessary, in btrfs quota call
Fixes: #25468
2022-11-29 15:35:06 +01:00
Lennart Poettering
698bc1861e blockdev-util: move O_PATH fd conversion into btrfs_get_block_device_fd() to shorten things
And let's use a simple call to the new fd_reopen_condition() helper
there.
2022-11-29 15:34:27 +01:00
Lennart Poettering
f1cab3d6dc btrfs-util: convert to fd_reopen_condition() 2022-11-29 15:33:51 +01:00
Lennart Poettering
5f5865f0ad fd-util: add new helper fd_reopen_conditional()
This is a wrapper around fd_reopen() that will reopen an fd if the
F_GETFL flags indicate this is necessary, and otherwise not.

This is useful for various utility calls that shall be able to operate
on O_PATH and without it, and might need to convert between the two
depending on what's passed in.
2022-11-29 15:32:47 +01:00
Jan Janssen
f6d59e2ebf boot: Only do full driver initialization in VMs
Doing the reconnect dance on some real firmware creates huge delays on
boot. This should not be needed anymore as we now ask the firmware to
make console devices and xbootldr partitions available explicitly in a
more targeted fashion.

Fixes: #25510
2022-11-29 15:05:56 +01:00
Jan Janssen
7f19be808c boot: Make sure all partitions drivers are connected 2022-11-29 15:03:52 +01:00
Jan Janssen
b99bf58118 boot: Use EFI_BOOT_MANAGER_POLICY_PROTOCOL to connect console devices 2022-11-29 15:03:52 +01:00
Lennart Poettering
0461375326
Merge pull request #25385 from drvink/main
systemd: Support OOMPolicy in scope units
2022-11-29 14:40:18 +01:00
Lennart Poettering
63b96eb9b3 fdisk-util: add fdisk_partition_get_type_as_id128() helper
Let's also add an easy accessor for the other per-partition UUID.
2022-11-29 12:07:15 +01:00
Lennart Poettering
02e32aa629 fdisk-util: add fdisk_partition_get_uuid_as_id128() helper
Inspired by: #25534
2022-11-29 12:07:15 +01:00
Joerg Behrmann
0ccfd3564b kernel-install: Add uki layout
Currently the kernel-install man page only documents the bls layout for use
with the boot loader spec type #1. 90-loaderentry.install uses this layout to
generate loader entries and copy the kernel image and initrd to $BOOT.

This commit documents a second layout "uki" and adds 90-uki-copy.install,
which copies a UKI "uki.efi" from the staging area or any file with the .efi
extension given on the command line to
$BOOT/EFI/Linux/$ENTRY_TOKEN-$KERNEl_VERSION(+$TRIES).efi

This allows for both locally generated and distro-provided UKIs to be handled
by kernel-install.
2022-11-29 11:33:27 +01:00
Daan De Meyer
49d1fcd01c
Merge pull request #25132 from yuwata/core-device-inactivate-removed-device-on-switching-root
core/device: inactivate removed device on switching root
2022-11-29 10:27:34 +01:00
Daan De Meyer
bf030f5569 repart: Add split path to table output 2022-11-29 10:08:51 +01:00
Daan De Meyer
db1d4e6b97 repart: Make sure we cleanup image file on failure if we create it 2022-11-29 10:08:51 +01:00
Daan De Meyer
448cfb7f37 repart: Inline Partition and Context typedefs 2022-11-29 10:08:51 +01:00
Daan De Meyer
ea09f92ce4 repart: Remove leftover debug statement 2022-11-29 10:08:51 +01:00
Daan De Meyer
cc751c75a0 repart: Move backing_fd, node and from_scratch variables into Context 2022-11-29 10:08:51 +01:00
Daan De Meyer
a2d7c42e97 repart: Make sure split partition files are cleaned up on failure 2022-11-29 10:08:51 +01:00
Daan De Meyer
621083481b repart: Refactor split names 2022-11-29 10:08:51 +01:00
Daan De Meyer
7d07030eea repart: Make sure we clean up temporary files created in context_minimize() 2022-11-29 10:08:49 +01:00
Yu Watanabe
f334a8c8e9
Merge pull request #25536 from yuwata/sd-netlink-several-fixes
sd-netlink: several fixes
2022-11-29 10:35:07 +09:00
Yu Watanabe
c167ed0fd1
Merge pull request #25552 from yuwata/network-ndisc-trivial-fixes
network: NDisc: trivial fixes
2022-11-29 10:33:33 +09:00
Luca Boccassi
8936a2a8f0
Merge pull request #25532 from Werkov/fix-cgtop-args
cgtop: Do not rewrite -P or -k options
2022-11-28 22:20:47 +01:00
Yu Watanabe
6a4f43cd66 network: drop invalid and unused flag
Route.flags can only take RTNH_F_ONLINK, and other flags are silently
dropped.
2022-11-29 04:31:27 +09:00
Yu Watanabe
d87c5cd8d9 network: fix indentation 2022-11-29 04:30:12 +09:00
Luca Boccassi
94d2caedee
Merge pull request #25496 from DaanDeMeyer/repart-optimize
repart: Prefer using loop devices to populate filesystems when available
2022-11-28 15:51:32 +01:00
Luca Boccassi
6d3fcb6ccd
Merge pull request #25222 from medhefgo/stub-cmdline
stub: Fix cmdline handling
2022-11-28 15:49:17 +01:00
Michal Koutný
48600b3524 cgtop: Do not rewrite -P or -k options
--recursive=no will overwrite possible -P or -k option hence making the
recursive disabling impossible.

Check what counting types the system supports (encoded in the ordering
of our enum) of and pick whatever user requests but is also supported.

Fixes: #25248
2022-11-28 14:29:49 +01:00
Daan De Meyer
d3201eb4f4 repart: Prefer using loop devices to populate filesystems when available
Let's make sure we use loop devices if we have access to them and
only fall back to regular files if we can't use loop devices. We
prefer loop devices because when using mkfs --root options, we have
to populate a temporary staging tree which means we're copying every
file twice instead of once when using loop devices.
2022-11-28 10:52:21 +01:00
Daan De Meyer
d2ac7698cb repart: Make sure all files in the image are owned by root 2022-11-28 10:46:00 +01:00
Daan De Meyer
8a050905a3 repart: Move comment 2022-11-28 10:46:00 +01:00
Jan Janssen
b17f3b3d80 stub: Detect empty LoadOptions when run from EFI shell
The EFI shell will pass the entire command line to the application it
starts, which includes the file path of the stub binary. This prevents
us from using the built-in cmdline if the command line is otherwise
empty.

Fortunately, the EFI shell registers a protocol on any images it starts
this way. The protocol even lets us access the args individually, making
it easy to strip the stub path off.

Fixes: #25201
2022-11-27 17:13:04 +01:00
Mike Yuan
3185360980 systemctl: deprecate passing positional argument to reboot completely
(follow-up of #15958)

In #15958 we deprecated passing positional argument to reboot by
generate a warning. It's been two years now and I believe it can
be dropped completely, as per requested in #15773.
2022-11-27 11:18:32 +01:00
Zbigniew Jędrzejewski-Szmek
0ef48896d9 pam: add a call to pam_namespace
A call to pam_namespace is required so that children of user@.service end up in
a namespace as expected. pam_namespace gets called as part of the stack that
creates a session (login, sshd, gdm, etc.) and those processes end up in a
namespace, but it also needs to be called from our stack which is parallel and
descends from pid1 itself.

The call to pam_namespace is similar to the call to pam_keyinit that was added
in ab79099d16. The pam stack for user@.service
creates a new session which is disconnected from the parent environment. Both
calls are not suitable for inclusion in the shared part of the stack (e.g.
@system-auth on Fedora/RHEL systems), because for example su/sudo/runuser
should not include them.

Fixes #17043 (Allow to execute user service into dedicated namespace
              if pam_namespace enabled)
Related to https://bugzilla.redhat.com/show_bug.cgi?id=1861836
(Polyinstantiation is ignored/bypassed in GNOME sessions)
2022-11-27 10:45:27 +01:00
Evgeny Vereshchagin
84f788d669 resolve: format zero-length RDATA according to rfc3597
If the RDATA is of zero length, the text representation contains only
the \# token and the single zero representing the length.
2022-11-26 12:20:21 +00:00
Evgeny Vereshchagin
ae8654f9e6 tests: fuzz dns resource records
It should help to catch issues like https://github.com/systemd/systemd/issues/19584,
https://github.com/systemd/systemd/issues/25449.
2022-11-26 09:52:09 +00:00
Yu Watanabe
52ceba53d3 sd-netlink: append instead of prepend multipart message
Previously, e.g., networkd enumerated network interfaces with ifindex
in a decreasing order, as sd-netlink inverses the order of the received
multipart messages.
Let's keep the order of the multipart messages. Hopefully this changes
no behavior, as our code do not depend on the order of the received
multipart messages.

Before:
===
Nov 26 09:35:10 systemd[1]: Starting Network Configuration...
Nov 26 09:35:11 systemd-networkd[36185]: wlp59s0: Saved new link: ifindex=3, iftype=ETHER(1), kind=n/a
Nov 26 09:35:12 systemd-networkd[36185]: enp0s31f6: Saved new link: ifindex=2, iftype=ETHER(1), kind=n/a
Nov 26 09:35:12 systemd-networkd[36185]: lo: Saved new link: ifindex=1, iftype=LOOPBACK(772), kind=n/a

After:
===
Nov 26 09:45:18 systemd[1]: Starting Network Configuration...
Nov 26 09:45:19 systemd-networkd[38372]: lo: Saved new link: ifindex=1, iftype=LOOPBACK(772), kind=n/a
Nov 26 09:45:19 systemd-networkd[38372]: enp0s31f6: Saved new link: ifindex=2, iftype=ETHER(1), kind=n/a
Nov 26 09:45:19 systemd-networkd[38372]: wlp59s0: Saved new link: ifindex=3, iftype=ETHER(1), kind=n/a
2022-11-26 11:28:27 +09:00
Yu Watanabe
a8ac052624 sd-netlink: do not link non-multipart messages
Previously, if a single packet contains multiple non-multipart messages,
then the messages were linked and saved as a single entry, especially
even if the messages has different serial numbers. Though, not sure if
the kernel sends such packet. But at least for safety, let's link only
multipart messages.
2022-11-26 11:28:27 +09:00
Yu Watanabe
9482429af9 sd-netlink: split out parse_message_one() from socket_read_message()
No functional change, just refactoring and preparation for later
commits.
2022-11-26 11:28:27 +09:00
Yu Watanabe
2b176edc74 sd-netlink: do not use serials currently queued 2022-11-26 11:28:27 +09:00
Yu Watanabe
7b34bae3b1 sd-netlink: also manage received messages by serial
Then, we can easily find the received message matching with requested
serial.
2022-11-26 11:28:27 +09:00
Yu Watanabe
e417c4ac44 sd-netlink: reimplement received message queue
By using OrderedSet and Hashmap, we can drop all memmove() calls.
No functional changes, just refactoring.
2022-11-26 11:28:27 +09:00
Yu Watanabe
2ea465ef62 sd-netlink: introduce netlink_queue_received_message() and friend
No functional change, just refactoring.
2022-11-26 11:28:27 +09:00
Yu Watanabe
766417bd76 sd-netlink: fix segfault 2022-11-26 11:28:27 +09:00
Yu Watanabe
bc1a8e2b6e sd-netlink: fix possible use-after-free
When we receive a multi-part message and fail to parse it, then
the prviously received message is freed with the _cleanup_ attribute,
but still referenced by sd_netlink.rqueue_partial. That causes
use-after-free when we receive another multi-part message.
2022-11-26 11:28:27 +09:00
Yu Watanabe
b491454dfc sd-netlink: return earlier when received invalid message 2022-11-26 11:28:27 +09:00
Yu Watanabe
fb298ef104 sd-netlink: allocate read buffer when necessary 2022-11-26 11:28:27 +09:00
Yu Watanabe
61d95dc02c sd-netlink: check received size in socket_recv_message()
No functional change, just refactoring and slightly shorten
socket_read_message().
2022-11-26 11:28:27 +09:00
Yu Watanabe
b374397ec5 sd-netlink: drop redundant 'else' 2022-11-26 11:28:27 +09:00
Yu Watanabe
027193db48 sd-netlink: always initialize return variable on success 2022-11-26 11:28:27 +09:00
Lennart Poettering
f8cf3d19d2 fdisk: introduce common fdisk_new_context_fd() helper
We do the same thing over and over again and it's a bit ugly, hence
let's unify the code for it at one common place.
2022-11-26 11:28:05 +09:00
Lennart Poettering
f52261a06d dissect: don't pre-open swap devices, we are not going to use them 2022-11-26 11:27:15 +09:00
Daan De Meyer
5fe8dbe728 repart: Remove bogus check
The --empty option applies to the partition table of the block
device, not the number of definition files we've read. Also, even
if we don't find any definition files, let's not shortcut execution
so we can run repart on a device/loopback file to get information
on the partition table.
2022-11-26 08:27:41 +09:00
Michal Koutný
f38e89c23c logind: Properly unescape names of lingering users
Filenames to store user linger requests are created with C-escaping.
When we enumerate the files to acquire ligering users, we use the
filenames verbatim. In the case C-escaping is not an identity map (such
as "DOMAIN\User"), we won't be able to start user instances of
such mangled users.

Unescape filenames when we treat them as usernames again.

Fixes: #25448
2022-11-26 08:27:16 +09:00
Yu Watanabe
5bd346feb7
Merge pull request #25530 from poettering/resolved-stub-name
resolved: make _localdnsstub and _localdnsproxy resolve to 127.0.0.{53,54}
2022-11-26 08:26:28 +09:00
jcg
1751bdde94 Fix typo 2022-11-26 07:35:56 +09:00
Luca Boccassi
6042b60def
Merge pull request #25498 from medhefgo/stub-splash
stub: Fix splash alpha blending
2022-11-25 19:38:47 +01:00
Lennart Poettering
056c398bda resolved: introduce common macro for 127.0.0.2 IP address 2022-11-25 17:41:55 +01:00
Lennart Poettering
17f244e8f9 resolved: introduce the _localdnsstub and _localdnsproxy special hostnames for 127.0.0.54 + 127.0.0.53
Let's give these special IP addresses names. After all name resolution
is our job here.

Fixes: #23623
2022-11-25 17:37:30 +01:00
Lennart Poettering
68d449997f resolved: don't filter _gateway/_outbound twice
We already denied being responsible for these names further up, no need
to test for them again.
2022-11-25 17:37:13 +01:00
Lennart Poettering
84d194f1e8 resolved: in dns stub always report "lo" as interface for "localhost"
Previously, we'd return the ifindex the user asked on, and if none was
specified "lo". Let's always return "lo".

This should be a better choice usually, since localhost addresses are
typically not reachable over arbitrary interfaces once SO_BINDTODEVICE
or so is used. Hence, let's report the interface that is always right
for these addresses.
2022-11-25 17:37:13 +01:00
Daan De Meyer
cf9c27b18b mkfs-util: Drop batch (b) and n flags from mcopy
The batch flag is bugged on older versions of mcopy causing failures
such as:

```
Internal error, size too big
Streamcache allocation problem:: 5
```

It's also a little unclear what the batch flag actually does, so since
everything still works without it, it doesn't hurt to remove it.

The n flag only applies when copying from fat to unix which we don't do
so it doesn't make sense in this scenario.
2022-11-25 13:46:07 +01:00
Daan De Meyer
9044e5b3bf
Merge pull request #25482 from DaanDeMeyer/repart-skip-partitions
repart: Add --skip-partitions=
2022-11-25 13:31:09 +01:00
Daan De Meyer
7d505753f1 repart: Add --skip-partitions=
--include-partitions and --exclude-partitions now fully exclude
partitions from repart. Whenever a partition type is excluded, we
don't take any partitions of that type into account at all when
running systemd-repart.

--skip-partitions= is introduced to do what --exclude-partitions did
previously. Any skipped partitions are taken into acount when doing
size calculations, but are not yet populated.

Why do we need both concepts? Exclusion is needed so that we can
use shared repart definitions to generate bootable and non-bootable
images. When generating a non-bootable image, we use --exclude-partitions
to exclude the ESP partition. Skipping is needed so that we can
populate the root partition while skipping the ESP partition, get
the roothash of the root partition, use that to generate a UKI, and
finally populate the ESP partition with the UKI included.
2022-11-25 12:07:38 +01:00
Lennart Poettering
fb896517ae resolved: remove inappropriate assert()
A NULL Bitmap object is by all our code considered identical to an empty
bitmap. Hence let's remove the entirely unnecessary assert().

The assert() can be triggered if debug monitoring is used an an empty
NSEC or NSEC3 RR is included in an answer resolved returns.

it's not really a security issue since enabling debug monitoring is a
manual step requiring root privileges, that is off by default. Moreover,
it's a "clean" assert(), i.e. the worst that happens is tha a coredump
is generated and resolved restarted.

Fixes: #25449
2022-11-25 07:49:04 +09:00
Luca Boccassi
9af93d7cab
Merge pull request #25473 from yuwata/mount-tool-cleanups
mount-tool: several cleanups
2022-11-24 20:40:37 +01:00
Daan De Meyer
03288a3f28
Merge pull request #25500 from DaanDeMeyer/mcopy-skip-symlinks
mkfs-util: Skip symlinks when calling mcopy
2022-11-24 16:28:01 +01:00
Jan Janssen
27e1f25ef7 stub: Small code style changes
No actual changes in behavior.
2022-11-24 14:03:01 +01:00
Daan De Meyer
c75cf0164c mkfs-util: Skip non files/directories when calling mcopy
Only files and directories are supported by vfat. When we pass a
symlink to mcopy, it will try to dereference them and copy what the
symlink points at into the vfat partition instead. Let's avoid this
by skipping all unsupported file types when establishing the list of
top level targets that mcopy should copy.

We also use RECURSE_DIR_SORT everywhere when iterating directories
to make things more reproducible.
2022-11-24 14:02:22 +01:00
Daan De Meyer
a0a4c57818 recurse-dir: Handle RECURSE_DIR_ENSURE_TYPE in readdir_all() 2022-11-24 14:02:19 +01:00
Jan Janssen
dde03dd2a8 stub: Fix splash alpha blending
How to interpret the pixel format depends on the masks in the DIB header
(if present). Also, 16bpp (unlike 24bpp) can carry an alpha channel.
This was previously not accounted for.
2022-11-24 13:50:20 +01:00
Daan De Meyer
06da125ea1 dirent-util: Expose dirent_ensure_type() 2022-11-24 13:18:00 +01:00
Daan De Meyer
fe5779cf3f mkfs-util: Check if mcopy is installed 2022-11-24 12:19:53 +01:00
Mark Laws
98b6c94b57 systemd: Default to OOMPolicy=continue for login session scopes
If the kernel OOM kills a process under a login session scope, we don't want to
kill the user's other processes for no good reason.
2022-11-24 19:41:36 +09:00
Mark Laws
5fa098357e systemd: Support OOMPolicy in scope units
Closes #25376.
2022-11-24 19:41:28 +09:00
Luca Boccassi
9f5bf99f1b
Merge pull request #25509 from enr0n/oomd-unpriv-container-fix
Fix `oomd_fetch_cgroup_oom_preference()` for unprivileged LXD containers
2022-11-24 11:21:16 +01:00
Christian Brauner
2e776ed6c8 shared: use move_pivot_root() for services
Currently, services use mount_move_root() in order to setup the root
directory of services using a mount namespace. This relies on MS_MOVE
and chroot(). However, this has serious drawbacks even for relatively
simple mount propagation scenarios.

What systemd currently does is roughly equivalent to the following shell
code:

  unshare --mount --propagation=shared
  cd /
  mount --make-rslave /
  mkdir /new-root
  mount --rbind / /new-root
  cd /new-root
  mount --move /new-root /
  chroot .

This looks simple enough but has the consequence that two separate mount
trees exist for the lifetime of the service. The first one was created
when the mount namespace was created, and the second one when a new
mount for the rootfs was created. The first mount tree sticks around as
a shadow mount tree. Both mount trees are dependent mounts with the host
rootfs as their dominating mount.

Now, when mount propagation is triggered by the host by e.g.,

   mount --bind /opt /mnt

it means that two propagation events are generated. I'm skipping over
the exact kernel details as they aren't that important. The gist is that
for every propagation event that is generated a second one is generated
for the shadow mount tree. In other words, the kernel creates two copies
for each mount that is propagated instead of one.

This isn't necessary. We can simply change the sequence above to:

  unshare --mount --propagation=shared
  cd /
  mount --make-rslave /
  mkdir /new-root
  # stash fd to old rootfs
  # stash fd to new rootfs
  mount --rbind / /new-root
  mkdir /new-root
  cd /new-root
  pivot_root . .
  # new root is tucked under old root
  # chdir into old rootfs via stashed fd
  umount -l /old-root

The pivot_root allows us to get rid of the old mount tree that was
created when the mount namespace was created. So after this sequence
only one mount tree is alive. Plus, it's safer and nicer. Moving mounts
isn't pleasnt.

This patch doesn't convert nspawn yet as the requirements are more
tricky given that it wants to preserve the rootfs as a shared mount
which goes against pivot_root() requirements.

Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
2022-11-24 10:58:26 +01:00
Yu Watanabe
1480c23199 mount: use device enumerator to find matching loopback block device
No functional change, just refactoring.
2022-11-24 14:17:35 +09:00
Yu Watanabe
961d08cadb mount: split umount_by_device() into two
No functional change, just refactoring and preparation for later
commits.
2022-11-24 14:17:35 +09:00
Yu Watanabe
95a45a87d6 mount: make acquire_mount_where_for_loop_dev() take sd-device object
No functional change, just refactoring.
2022-11-24 14:17:22 +09:00
Yu Watanabe
00a60eaf5f
Merge pull request #25483 from poettering/ppoll-usec-eintr
ppoll() + EINTR fixes
2022-11-24 09:42:48 +09:00
Michal Sekletar
88e4bfa62b core: add possibility to not track certain unit types 2022-11-24 09:28:22 +09:00
Luca Boccassi
80d95fcd6e portable: add a few more useful debug log messages
When attaching and /etc/systemd/system.attached can't be created or used
(eg: dead symlink) the logs are pretty much useless as even at debug
level there's no indication of what is going wrong.
Add some debug logs, and return a more specific error string over D-Bus.
2022-11-23 23:02:07 +01:00
Nick Rosbrook
f05bcc1894 oomd: fix unreachable test case in test-oomd-util
This conditional with !empty_or_root(ctx->path) always returns false
because the most recent oomd_cgroup_context_acquire() call was with the
root cgroup. Make sure this test case can be reached by checking cgroup
instead of ctx->path.

While here, use an unused uid (61183) instead of the nobody uid so the
test case does not fail in unprivileged LXD containers.
2022-11-23 15:45:54 -05:00
Nick Rosbrook
8918609348 oomd: always allow root-owned cgroups to set ManagedOOMPreference
Commit 652a4efb66 ("oomd: loosen the restriction on ManagedOOMPreference")
made the change to allow ManagedOOMPreference on a cgroup candidate when
the monitored cgroup and cgroup candidate are owned by the same user.

The commit assumed that this check was sufficient to continue allowing
ManagedOOMPreference on all cgroups owned by root. However, it caused a
regression for unprivileged LXD containers where e.g. /sys/fs/cgroup is
owned by nobody (uid=65534).

Fix this by explicitly allowing the ManagedOOMPreference if uid == 0 in
oomd_fetch_cgroup_oom_preference().
2022-11-23 15:43:51 -05:00
Daan De Meyer
3f9b0e1343 Revert "find-esp: Relax filesystem root directory check"
This reverts commit d91a5f6481.

This is the wrong approach as we don't detect the UUID and devid
of valid ESP/XBOOTLDR partitions.
2022-11-23 21:22:07 +01:00
Lennart Poettering
2ed2c52ace
Merge pull request #25486 from keszybz/kernel-install-header
Add "File created by …" header to BLS entries
2022-11-23 17:36:44 +01:00
Zbigniew Jędrzejewski-Szmek
9efb224443 pam: align second and third columns
In our template file, we have jinja2 template markers, so the file
looks fairly messy. But once it's rendered, it looks pretty clean, except
that the columns are unaligned becuase of "-" in some lines in the first
column. Let's make them aligned.
2022-11-23 16:05:48 +01:00
Daan De Meyer
220780db86 repart: Make parse_filter_partitions() more generic 2022-11-23 12:41:23 +01:00
Daan De Meyer
d989dd7631 repart: Rename arg_filter_partitions_size to arg_n_filter_partitions 2022-11-23 12:41:23 +01:00
Zbigniew Jędrzejewski-Szmek
0be160136e kernel-install: add header to generate entry files
I was looking at a bug in bugzilla about some boot loader issue, and it was
hard to say if the boot entry files were generated by our plugin or something
else. Add a header to make this clear.

kernel-install invokes the plugins via absolute path always, so $0 gives as
the full path the location where the plugin is installed. This is what we want:

  title      Fedora Linux 37 (Workstation Edition)
  # Boot Loader Specification type#1 entry
  # File created by /usr/lib/kernel/install.d/90-loaderentry.install (systemd 252-409-g5028904^)
2022-11-23 10:14:25 +01:00
Daan De Meyer
d91a5f6481 find-esp: Relax filesystem root directory check
When relaxed checks are requested, let's not require the efi/xbootldr
directory to be the root of the filesystem. When building images, image
builders might install all efi/xbootldr files to a regular directory
first before packing them up into a partition. To allow bootctl to be
used in such scenarios to install systemd-boot, we need to relax the
fsroot check.
2022-11-23 09:20:10 +01:00
Luca Boccassi
0dce448bbc repart: respect --discard=no also for block devices
It's only used to avoid BLKDISCARD on individual partitions at the moment.
It can take a lot of time to run on very slow devices, so avoid it for
them too.
2022-11-23 01:33:26 +01:00
Jason A. Donenfeld
0a1d8ac77a stub: handle random seed like sd-boot does
sd-stub has an opportunity to handle the seed the same way sd-boot does,
which would have benefits for UKIs when sd-boot is not in use. This
commit wires that up.

It refactors the XBOOTLDR partition discovery to also find the ESP
partition, so that it access the random seed there.
2022-11-23 00:56:45 +01:00
Lennart Poettering
0c14c45e5c sd-event: reenable epoll_pwait2()
This reenables epoll_pwait2() use, i.e. undoes the effect of
39f756d3ae.

Instead of just reverting that, this PR will change things so that we
strictly rely on glibc's new epoll_pwait2() wrapper (which was added
earlier this year), and drop our own manual fallback syscall wrapper.
That should nicely side-step any issues with correct syscall wrapping
definitions (which on some arch seem not to be easy, given the sigset_t
size final argument), by making this a glibc problem, not ours.

Given that the only benefit this delivers are time-outs more granular
than msec, it shouldn't really matter that we'll miss out on support
for this on systems with older glibcs.
2022-11-23 00:54:23 +01:00
Daan De Meyer
c9bb7438db
Merge pull request #25485 from DaanDeMeyer/gpt-fix
gpt: Specify designator array sizes explicitly
2022-11-22 22:29:50 +01:00
Jan Janssen
927ebebe58 stub: Fix cmdline handling
This fixes some bugs that could lead to garbage getting appended to the
command line passed to the kernel:
 1. The .cmdline section is not guaranteed to be NUL-terminated, but it
    was used as if it was.
 2. The conversion of the command line to ASCII that was passed to the
    stub ate the NUL at the end.
 3. LoadOptions is not guaranteed to be a NUL-terminated EFI string (it
    really should be and generally always is, though).

This also fixes the inconsistent mangling of the command line. If the
.cmdline section was used ASCII controls chars (new lines in particular)
would not be converted to spaces.

As part of this commit, we optimize conversion for the generic code
instead of the (deprecated) EFI handover protocol. Previously we would
convert to ASCII/UTF-8 and then back to EFI string for the (now) default
generic code path. Instead we now convert to EFI string and mangle that
back to ASCII in the EFI handover protocol path.
2022-11-22 17:42:38 +01:00
Jan Janssen
7444e10611 boot: Use xstr8_to_16 for path conversion 2022-11-22 16:50:42 +01:00
Zbigniew Jędrzejewski-Szmek
04fea8407c kernel-install: make 90-loadentry.install templated
It's a bit annoying that this causes so much churn, but I don't see a different
way to do this.
2022-11-22 16:12:09 +01:00
Jan Janssen
aee515bbb5 boot: Use xstr8_to_16 2022-11-22 16:03:03 +01:00
Daan De Meyer
df655bf34c gpt: Drop PARTITION_LINUX_GENERIC and PARTITION_USER_HOME
These don't have an inherent purpose, and aren't used throughout
the codebase, so let's simplify things and remove these.

See https://github.com/systemd/systemd/pull/24803#discussion_r1028190421
for more information.
2022-11-22 15:59:50 +01:00
Jan Janssen
8ad7deffa9 boot: Add xstrn8_to_16 2022-11-22 15:56:48 +01:00
Daan De Meyer
3cde36ffa3 gpt: Specify designator array sizes explicitly
Avoid users accidentally accessing uninitialized memory by always
making sure the array size covers all possible enum values.
2022-11-22 15:53:02 +01:00
Lennart Poettering
ffbcc8d423 io-util: document EINTR situation a bit 2022-11-22 15:23:34 +01:00
Luca Boccassi
d4b3ae65f3
Merge pull request #25477 from yuwata/network-wifi-reconfigure-on-connect
network: wifi: try to reconfigure when connected
2022-11-22 13:37:15 +01:00
Lennart Poettering
22ecfa8312 utmp-wtmp: handle EINTR gracefully when waiting to write to tty 2022-11-22 13:11:04 +01:00
Lennart Poettering
80b780ba17 utmp-wtmp: fix error in case isatty() fails 2022-11-22 13:10:29 +01:00
Lennart Poettering
f3d9278f38 homed: handle EINTR gracefully when waiting for device node 2022-11-22 13:09:53 +01:00
Lennart Poettering
6d66a22168 resolved: handle -EINTR returned from fd_wait_for_event() better
We might get signals for various reasons (for example, somebody asking
us to reload caches via a signal), hence let's handle this gracefully.
2022-11-22 13:09:17 +01:00
Lennart Poettering
6985878533 sd-netlink: handle EINTR from poll() gracefully, as success 2022-11-22 13:08:41 +01:00
Lennart Poettering
6976bf5cd6 varlink: also handle EINTR gracefully when waiting for EIO via ppoll() 2022-11-22 13:08:05 +01:00
Lennart Poettering
7c75f34131 stdio-bridge: don't be bothered with EINTR
We handle signals via signal handlers, hence no need to be concerned
about EINTR.
2022-11-22 13:07:27 +01:00
Lennart Poettering
3022916b4d sd-bus: handle -EINTR return from bus_poll()
In sd_bus_wait(), let's convert EINTR to a return code of 0, thus asking
the caller do loop again and enter sd_bus_process() again (which will
not find any queued events). This way we'll not return an error on
something that isn't really an error. This should typically make sure
things are properly handled by the caller, magically, without eating up
the event entirely, and still giving the caller time to run some code if
they want.
2022-11-22 13:06:50 +01:00
Lennart Poettering
108dfff2c7 tree-wide: modernizations with RET_NERRNO() 2022-11-22 13:05:29 +01:00
Benjamin Fogle
f4a49d1c58 resolved: Fix OpenSSL error messages 2022-11-22 16:04:45 +09:00
Yu Watanabe
8a4ad01a72 network: wifi: try to reconfigure when connected
Sometimes, RTM_NEWLINK message with carrier is received earlier than
NL80211_CMD_CONNECT. To make SSID= or other WiFi related settings in
[Match] section work, let's try to reconfigure the interface.

Fixes a bug introduced by 96f5f9ef9a.

Fixes #25384.
2022-11-22 14:44:26 +09:00
Yu Watanabe
4642371d07 network: drop unnecessary prototype
Follow-up for a39a9ac806.
2022-11-22 14:32:19 +09:00
Yu Watanabe
6ad17c31fb
Merge pull request #25470 from keszybz/strv-extendf-format
Improve check for strv_extendf() format string
2022-11-22 12:27:37 +09:00
наб
848517ddd4 systemctl: edit: write override files as text files
Instead of stripping the newline off the final would-be line;
continue to reduce an empty-line-only file to an empty file, though

Closes #25303
2022-11-22 01:45:50 +01:00
Zbigniew Jędrzejewski-Szmek
5a65d2e535 bootctl: use grey-and-slash prefix for source in list too
Follow-up for 7851732262. The source
field also shows a path relative to $BOOT, so it should be displayed
in the same fashion.
2022-11-22 01:40:20 +01:00
Lennart Poettering
e4cb147a2e udev: make sure auto-root logic also works in UKIs booted from XBOOTLDR
If no root= switch is specified on the kernel command line we'll use the
root disk on which the partition the LoaderDevicePartUUID efi var is
located – as long as that partition is an ESP. Let's slightly liberalize
that and also allow it if that partition is an XBOOTLDR partition. This
ensures that UKIs spawned directly from XBOOTLDR work the same as those
from the ESP.

(Note that this makes no difference if sd-boot is in the mix, as in that
case LoaderDevicePartUUID is always set to the ESP, as that's where
sd-boot is located, and sd-boot will set the var first, sd-stub will
only set it later if it#s not set yet.)
2022-11-22 01:32:51 +01:00
Lennart Poettering
7d1e61cab6 tree-wide: make constant ratelimit compound actually const
The compiler should recognize that these are constant expressions, but
let's better make this explicit, so that the linker can safely share the
initializations all over the place.
2022-11-22 01:30:55 +01:00
Jason A. Donenfeld
47b3e96647 boot: remove random-seed-mode
Now that the random seed is used on virtualized systems, there's no
point in having a random-seed-mode toggle switch. Let's just always
require it now, with the existing logic already being there to allow not
having it if EFI itself has an RNG. In other words, the logic for this
can now be automatic.
2022-11-22 01:30:03 +01:00
Luca Boccassi
a0c544ee09
Merge pull request #25379 from keszybz/update-doc-links
Update doc links
2022-11-22 01:07:13 +01:00
Zbigniew Jędrzejewski-Szmek
400102ec91 basic/strv: check printf arguments to strv_extendf()
The second argument to _printf_() specifies where the arguments start. We need to
use 0 in two cases: when the args in a va_list and can't be checked, and with journald
logging functions which accept multiple format strings with multiple argument sets,
which the _printf_ checker does not understand. But strv_extendf() can be checked.
2022-11-21 20:08:50 +01:00
Zbigniew Jędrzejewski-Szmek
6457ce15be manager: fix format strings for trigger metadata
Fixup for c8bc7519c8.
2022-11-21 20:08:50 +01:00
Lennart Poettering
7736a71fd2 dlfcn-util: add static asserts ensuring our sym_xyz() func ptrs match the types from the official headers
Make sure that the sym_xyz function pointers have the types that the
functions we'll assign them have.

And of course, this found a number of incompatibilities right-away, in
particular in the bpf hookup.

(Doing this will trigger deprecation warnings from libbpf. I simply
turned them off locally now, since we are well aware of what we are
doing in that regard.)

There's one return type fix (bool → int), that actually matters I think,
as it might have created an incompatibility on some archs.
2022-11-21 16:13:17 +01:00
Jason A. Donenfeld
a4eea6038c bootctl: install system token on virtualized systems
Removing the virtualization check might not be the worst thing in the
world, and would potentially get many, many more systems properly seeded
rather than not seeded. There are a few reasons to consider this:

- In most QEMU setups and most guides on how to setup QEMU, a separate
  pflash file is used for nvram variables, and this generally isn't
  copied around.

- We're now hashing in a timestamp, which should provide some level of
  differentiation, given that EFI_TIME has a nanoseconds field.

- The kernel itself will additionally hash in: a high resolution time
  stamp, a cycle counter, RDRAND output, the VMGENID uniquely
  identifying the virtual machine, any other seeds from the hypervisor
  (like from FDT or setup_data).

- During early boot, the RNG is reseeded quite frequently to account for
  the importance of early differentiation.

So maybe the mitigating factors make the actual feared problem
significantly less likely and therefore the pros of having file-based
seeding might outweigh the cons of weird misconfigured setups having a
hypothetical problem on first boot.
2022-11-21 15:13:26 +01:00
Daan De Meyer
261b14be76
Merge pull request #25461 from DaanDeMeyer/repart-followups
repart followups
2022-11-21 14:02:25 +01:00
Zbigniew Jędrzejewski-Szmek
db81144428 tree-wide: BLS and DPS are now on uapi-group website 2022-11-21 12:26:35 +01:00
Daan De Meyer
6b1ea55e0b repart: Rework PartitionTarget initialization 2022-11-21 11:47:13 +01:00
Daan De Meyer
488bb758c0 repart: Use fd based operations in partition_populate_directory() 2022-11-21 11:47:13 +01:00
Daan De Meyer
48b1e18aae repart: Remove redundant parentheses in partition_populate_directory() 2022-11-21 10:53:23 +01:00
Daan De Meyer
a9abef7f67 mkfs-util: Use FORK_CLOSE_ALL_FDS 2022-11-21 10:51:15 +01:00
Daan De Meyer
92b11378ff mkfs-util: Prefer fd based stat() where possible 2022-11-21 10:49:37 +01:00
Daan De Meyer
29ec4bce0e mkfs-util: Use GID_FMT 2022-11-21 10:46:59 +01:00
Daan De Meyer
922576e452 repart: Use ASSERT_PTR() in partition_encrypt() 2022-11-21 10:45:26 +01:00
Daan De Meyer
983154f518 repart: Use ftruncate() instead of posix_allocate() 2022-11-21 10:44:38 +01:00
Daan De Meyer
766f52f25c repart: Fix parse_filter_partitions() log messages 2022-11-21 10:36:37 +01:00
Daan De Meyer
53538e33e9 repart: Fix FilterPartitionsType enum name 2022-11-21 10:35:18 +01:00
Daan De Meyer
5f59807d2d repart: Rework unused partition number algorithm 2022-11-21 10:34:28 +01:00
Daan De Meyer
c1979cd881 repart: Use IN_SET() in one more place 2022-11-21 10:28:36 +01:00
Jan Janssen
967a868563 boot: Replace firmware security hooks directly
For some firmware, replacing their own security arch instance with our
override using ReinstallProtocolInterface() is not enough as they will
not use it. This commit goes back to how this was done before by
directly modifying the security protocols.

Fixes: #25336
2022-11-19 16:39:04 +01:00
Jan Janssen
5489c13bae boot: Rework security arch override
This simplifies the caller interface for security arch overrides by only
having to pass a validator and an optional context.
2022-11-19 16:37:27 +01:00
Jan Janssen
679007044f boot: Manually convert filepaths if needed
The conversion of a filepath device path to text is needed for the stub
loader to find credential files.
2022-11-19 16:36:02 +01:00
Jan Janssen
af7ef648cd boot: Do not require a loaded image path
If the device path to text protocol is not available (looking angrily at
Apple) we would fail to boot because we cannot get the loaded image
path. As this is only used for cosmetic purposes, we can just silently
continue.

Fixes: #25363
2022-11-19 16:36:02 +01:00
Jan Janssen
b7b327f856 boot: Fix memory leak 2022-11-19 16:36:02 +01:00
Yu Watanabe
da2e6df00a
Merge pull request #25438 from poettering/localhost-ifindex-tweak
resolved: fix ifindex for contacting per-interface DNS server if it is 127.0.0.1
2022-11-19 15:36:12 +09:00
Yu Watanabe
26627c088b
Merge pull request #25423 from yuwata/network-tc-cake-rtt-and-ack-filter
network: tc-cake: support controlling RTT and ACK filter
2022-11-19 15:35:49 +09:00
Mike Yuan
2d8cc7a7bb dbus-manager: add comments about booleans in function calls
Update to match the new coding style
See also: https://github.com/systemd/systemd/pull/25437#discussion_r1026934242
2022-11-19 14:34:08 +09:00
Yu Watanabe
8c92063633 network: tc-cake: add support to specify ACK filter 2022-11-19 07:08:22 +09:00
Lennart Poettering
af1bed8e83 bootctl: rework how we handle referenced but absent EFI boot entries
Follow-up for #25368.

Let's consider ENOENT an expected error, and just debug log about it
(though, let's suffix it with `, ignoring.`). All other errors will log
loudly, as they are unexpected errors.
2022-11-19 05:27:50 +09:00
Lennart Poettering
6e32414a66 resolved: when configuring 127.0.0.1 as per-interface DNS server, contact it via "lo" always
ussually if you specify a DNS server on some interface then we'll use
that interface to talk to it. Let's override this for localhost
addresses, as they only really make sense on "lo".

Fixes: #25397
2022-11-18 16:54:46 +01:00
Lennart Poettering
5faaed5b62 resolved: use right conditionalization when setting unicast ifindex on UDP sockets 2022-11-18 16:53:31 +01:00
Sam James
b9e7f22c2d nspawn: allow sched_rr_get_interval_time64 through seccomp filter
We only allow a selected subset of syscalls from nspawn containers
and don't list any time64 variants (needed for 32-bit arches when
built using TIME_BITS=64, which is relatively new).

We allow sched_rr_get_interval which cpython's test suite makes
use of, but we don't allow sched_rr_get_interval_time64.

The test failures when run in an arm32 nspawn container on an arm64 host
were as follows:
```
======================================================================
ERROR: test_sched_rr_get_interval (test.test_posix.PosixTester.test_sched_rr_get_interval)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/var/tmp/portage/dev-lang/python-3.11.0_p1/work/Python-3.11.0/Lib/test/test_posix.py", line 1180, in test_sched_rr_get_interval
    interval = posix.sched_rr_get_interval(0)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
PermissionError: [Errno 1] Operation not permitted
```

Then strace showed:
```
sched_rr_get_interval_time64(0, 0xffbbd4a0) = -1 EPERM (Operation not permitted)
```

This appears to be the only time64 syscall that isn't already included one of
the sets listed in nspawn-seccomp.c that has a non-time64 variant. Checked
over each of the time64 syscalls known to systemd and verified that none
of the others had a non-time64-variant whitelisted in nspawn other than
sched_rr_get_interval.

Bug: https://bugs.gentoo.org/880131
2022-11-18 16:32:17 +01:00
reuben olinsky
f8a7112c47 sysupdate: Support volatile-root for finding the root partition
The existing logic can't find the root device in scenarios where
the root has been replaced with an overlay. We support looking
at "/run/systemd/volatile-root" to find the original root, similar
to what systemd-repart and gpt-auto-generator do.
2022-11-18 16:31:22 +01:00
Lennart Poettering
eb2a610210
Merge pull request #25410 from DaanDeMeyer/mkfs-xfs-fixes
Followups for #25400
2022-11-18 14:45:48 +01:00
Li kunyu
fc0cc6db1e boot/measure: fix oom check 2022-11-18 21:02:03 +09:00
Li kunyu
f54f6d88b1
fuzz: fuzz-compress: fix copy-and-paste error: buf -> buf2 (#25431) 2022-11-18 15:03:41 +09:00
Luca Boccassi
daefca4611
Merge pull request #25414 from zx2c4-forks/krngseed
EFI random seed post #25319 review fixups
2022-11-17 19:49:40 +01:00
Daan De Meyer
0ae03a0fe7 kmod-setup: Make sure the tpm module is available early
Required for early boot services such as systemd-pcrphase-sysinit
which need early access to the tpm.
2022-11-17 18:17:44 +01:00
Lennart Poettering
fa4c01933d
Merge pull request #25333 from yuwata/find-esp-part-entry-scheme
find-esp: downgrade and ignore error on retrieving PART_ENTRY_SCHEME
2022-11-17 15:28:54 +01:00
Lennart Poettering
128a11ea99 signal-util: add common implementation for propagating a signal
i.e. let's add a common logic to be called from a signal handler to
raise the passed signal again.

Follow-up for: #25399
2022-11-17 22:38:14 +09:00
Daan De Meyer
f9fbac8b1f log: Remove log_ratelimit_debug() macros
These don't make sense anymore since we disable log ratelimiting
when logging at debug level.
2022-11-17 22:16:18 +09:00
Daan De Meyer
0b75744d5c repart: Write temporary LUKS header to /var/tmp instead of /tmp
This is a relatively large file so let's not create it in memory.
2022-11-17 14:15:28 +01:00
Daan De Meyer
48ac1fd132 Followups for aa6aa81c1e 2022-11-17 14:14:45 +01:00
Daan De Meyer
dd3c825294 tmpfile-util: Introduce fopen_temporary_child()
Instead of having fopen_temporary() create the file either next
to an existing file or in tmp/, let's split this up clearly into
two different functions, one for creating temporary files next to
existing files, and one for creating a temporary file in a directory.
2022-11-17 14:14:31 +01:00
Yu Watanabe
3af9cd0bf1 network: tc-cake: add support to specify RTT 2022-11-17 21:13:42 +09:00
Jason A. Donenfeld
1a2b1e10bd boot: only use __builtin_object_size with -O>0
__builtin_object_size() returns -1 with -O0, so disable this and warn
about it instead.
2022-11-17 12:23:17 +01:00
Jason A. Donenfeld
5d29d07b34 boot: do not truncate random seed file
There are concerns about the FAT file system driver exploding if we try
to do this, so just leave the bytes zeroed out instead.
2022-11-17 12:22:32 +01:00
Jason A. Donenfeld
3daeef0884 random-seed: handle post-merge review nits
These are various misc things that came up after merging.
2022-11-17 12:22:27 +01:00
Marcus Schäfer
305dd91adf Handle MACHINE_ID=uninitialized
systemd supports /etc/machine-id to be set to: uninitialized
In this case the expectation is that systemd creates a new
machine ID and replaces the value 'uninitialized' with the
effective machine id. In the scope of kernel-install we
should also enforce the creation of a new machine id in this
condition
2022-11-17 07:45:25 +09:00
Lennart Poettering
6337be0a4e pcrphase: add $SYSTEMD_PCRPHASE_STUB_VERIFY env var for overriding stub check 2022-11-17 07:44:11 +09:00
Vitaly Kuznetsov
155c51293d shared/tpm2-util: Fix "Error: Esys invalid ESAPI handle (40000001)" warning
systemd-cryptenroll complains (but succeeds!) upon binding to a signed PCR
policy:

$ systemd-cryptenroll --unlock-key-file=/tmp/passphrase --tpm2-device=auto
  --tpm2-public-key=... --tpm2-signature=..." /tmp/tmp.img

ERROR:esys:src/tss2-esys/esys_iutil.c:394:iesys_handle_to_tpm_handle() Error: Esys invalid ESAPI handle (40000001).
WARNING:esys:src/tss2-esys/esys_iutil.c:415:iesys_is_platform_handle() Convert handle from TPM2_RH to ESYS_TR, got: 0x40000001
ERROR:esys:src/tss2-esys/esys_iutil.c:394:iesys_handle_to_tpm_handle() Error: Esys invalid ESAPI handle (40000001).
WARNING:esys:src/tss2-esys/esys_iutil.c:415:iesys_is_platform_handle() Convert handle from TPM2_RH to ESYS_TR, got: 0x4000000
New TPM2 token enrolled as key slot 1.

The problem seems to be that Esys_LoadExternal() function from tpm2-tss
expects a 'ESYS_TR_RH*' constant specifying the requested hierarchy and not
a 'TPM2_RH_*' one (see Esys_LoadExternal() -> Esys_LoadExternal_Async() ->
iesys_handle_to_tpm_handle() call chain).

It all works because Esys_LoadExternal_Async() falls back to using the
supplied values when iesys_handle_to_tpm_handle() fails:

    r = iesys_handle_to_tpm_handle(hierarchy, &tpm_hierarchy);
    if (r != TSS2_RC_SUCCESS) {
        ...
        tpm_hierarchy = hierarchy;
    }

Note, TPM2_RH_OWNER was used on purpose to support older tpm2-tss versions
(pre https://github.com/tpm2-software/tpm2-tss/pull/1531), use meson magic
to preserve compatibility.

Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
2022-11-16 21:45:57 +01:00
Lennart Poettering
c204cfb2e8
Merge pull request #25399 from DaanDeMeyer/siginfo-crash
crash-handler: Make sure we propagate the original siginfo
2022-11-16 18:42:07 +01:00
Daan De Meyer
ffa8d1ba39
Merge pull request #25096 from DaanDeMeyer/journald-log-fixes
journal: Ratelimit more journald log messages
2022-11-16 16:40:00 +01:00
Daan De Meyer
2af3e23fc0 crash-handler: Make sure we propagate the original siginfo
If we call raise(), we lose the information from the original signal.
If we use rt_sigqueueinfo(), the original siginfo gets reused which
is helpful when debugging crashes.
2022-11-16 16:07:35 +01:00
Daan De Meyer
a0f95434c0 sigbus: Add fallback in case rt_tgsiqqueueinfo() fails 2022-11-16 16:07:31 +01:00
Daan De Meyer
aa6aa81c1e mkfs-util: Add support for rootless xfs population
We use mkfs.xfs's protofile (-p) support to achieve this. The
protofile is a description of the files that should be copied into
the filesystem. The format is described in the manpage of mkfs.xfs.
2022-11-16 15:38:17 +01:00
Luca Boccassi
39a306ba34
Merge pull request #25319 from zx2c4-forks/krngseed
boot: implement kernel EFI RNG seed protocol with proper hashing
2022-11-16 15:07:54 +01:00
Daan De Meyer
ee69f2b414 sigbus: Make sure the signal is delivered to the same thread 2022-11-16 15:07:23 +01:00
Daan De Meyer
a54219532d missing_syscall: Add rt_tgsigqueueinfo() 2022-11-16 15:03:41 +01:00
Lennart Poettering
1282fec93f
Merge pull request #25310 from jlinton/fpdt_dev_mem_alt
acpi-fpdt: Use kernel fpdt parsing
2022-11-16 14:55:17 +01:00
Lennart Poettering
45e99be3fb
Merge pull request #24855 from kraxel/qemu
better qemu support (handle direct kernel boot etc).
2022-11-16 14:53:42 +01:00
Lennart Poettering
155519f4a3
Merge pull request #25393 from poettering/tpm2-override
tpm2-util: force default TCTI to be "device" with parameter "/dev/tpm…
2022-11-16 14:30:26 +01:00
Gerd Hoffmann
8fec4f95be boot: improve support for qemu
systemd-boot expects being loaded from ESP and is quite unhappy in case
the loaded image device path is something else.  When running on qemu
this can easily happen though.  Case one is direct kernel boot, i.e.
loading via 'qemu -kernel systemd-bootx64.efi'.  Case two is sd-boot
being added to the ovmf firmware image and being loaded from there.

This patch detects both cases and goes inspect all file systems known to
the firmware, trying to find the ESP.  When present the
VMMBootOrderNNNN variables are used to inspect the file systems in the
given order.
2022-11-16 12:52:58 +01:00
Zbigniew Jędrzejewski-Szmek
b8d6b1608e
Merge pull request #24555 from medhefgo/bootctl
bootctl: Small improvements
2022-11-16 12:27:30 +01:00