Frantisek Sumsal [Wed, 25 Jan 2023 12:21:09 +0000 (13:21 +0100)]
partition: fix build with newer linux/btrfs.h uapi header
linux/btrfs.h needs to be included after sys/mount.h, as since [0]
linux/btrfs.h includes linux/fs.h causing build errors:
```
In file included from /usr/include/linux/fs.h:19,
from ../src/basic/linux/btrfs.h:29,
from ../src/partition/growfs.c:6:
/usr/include/sys/mount.h:35:3: error: expected identifier before numeric constant
35 | MS_RDONLY = 1, /* Mount read-only. */
| ^~~~~~~~~
[1222/2169] Compiling C object systemd-creds.p/src_creds_creds.c.o
ninja: build stopped: subcommand failed.
```
Frantisek Sumsal [Wed, 25 Jan 2023 11:37:49 +0000 (12:37 +0100)]
basic/linux: update linux uapi headers
IPPROTO_L2TP was moved from linux/l2tp.h to linux/in.h [0], so let's
reflect that change to fix build with newer kernels:
```
In file included from ../src/libsystemd/sd-netlink/netlink-types-genl.c:10:
../src/basic/linux/l2tp.h:16: error: "IPPROTO_L2TP" redefined [-Werror]
16 | #define IPPROTO_L2TP 115
|
In file included from ../src/libsystemd/sd-netlink/netlink-types-genl.c:3:
/usr/include/netinet/in.h:85: note: this is the location of the previous definition
85 | #define IPPROTO_L2TP IPPROTO_L2TP
|
cc1: all warnings being treated as errors
```
When at it, update the rest of the headers we ship as well.
- add missing error cause in logging,
- add several missing assertions,
- drop an unnecessary initialization,
- make boot_config_find_in() return negative errno if nothing found,
- and several coding style fixlets.
Yu Watanabe [Wed, 25 Jan 2023 02:05:46 +0000 (11:05 +0900)]
bootctl-uki: several follow-ups for inspect_osrel()
Follow-ups for #26124 and #26158.
- use os_release_pretty_name(),
- constify the buffer passed to inspect_osrel(),
- propagate errors in inspect_osrele(), and ignore them in the caller
side,
- and several coding style fixlets.
Frantisek Sumsal [Wed, 25 Jan 2023 10:35:06 +0000 (11:35 +0100)]
coccinelle: skip the empty-to-null transformation on the macro itself
Since the empty_to_null() function was "macrofied", we need to use a bit
of black magic to make Coccinelle avoid running the transformation on
the macro itself.
shared/efi-loader: fix compilation with !ENABLE_EFI, improve messages
When compiled without ENABLE_EFI, efi_stub_measured() was not defined, so
compilation would fail. But it's not enough to add a stub that returns
-EOPNOTSUPP. We call this function in various places and usually print the error
at warning or error level, so we'd print a confusing message. We also can't add
a stub that always returns 0, because then we'd print a message like "Kernel
stub did not measure", which would be confusing too. Adding special handling for
-EOPNOTSUPP in every caller is also unattractive. So instead efi_stub_measured()
is reworked to log the warning or error internally, and such logging is removed
from the callers, and a stub is added that logs a custom message.
Luca Boccassi [Tue, 24 Jan 2023 17:18:31 +0000 (17:18 +0000)]
locale: rename new XKB variables to match Debian/Ubuntu's
Debian/Ubuntu use almost the same variables, but without '_'. Given
our usage is new, rename them so that they match and downstream tech
debt can be removed.
Follow-up for https://github.com/systemd/systemd/pull/25805
The timeout was raised during review and I wrote that I lowered it, but forgot
to actually commit the diff. Follow-up for 31f62bdd79472c32d52408956d5c82e9991ca425.
path-util: rework file_in_same_dir() on top of path_extract_directory()
Let's port one more over.
Note that this changes behaviour of file_in_same_dir() in some regards.
Specifically, a trailing slash of the input path will be treated
differently: previously we'd operate below that dir then, instead of the
parent. I think that makes little sense however, and I think the code
using this function doesn't expect that either.
Moroever, addresses some corner cases if the path is specified as "/" or
".", i.e. where e cannot extract a parent. These will now be treated as
error, which I think is much cleaner.
os-util: determine distro EOL in UTC, not local timezone
Presumably vendors establish a global EOL time, hence its better to
interpret the date specification everywhere the same, instead of
timezone dependent.
man: fix explanation for Credential= match in .link files
.link files are handled by systemd-udevd, not by systemd-networkd,
so fix the man page to say that the Credential= match uses credentials set
on the systemd-udevd.service
Callum Farmer [Thu, 12 Jan 2023 19:19:56 +0000 (19:19 +0000)]
boot: Use objcopy with arm64
Binutils 2.38 added support for efi-app-aarch64
Still use binary mode if we have an older objcopy
Add check for incompatible gnu-efi crt0 containing the header section
which gets added by objcopy and if used results in duplicate header
and subsequently a broken binary
Those hashmaps are created anew in each iteration of the loop. The
leak wasn't really a problem, because the loop is bounded and the
hashmaps were not huge, but it's nicer to be correct.
sleep: reduce double logging and improve messages and comments a bit
read_battery_capacity_percentage() was already logging, but with a slightly
different wording.
More could be done, I just touched the most noticable places. Especially
in debug messages, it is much more useful to be direct about what couldn't
be accessed or parsed, instead of providing "descriptive names" which are
not useful to the user at all, who then needs to read the code to figure out
what was the actual property name.
sleep: do not abort if we try to query capacity of missing battery
Fixes #25584.
From the issue:
Assertion 'capacity >= 0' failed at src/shared/sleep-config.c:58, function PTR_TO_CAPACITY(). Aborting.
(gdb) bt
The problem is that PTR_TO_CAPACITY(hashmap_get(last_capacity, battery_name))
will abort if it's called with a name not present in the hashmap. We want to
skip the device silently in this case instead.
Luca Boccassi [Fri, 20 Jan 2023 23:00:38 +0000 (23:00 +0000)]
core: ensure init.scope is realized after drop-ins have been loaded
If we add a drop-in for init.scope (e.g.: to set some memory limit),
it will be loaded long after the cgroup has already been realized.
Do it again when creating the special unit.
We also modify the repart integration tests to make them pass with the
changes in this commit. In short, we have to make sure every file is
owned by the user executing repart. We use tee instead of cat since it
makes that easier. This also has the benefit of improving debugability
as seeing the config file contents on stdout makes it easier to know
which test is failing.
Yu Watanabe [Fri, 23 Dec 2022 01:34:36 +0000 (10:34 +0900)]
locale: make errors in writing files not critical
Suggested at https://github.com/systemd/systemd/pull/25805#discussion_r1054871210
> we now write multiple files and we cannot possibly guarantee that
> either both updates worked or neither. unix fs apis simply have
> no concept that would allow us to implement that. hence I think
> we should update what we can, log about what we cannot, but return
> success as long as our in-memory state was updated.
Yu Watanabe [Tue, 20 Dec 2022 12:36:01 +0000 (21:36 +0900)]
locale: several coding style fixlets
- add missing assertions,
- rename arguments for storing results,
- always initialize results on success,
- use _cleanup_ attribute at more places, etc.