Yu Watanabe [Mon, 26 Apr 2021 00:03:33 +0000 (09:03 +0900)]
network: update comment and log message
After
4b30f2e135ee84041bb597edca7225858f4ef4fb, reading stable_secret
sysctl property fails with -ENOMEM, instead of -EIO.
This is due to read_full_virtual_file() uses read() as the backend while
read_one_line_file() uses fgetc(). And each functions return different
error on fails.
Anyway, the failure is harmless here. So, the log message and comment is
updated.
Closes one of the issues in #19410.
Luca Boccassi [Mon, 26 Apr 2021 09:08:07 +0000 (10:08 +0100)]
Merge pull request #19421 from yuwata/fix-typo
core, network: Fix typo
Yu Watanabe [Sun, 25 Apr 2021 23:16:08 +0000 (08:16 +0900)]
network: add missing sections
Follow-up for
4e26a5baa0045c8bbb899f0c72f07ac630692bd3.
Fixes one of issues in #19410.
Yu Watanabe [Mon, 26 Apr 2021 00:20:24 +0000 (09:20 +0900)]
Yu Watanabe [Mon, 26 Apr 2021 00:19:38 +0000 (09:19 +0900)]
Lennart Poettering [Sat, 24 Apr 2021 07:17:38 +0000 (09:17 +0200)]
Merge pull request #19411 from poettering/homectl-fixes
homectl password caching fixes
Lennart Poettering [Fri, 23 Apr 2021 14:31:12 +0000 (16:31 +0200)]
homectl: pick up cached/credential store/env var passwords *before* issuing first request
Previously, we'd generally attempt the operation first, without any
passwords, and only query for a password if that operation then fails
and asks for one. This is done to improve compatibility with
password-less authentication schemes, such as security tokens and
similar.
This patch modifies this slightly: if a password can be acquired cheaply
via the keyring password cache, the $CREDENTIALS_PATH credential store,
or the $PASSWORD/$PIN environment variables, acquire it *before* issuing
the first requested.
This should save us a pointless roundtrip, and should never hurt.
Lennart Poettering [Fri, 23 Apr 2021 14:14:57 +0000 (16:14 +0200)]
homectl: don't use password cache if we operate on other user
Lennart Poettering [Fri, 23 Apr 2021 12:53:32 +0000 (14:53 +0200)]
homectl: don't use cached passwords when re-requesting password because wrong
Asking repeatedly for a password is pointless if we always use the same
cached one. Let's thus disable cache use whenever we failed already
once.
Lennart Poettering [Fri, 23 Apr 2021 15:17:26 +0000 (17:17 +0200)]
test: use systemd-run -P instead of -t in TEST-50
We want to use the result in a shell pipeline hence use -P mode (pipe
mode) instead of -t mode (interactive tty mode) for systemd-run.
This shouldn't change much about the test, but is slightly more correct
(and quicker).
Zbigniew Jędrzejewski-Szmek [Tue, 20 Apr 2021 15:47:50 +0000 (17:47 +0200)]
tests: use setfacl to give $SUDO_USER read permissions on artifacts
We have to invoke the tests as superuser, and not being able to read
the journal as the invoking user is annoying. I don't think there are
any security considerations here, since the invoking user can already
put arbitrary code in the Makefile and test scripts which get executed
with root privileges.
Luca Boccassi [Fri, 23 Apr 2021 15:43:45 +0000 (16:43 +0100)]
Merge pull request #19156 from dtardon/enable-warn
install: warn if WantedBy targets don't exist
Lennart Poettering [Wed, 7 Apr 2021 09:44:29 +0000 (11:44 +0200)]
fstab-generator: clean up mount point flags handling
Let's rename MountpointsFlags → MountPointFlags. In most of our codebase
we name things mount_point/MountPoint rather than mountpoint/Mountpoint,
do so here too.
Also, prefix the enum values with "MOUNT_". The fact the enum values
weren#t prefixed was pretty unique in our codebase, and pretty
surprising. Let's fix that.
This is just refactoring, no actual change in behaviour
Frantisek Sumsal [Thu, 22 Apr 2021 14:26:25 +0000 (16:26 +0200)]
test: configure swap for TEST-55-OOMD
oomd works way better with swap, so let's make the test less flaky by
configuring a swap device for it. This also allows us to drop the ugly
`cat`s from the load-generating script.
jiangchuangang [Fri, 23 Apr 2021 07:55:52 +0000 (15:55 +0800)]
logind:add missing equal sign
Lennart Poettering [Fri, 23 Apr 2021 09:31:34 +0000 (11:31 +0200)]
Merge pull request #19124 from takaswie/topic/fw-audio-entries
hwdb/rule: add database and rules for known audio and music unit in IEEE 1394 bus
Flos Lonicerae [Fri, 23 Apr 2021 07:57:14 +0000 (15:57 +0800)]
Add D-Bus property exposing Ctrl-Alt-Delete action (#19217)
David Tardon [Wed, 31 Mar 2021 08:38:00 +0000 (10:38 +0200)]
test-install-root: add test for unknown WantedBy= target
Jan Synacek [Wed, 3 Jun 2020 08:33:21 +0000 (10:33 +0200)]
install: warn if WantedBy targets don't exist
Currently, if [Install] section contains WantedBy=target that doesn't exist,
systemd creates the symlinks anyway. That is just user-unfriendly.
Let's be nice and warn about installing non-existent targets.
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=
1835351.
Replaces: #15834
David Tardon [Wed, 31 Mar 2021 08:08:31 +0000 (10:08 +0200)]
test-install-root: create referenced targets
Yu Watanabe [Thu, 22 Apr 2021 23:32:46 +0000 (08:32 +0900)]
Merge pull request #19392 from yuwata/network-dhcp-split-link_set_dhcp_routes
network: split link_set_dhcp_routes() into smaller functions
Lennart Poettering [Thu, 22 Apr 2021 14:39:06 +0000 (16:39 +0200)]
Merge pull request #19336 from pdmorrow/reloading_restart
core,test: services in reloading state should exit without waiting TimeoutStartSec
Dimitri John Ledkov [Thu, 22 Apr 2021 13:22:50 +0000 (14:22 +0100)]
Merge pull request #19346 from mihajlov/dhcp_broadcast_l3
network: enable DHCP broadcast flag if required by interface
Luca Boccassi [Thu, 22 Apr 2021 13:06:10 +0000 (14:06 +0100)]
Merge pull request #19390 from poettering/repart-copy-fixes
repart: fix CopyFiles= corner case when copying into root dir of newly formatted fs
Lennart Poettering [Thu, 22 Apr 2021 12:34:53 +0000 (14:34 +0200)]
dissect: fix two minor typos in comments
Emil Renner Berthing [Thu, 22 Apr 2021 07:33:51 +0000 (09:33 +0200)]
boot/efi: compile on riscv64
This makes systemd-boot compile against the latest gnu-efi which
just added support for riscv64.
Lennart Poettering [Thu, 22 Apr 2021 09:31:14 +0000 (11:31 +0200)]
dissect-image: prefer PARTN= uevent property over "partition" sysfs attr
The kernel will send us a PARTN= uevent proprty with partition add
events, let's use it instead of going for the "partition" sysfs attr.
It's less racy that way and there are reports the sysfs attr shows up
after the device, which makes it evern worse.
Peter Morrow [Tue, 13 Apr 2021 16:22:52 +0000 (17:22 +0100)]
test: add a test to cover restarting services in reloading state
Cover the case where a service is recovered out of reloading state via
a restart Restart= configuration.
Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
Peter Morrow [Tue, 13 Apr 2021 16:20:42 +0000 (17:20 +0100)]
core: allow services stuck in reloading state to exit
If a service is in reloading state but has exited do not delay
the final exit until the service reload timer expires. Instead allow
the service to exit immediately since we can't expect the service to
ever transition out of reloading state.
For example if a service sent RELOADING=1 but crashed before it could
send READY=1 then it should be restarted if the service had
Restart= configured.
Signed-off-by: Peter Morrow <pemorrow@linux.microsoft.com>
Jóhann B. Guðmundsson [Wed, 21 Apr 2021 21:09:29 +0000 (21:09 +0000)]
fix: point to the correct drop-ins subdirectory for confs
Lennart Poettering [Wed, 21 Apr 2021 15:38:21 +0000 (17:38 +0200)]
gpt: we actually honour the ReadOnly= flag on XBOOTLDR partitions too
The partition type is defined in our Discoverable Partition Spec, and we
honour the flag for it, hence allow setting it too.
Yu Watanabe [Sun, 11 Apr 2021 23:48:29 +0000 (08:48 +0900)]
network: dhcp4: simplify link_set_dns_routes()
Yu Watanabe [Sun, 11 Apr 2021 23:43:09 +0000 (08:43 +0900)]
network: dhcp4: introduce link_set_dhcp_gateway() and link_set_dhcp_route_to_gateway()
Yu Watanabe [Sun, 11 Apr 2021 23:22:24 +0000 (08:22 +0900)]
network: dhcp4: introduce link_set_dhcp_static_routes()
Yu Watanabe [Sun, 11 Apr 2021 10:11:26 +0000 (19:11 +0900)]
network: dhcp4: introduce link_set_dhcp_prefix_route()
Lennart Poettering [Wed, 21 Apr 2021 21:23:07 +0000 (23:23 +0200)]
repart: don't try to extract directory of root dir when copying directories
It's OK to specify the root dir as target directory when copying
directories. However, in that case path_extract_filename() is going to
fail, because the root dir simply has not filename.
Let's address that by moving the call further down into the loop, when
we made sure that the target dir doesn't exist yet (the root dir always
exists, hence this check is sufficient).
Moreover, in the branch for copying regular files, also move the calls
down, and generate friendly error messages in case people try to
overwrite dirs with regular files (and the root dir is just a special
case of a dir).
Altogether this makes CopyFiles=/some/place:/ work, i.e. copying some
dir on the host into the root dir of the newly created fs. Previously
this would fail with an error about the inability to extract a filename
from "/", needlessly.
Lennart Poettering [Wed, 21 Apr 2021 21:22:26 +0000 (23:22 +0200)]
repart: don't use basename() when we called path_extract_filename() anyway already
We already have the string, use it.
Lennart Poettering [Wed, 21 Apr 2021 21:21:21 +0000 (23:21 +0200)]
repart: prefix the correct path with root dir in log output
When we copy files into the freshly formatted file system, the mount
point prefix must be prepended to the *target* path, not the *source*
path. Not just in code but in the log message about it, too.
Zbigniew Jędrzejewski-Szmek [Wed, 21 Apr 2021 21:10:48 +0000 (23:10 +0200)]
Merge pull request #19387 from poettering/discoverable-part-fix
minor doc fixes
Igor Zhbanov [Tue, 20 Apr 2021 17:22:28 +0000 (17:22 +0000)]
journald: Retry if posix_fallocate returned -1 (EINTR)
On some conditions (particularly when mobile CPUs are going to sleep),
the posix_fallocate(), which is called when a new journal file is allocated,
can return -1 (EINTR). This is counted as a fatal error. So the journald
closes both old and journals, and simply throwing away further incoming
events, because of no log files open.
Introduce posix_fallocate_loop() that restarts the function in the case
of EINTR. Also let's make code base more uniform by returning negative
values on error.
Fix assert in test-sigbus.c that incorrectly counted positive values as
success. After changing the function return values, that will actually work.
Fixes: #19041
Signed-off-by: Igor Zhbanov <i.zhbanov@omprussia.ru>
Lennart Poettering [Wed, 21 Apr 2021 16:12:25 +0000 (18:12 +0200)]
doc: slightly reorder/improve partition type table
Let's put swap and generic linux data partitions next to each other, and
clarify they predated this spec.
Lennart Poettering [Wed, 21 Apr 2021 16:10:08 +0000 (18:10 +0200)]
doc: verity partitions may only contain Verity data (fix copypasta)
Lennart Poettering [Wed, 21 Apr 2021 15:00:45 +0000 (17:00 +0200)]
man: --add was renamed --copy-to when it was merged, fix man page reference to it
Lennart Poettering [Wed, 21 Apr 2021 19:59:35 +0000 (21:59 +0200)]
Merge pull request #19271 from yuwata/dhcp-duid-uuid
network: fix issues arround DHCP DUID-UUID
Lennart Poettering [Wed, 21 Apr 2021 19:45:14 +0000 (21:45 +0200)]
Merge pull request #19365 from keszybz/sd_id128_equals
Add sd_id128_in_set()
Lennart Poettering [Wed, 21 Apr 2021 19:43:33 +0000 (21:43 +0200)]
update TODO
Lennart Poettering [Wed, 21 Apr 2021 16:33:05 +0000 (18:33 +0200)]
Merge pull request #19381 from poettering/generator-tweaks
generator: two minor tweaks
Lennart Poettering [Wed, 7 Apr 2021 08:57:19 +0000 (10:57 +0200)]
generator: write out special systemd-fsck-usr.service
So far all file systems where checked by instances of
systemd-fsck@.service, with the exception of the root fs which was
covered by systemd-fsck-root.service. The special handling is necessary
to deal with ordering issues: we typically want the root fs to be
checked before all others, and — weirdly — allow mounting it before the
fsck done (for compat with initrd-less boots).
This adds similar special handling for /usr: if the hierarchy is placed
on a separate file system check it with a special
systemd-fsck-usr.service instead of a regular sysemd-fsck@.service
instance. Reason is again ordering: we want to allow mounting of /usr
without the root fs already being around in the initrd, to cover for
cases where the root fs is created on first boot and thus cannot be
mounted/checked before /usr.
Zbigniew Jędrzejewski-Szmek [Wed, 21 Apr 2021 16:20:49 +0000 (18:20 +0200)]
Merge pull request #19362 from yuwata/network-dhcp6-pd-log-19354
network: dhcp6: add logs about delegated prefix
Zbigniew Jędrzejewski-Szmek [Wed, 21 Apr 2021 16:14:32 +0000 (18:14 +0200)]
Merge pull request #19370 from mrc0mmand/shellcheck-pt4
More shellcheck shenanigans
Viktor Mihajlovski [Wed, 14 Apr 2021 11:01:35 +0000 (13:01 +0200)]
network: enable DHCP broadcast flag if required by interface
Some interfaces require that the DHCPOFFER message is sent via broadcast
if they can't receive unicast messages before they've been configured
with an IP address.
E.g., s390 ccwgroup network interfaces operating in layer3 mode face
this limitation. This can prevent the interfaces from receiving an
IP address via DHCP, if the have been configured for layer3.
To allow DHCP over such interfaces, we're introducing a new device
property ID_NET_DHCP_BROADCAST which can be set for those.
The networkd DHCP client will check whether this property is set
for an interface, and if so will set the broadcast flag, unless
the network configuration for the interface has an explicit
RequestBroadcast setting.
Besides that, we're adding a udev rule to set this device property
for ccwgroup devices operating in layer3 mode, which is the case
if the ID_NET_DRIVER property is qeth_l3.
Supercedes #18829
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 13:43:01 +0000 (15:43 +0200)]
repart: reword log message
The UUID does not exist, a partion with the UUID exists. So let's
say that the UUID is "already used" for clarity.
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 13:42:05 +0000 (15:42 +0200)]
partition,shared/gpt: use sd_id128_in_set()
I was worried that the text size will grow, but apparently that's not the
case:
With --optimization=2:
$ size build/src/shared/libsystemd-shared-248.a.p/gpt.c.o*
text data bss dec hex filename
3674 1104 0 4778 12aa build/src/shared/libsystemd-shared-248.a.p/gpt.c.o.old
3085 1104 0 4189 105d build/src/shared/libsystemd-shared-248.a.p/gpt.c.o
(I don't understand the generated assembly, even though it seems to work:
Disassembly of section .text.gpt_partition_type_is_usr_verity:
0000000000000000 <gpt_partition_type_is_usr_verity>:
bool gpt_partition_type_is_usr_verity(sd_id128_t id) {
0: 48 83 ec 08 sub $0x8,%rsp
return sd_id128_in_set(id,
4: 4c 8b 05 00 00 00 00 mov 0x0(%rip),%r8 # b <gpt_partition_type_is_usr_verity+0xb>
b: 31 c0 xor %eax,%eax
d: 4c 8b 0d 00 00 00 00 mov 0x0(%rip),%r9 # 14 <gpt_partition_type_is_usr_verity+0x14>
14: 48 8b 15 00 00 00 00 mov 0x0(%rip),%rdx # 1b <gpt_partition_type_is_usr_verity+0x1b>
1b: 48 8b 0d 00 00 00 00 mov 0x0(%rip),%rcx # 22 <gpt_partition_type_is_usr_verity+0x22>
22: 6a 00 pushq $0x0
24: 6a 00 pushq $0x0
26: ff 35 00 00 00 00 pushq 0x0(%rip) # 2c <gpt_partition_type_is_usr_verity+0x2c>
2c: ff 35 00 00 00 00 pushq 0x0(%rip) # 32 <gpt_partition_type_is_usr_verity+0x32>
32: ff 35 00 00 00 00 pushq 0x0(%rip) # 38 <gpt_partition_type_is_usr_verity+0x38>
38: ff 35 00 00 00 00 pushq 0x0(%rip) # 3e <gpt_partition_type_is_usr_verity+0x3e>
3e: ff 35 00 00 00 00 pushq 0x0(%rip) # 44 <gpt_partition_type_is_usr_verity+0x44>
44: ff 35 00 00 00 00 pushq 0x0(%rip) # 4a <gpt_partition_type_is_usr_verity+0x4a>
4a: ff 35 00 00 00 00 pushq 0x0(%rip) # 50 <gpt_partition_type_is_usr_verity+0x50>
50: ff 35 00 00 00 00 pushq 0x0(%rip) # 56 <gpt_partition_type_is_usr_verity+0x56>
56: ff 35 00 00 00 00 pushq 0x0(%rip) # 5c <gpt_partition_type_is_usr_verity+0x5c>
5c: ff 35 00 00 00 00 pushq 0x0(%rip) # 62 <gpt_partition_type_is_usr_verity+0x62>
62: e8 00 00 00 00 callq 67 <gpt_partition_type_is_usr_verity+0x67>
67: 85 c0 test %eax,%eax
69: 0f 95 c0 setne %al
GPT_USR_ARM_VERITY,
GPT_USR_ARM_64_VERITY,
GPT_USR_IA64_VERITY,
GPT_USR_RISCV32_VERITY,
GPT_USR_RISCV64_VERITY);
}
6c: 48 83 c4 68 add $0x68,%rsp
70: c3 retq
)
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 13:36:10 +0000 (15:36 +0200)]
sd-id128: add convenience functions to compare multiple sd_id128_t
Similar to sd_bus_error_has_names() that was added in
2b07ec316a0e25a3e10c270c7f6baee9e0187bf8.
It is made inline in the hope that the compiler will be able to optimize
all the va_args boilerplate away, and do an efficient comparison when
the arguments are all constants.
Yangyang Shen [Wed, 24 Mar 2021 13:23:01 +0000 (21:23 +0800)]
journald: enforce longer line length limit during "setup" phase of stream protocol
This PR made modification on Lennart Poettering's basis. Fix the LineMax's function failure problem.
Signed-off-by: Yangyang Shen <shenyangyang4@huawei.com>
Lennart Poettering [Wed, 7 Apr 2021 09:21:50 +0000 (11:21 +0200)]
generator: explain why systemd-root-fsck.service exists in a comment
Lennart Poettering [Wed, 7 Apr 2021 09:19:29 +0000 (11:19 +0200)]
generator: exit early when asked to generate fsck unit for / and /usr in initrd
Let's exit early if we are invoked to generate an fsck unit for the
rootfs or /usr of the initrd itself. The "systemd-root-fsck.service" and
"systemd-usr-fsck.service" units are after all for the host file
systems, and the initrd file hierarchy is from an unpacked cpio anyway.
Hence, this semantically doesn't really make sense, so quickly exit if
we detect this case. This allows us to remove some checks further down
the codepath.
Yu Watanabe [Wed, 21 Apr 2021 04:35:57 +0000 (13:35 +0900)]
network: dhcp: constify link_get_duid()
Yu Watanabe [Wed, 21 Apr 2021 04:21:02 +0000 (13:21 +0900)]
network: dhcp: introduce duid_needs_product_uuid() helper function
Yu Watanabe [Sat, 10 Apr 2021 02:47:50 +0000 (11:47 +0900)]
network: configure non-dhcp configs earlier even DUID-UUID is used by DHCP clients
Previously, if DUID-UUID is used, all configurations are configured
after networkd gets product uuid of machine.
This makes only DHCP clients are delayed, and other configs are
configured earlier.
Yu Watanabe [Sat, 10 Apr 2021 01:24:17 +0000 (10:24 +0900)]
network: make IAID and DUID for DHCPv6 configurable explicitly
Closes #18996.
Yu Watanabe [Fri, 9 Apr 2021 11:11:33 +0000 (20:11 +0900)]
network: move dhcp related conf parsers to networkd-dhcp-common.c
Yu Watanabe [Wed, 21 Apr 2021 11:51:31 +0000 (20:51 +0900)]
Merge pull request #19344 from yuwata/network-route-metric-19028
network: add RouteMetric= setting in [Address] and more
Lennart Poettering [Wed, 7 Apr 2021 09:22:21 +0000 (11:22 +0200)]
units: fix repart conditions to run if definitions exist in /sysroot + /sysusr
The systemd-repart code was already smart enough to look for definitions
there, but the unit file conditions made that pointless. Let's fix that.
Yu Watanabe [Wed, 21 Apr 2021 05:10:18 +0000 (14:10 +0900)]
doc: fix typo
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 13:33:09 +0000 (15:33 +0200)]
man: mention sd_id128_is_allf(), SD_ID128_ALLF
It was added in
670814387ba8973245c08123e7240669f51a55a8, but not
mentioned in the man pages.
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 13:09:22 +0000 (15:09 +0200)]
man: dedent examples in sd-id128 to 2 columns
In man pages, horizontal space it at premium, and everything should
generally be indented with 2 spaces to make it more likely that the
examples fit on a user's screen.
C.f.
798d3a524ea57aaf40cb53858aaa45ec702f012d.
Yu Watanabe [Tue, 20 Apr 2021 01:08:08 +0000 (10:08 +0900)]
network: dhcp6: logs about generated addresses in delegated prefix
Yu Watanabe [Tue, 20 Apr 2021 01:50:36 +0000 (10:50 +0900)]
network: dhcp6: logs about delegated prefixes
Closes #19354.
Yu Watanabe [Tue, 20 Apr 2021 01:49:21 +0000 (10:49 +0900)]
in-addr-util: introduce 'struct in_addr_prefix' and hash ops for it
Yu Watanabe [Tue, 20 Apr 2021 12:12:22 +0000 (21:12 +0900)]
in-addr-util: add assertions
Yu Watanabe [Sat, 17 Apr 2021 18:03:47 +0000 (03:03 +0900)]
test-network: update test for RouteMetric=
Yu Watanabe [Sat, 17 Apr 2021 17:37:13 +0000 (02:37 +0900)]
man: update explanation about route metric
Yu Watanabe [Sun, 18 Apr 2021 09:34:18 +0000 (18:34 +0900)]
network: set metric for prefix route of IPv4 link-local address
Yu Watanabe [Sat, 17 Apr 2021 17:49:15 +0000 (02:49 +0900)]
network: radv: add RouteMetric= setting in [IPv6Prefix]
Yu Watanabe [Sat, 17 Apr 2021 17:32:51 +0000 (02:32 +0900)]
network: dhcp6-pd: add RouteMetric= setting in [DHCPv6PrefixDelegation]
Yu Watanabe [Sat, 17 Apr 2021 17:31:13 +0000 (02:31 +0900)]
network: move RouteMetric= from [DHCPv6] to [IPv6AcceptRA]
As the value is used in the routes in RA.
Yu Watanabe [Sat, 17 Apr 2021 17:04:20 +0000 (02:04 +0900)]
network: dhcp4: also apply RouteMetric= setting in [DHCPv4] to prefix route
Yu Watanabe [Sat, 17 Apr 2021 17:02:29 +0000 (02:02 +0900)]
network: add RouteMetric= setting in [Address] section
Yu Watanabe [Sun, 18 Apr 2021 16:23:54 +0000 (01:23 +0900)]
network: show route metric in debug log
Yu Watanabe [Sat, 17 Apr 2021 16:32:19 +0000 (01:32 +0900)]
sd-netlink: add missing address types
Lennart Poettering [Tue, 20 Apr 2021 21:46:17 +0000 (23:46 +0200)]
Merge pull request #19371 from poettering/repart-initrd-usr-only
two /sysusr/ changes for repart, split out of #19234
Lennart Poettering [Tue, 20 Apr 2021 21:44:49 +0000 (23:44 +0200)]
Merge pull request #19372 from poettering/repart-initrd-usr-begin
fstab-generator: mount.usr= handling changes, split out of #19234
Lennart Poettering [Tue, 20 Apr 2021 21:43:57 +0000 (23:43 +0200)]
Merge pull request #19368 from poettering/loop-seqnum
loop-util: let's try harder to avoid loopback block device recycle issues
Frantisek Sumsal [Tue, 20 Apr 2021 11:02:02 +0000 (13:02 +0200)]
tools: shellcheck-ify most of the tool scripts
Lennart Poettering [Wed, 31 Mar 2021 15:18:25 +0000 (17:18 +0200)]
man: document new initrd-usr-fs.target
Lennart Poettering [Sat, 27 Mar 2021 12:47:25 +0000 (13:47 +0100)]
units: change order of settings to match order in other similar unit
Lennart Poettering [Wed, 7 Apr 2021 09:18:43 +0000 (11:18 +0200)]
repart: use /sysusr/ as --root= default in initrd, if mounted
Lennart Poettering [Fri, 26 Mar 2021 15:26:32 +0000 (16:26 +0100)]
repart: try harder to find OS prefix
This teaches repart to look for the root block device both as the
backing for /sysroot and for /sysusr/usr.
The latter is a new addition, and starts making more sense with the next
commit. It's about supporting systems that are shipped with only a /usr/
fs, but where a root fs is allocated and formatted on first boot via
systemd-repart (or a similar tool). In this case it's useful to be able
to mount the ultimate /usr/ early on without mounting the root fs
right-away (simple because the rootfs might not exist yet, and we need
the repart data encoded in /usr/ to actually format it). Hence, instead
of requiring that we mount /sysroot/ first and /sysroot/usr/ second as
we did so far, let's rearrange things slightly:
1. We mount the /usr/ file system we discover to /sysusr/usr/
2. We mount the root file system we discover to /sysroot/
3. Once both are established we bind mount /sysusr/usr/ to /sysroot/usr/
And that' it. The first two steps can happen in either order, and we can
access /usr/ with or without a rootfs being around.
This commit implements nothing of the above. Instead, it teaches
systemd-repart to check both /sysroot/ and /sysusr/ for repart drop-ins,
and use the first of these hierarchies it finds populated. This way
systemd-repart can be spawned once /usr is mounted and it will work
correctly without root fs having to exist, or we can invoke it when the
root fs is already mounted, where it also will work correctly.
Frantisek Sumsal [Mon, 19 Apr 2021 16:07:51 +0000 (18:07 +0200)]
src: shellcheck-ify shell scripts
Lennart Poettering [Wed, 7 Apr 2021 09:12:39 +0000 (11:12 +0200)]
fstab-generator: properly order generated mount units before "post" target units
Let's make sure, that our mount unit are properly ordered before the
"post" target unit even if DefaultDependencies= is used on the target
unit.
Lennart Poettering [Sat, 27 Mar 2021 12:47:04 +0000 (13:47 +0100)]
fstab-generator: extend logging a bit
Lennart Poettering [Fri, 26 Mar 2021 21:40:40 +0000 (22:40 +0100)]
fstab-generator: if usr= is specified, mount it to /sysusr/usr/ first
This changes the fstab-generator to handle mounting of /usr/ a bit
differently than before. Instead of immediately mounting the fs to
/sysroot/usr/ we'll first mount it to /sysusr/usr/ and then add a
separate bind mount that mounts it from /sysusr/usr/ to /sysroot/usr/.
This way we can access /usr independently of the root fs, without for
waiting to be mounted via the /sysusr/ hierarchy. This is useful for
invoking systemd-repart while a root fs doesn't exist yet and for
creating it, with partition data read from the /usr/ hierarchy.
This introduces a new generic target initrd-usr-fs.target that may be
used to generically order services against /sysusr/ to become available.
Lennart Poettering [Tue, 20 Apr 2021 15:21:22 +0000 (17:21 +0200)]
ci: drop test/TEST-50-DISSECT/deny-list-ubuntu-ci
Let's see if this makes the test stable on the CI.
Lennart Poettering [Tue, 20 Apr 2021 14:19:27 +0000 (16:19 +0200)]
dissect: ignore udev database entries from before the loopback attachment
This tries to shorten the race of device reuse a bit more: let's ignore
udev database entries that are older than the time where we started to
use a loopback device.
This doesn't fix the whole loopback device raciness mess, but it makes
the race window a bit shorter.
Lennart Poettering [Tue, 20 Apr 2021 14:08:43 +0000 (16:08 +0200)]
loop-util: track CLOCK_MONOTONIC timestamp immediately before attaching a loopback device
This is similar to the preceding work to store the uevent seqnum, but
this stores the CLOCK_MONOTONIC timestamp.
Why? This allows to validate udev database entries, to determine if they
were created *after* we attached the device.
The uevent seqnum logic allows us to validate uevent, and the timestamp
database entries, hence together we should be able to validate both
sources of truth for us.
(note that this is all racy, just a bit less racy, since we cannot
atomically attach loopback devices and get the timestamp for it, the
same way we can't get the uevent seqnum. Thus is shortens the race
window, but doesn#t close it).
Lennart Poettering [Tue, 20 Apr 2021 14:01:53 +0000 (16:01 +0200)]
sd-device: add API to query from when a udev database entry is
We already store a CLOCK_MONOTONIC timestamp for each device appearance,
let' make this queriable.
This is useful to determine whether a udev device database entry is from
a current appearance of the device or a previous one, by comparing it
with appropriately taken timestamps.
Lennart Poettering [Tue, 20 Apr 2021 13:57:29 +0000 (15:57 +0200)]
dissect: ignore old uevents when waiting for loopback partition scan
Let's drop all monitor uevent that were enqueued before we actually
started setting up the device.
This doesn't fix the race, but it makes the race window smaller: since
we cannot determine the uevent seqnum and the loopback attachment
atomically, there's a tiny window where uevents might be generated by
the device which we mistake for being associated with out use of the
loopback device.
Lennart Poettering [Tue, 20 Apr 2021 08:56:38 +0000 (10:56 +0200)]
loop-util: read kernel's uevent seqnum right before attaching a loopback device
Later, this will allow us to ignore uevents from earlier attachments a
bit better, as we can compare uevent seqnums with this boundary. It's
not a full fix for the race though, since we cannot atomically determine
the uevent and attach the device, but it at least shortens the window a
bit.
Lennart Poettering [Tue, 20 Apr 2021 15:10:45 +0000 (17:10 +0200)]
loop-util: initialize .devno in loop_device_open() too