]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
4 years agotest: add a test to cover restarting services in reloading state 19336/head
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>
4 years agocore: allow services stuck in reloading state to exit
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>
4 years agofix: point to the correct drop-ins subdirectory for confs
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

4 years agogpt: we actually honour the ReadOnly= flag on XBOOTLDR partitions too
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.

4 years agoMerge pull request #19387 from poettering/discoverable-part-fix
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

4 years agojournald: Retry if posix_fallocate returned -1 (EINTR)
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>
4 years agodoc: slightly reorder/improve partition type table 19387/head
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.

4 years agodoc: verity partitions may only contain Verity data (fix copypasta)
Lennart Poettering [Wed, 21 Apr 2021 16:10:08 +0000 (18:10 +0200)] 
doc: verity partitions may only contain Verity data (fix copypasta)

4 years agoman: --add was renamed --copy-to when it was merged, fix man page reference to it
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

4 years agoMerge pull request #19271 from yuwata/dhcp-duid-uuid
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

4 years agoMerge pull request #19365 from keszybz/sd_id128_equals
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()

4 years agoupdate TODO
Lennart Poettering [Wed, 21 Apr 2021 19:43:33 +0000 (21:43 +0200)] 
update TODO

4 years agoMerge pull request #19381 from poettering/generator-tweaks
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

4 years agogenerator: write out special systemd-fsck-usr.service
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.

4 years agoMerge pull request #19362 from yuwata/network-dhcp6-pd-log-19354
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

4 years agoMerge pull request #19370 from mrc0mmand/shellcheck-pt4
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

4 years agorepart: reword log message 19365/head
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.

4 years agopartition,shared/gpt: use sd_id128_in_set()
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
)

4 years agosd-id128: add convenience functions to compare multiple sd_id128_t
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.

4 years agojournald: enforce longer line length limit during "setup" phase of stream protocol
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>
4 years agogenerator: explain why systemd-root-fsck.service exists in a comment 19381/head
Lennart Poettering [Wed, 7 Apr 2021 09:21:50 +0000 (11:21 +0200)] 
generator: explain why systemd-root-fsck.service exists in a comment

4 years agogenerator: exit early when asked to generate fsck unit for / and /usr in initrd
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.

4 years agonetwork: dhcp: constify link_get_duid() 19271/head
Yu Watanabe [Wed, 21 Apr 2021 04:35:57 +0000 (13:35 +0900)] 
network: dhcp: constify link_get_duid()

4 years agonetwork: dhcp: introduce duid_needs_product_uuid() helper function
Yu Watanabe [Wed, 21 Apr 2021 04:21:02 +0000 (13:21 +0900)] 
network: dhcp: introduce duid_needs_product_uuid() helper function

4 years agonetwork: configure non-dhcp configs earlier even DUID-UUID is used by DHCP clients
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.

4 years agonetwork: make IAID and DUID for DHCPv6 configurable explicitly
Yu Watanabe [Sat, 10 Apr 2021 01:24:17 +0000 (10:24 +0900)] 
network: make IAID and DUID for DHCPv6 configurable explicitly

Closes #18996.

4 years agonetwork: move dhcp related conf parsers to networkd-dhcp-common.c
Yu Watanabe [Fri, 9 Apr 2021 11:11:33 +0000 (20:11 +0900)] 
network: move dhcp related conf parsers to networkd-dhcp-common.c

4 years agoMerge pull request #19344 from yuwata/network-route-metric-19028
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

4 years agounits: fix repart conditions to run if definitions exist in /sysroot + /sysusr
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.

4 years agodoc: fix typo
Yu Watanabe [Wed, 21 Apr 2021 05:10:18 +0000 (14:10 +0900)] 
doc: fix typo

4 years agoman: mention sd_id128_is_allf(), SD_ID128_ALLF
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.

4 years agoman: dedent examples in sd-id128 to 2 columns
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.

4 years agonetwork: dhcp6: logs about generated addresses in delegated prefix 19362/head
Yu Watanabe [Tue, 20 Apr 2021 01:08:08 +0000 (10:08 +0900)] 
network: dhcp6: logs about generated addresses in delegated prefix

4 years agonetwork: dhcp6: logs about delegated prefixes
Yu Watanabe [Tue, 20 Apr 2021 01:50:36 +0000 (10:50 +0900)] 
network: dhcp6: logs about delegated prefixes

Closes #19354.

4 years agoin-addr-util: introduce 'struct in_addr_prefix' and hash ops for it
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

4 years agoin-addr-util: add assertions
Yu Watanabe [Tue, 20 Apr 2021 12:12:22 +0000 (21:12 +0900)] 
in-addr-util: add assertions

4 years agotest-network: update test for RouteMetric= 19344/head
Yu Watanabe [Sat, 17 Apr 2021 18:03:47 +0000 (03:03 +0900)] 
test-network: update test for RouteMetric=

4 years agoman: update explanation about route metric
Yu Watanabe [Sat, 17 Apr 2021 17:37:13 +0000 (02:37 +0900)] 
man: update explanation about route metric

4 years agonetwork: set metric for prefix route of IPv4 link-local address
Yu Watanabe [Sun, 18 Apr 2021 09:34:18 +0000 (18:34 +0900)] 
network: set metric for prefix route of IPv4 link-local address

4 years agonetwork: radv: add RouteMetric= setting in [IPv6Prefix]
Yu Watanabe [Sat, 17 Apr 2021 17:49:15 +0000 (02:49 +0900)] 
network: radv: add RouteMetric= setting in [IPv6Prefix]

4 years agonetwork: dhcp6-pd: add RouteMetric= setting in [DHCPv6PrefixDelegation]
Yu Watanabe [Sat, 17 Apr 2021 17:32:51 +0000 (02:32 +0900)] 
network: dhcp6-pd: add RouteMetric= setting in [DHCPv6PrefixDelegation]

4 years agonetwork: move RouteMetric= from [DHCPv6] to [IPv6AcceptRA]
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.

4 years agonetwork: dhcp4: also apply RouteMetric= setting in [DHCPv4] to prefix route
Yu Watanabe [Sat, 17 Apr 2021 17:04:20 +0000 (02:04 +0900)] 
network: dhcp4: also apply RouteMetric= setting in [DHCPv4] to prefix route

4 years agonetwork: add RouteMetric= setting in [Address] section
Yu Watanabe [Sat, 17 Apr 2021 17:02:29 +0000 (02:02 +0900)] 
network: add RouteMetric= setting in [Address] section

4 years agonetwork: show route metric in debug log
Yu Watanabe [Sun, 18 Apr 2021 16:23:54 +0000 (01:23 +0900)] 
network: show route metric in debug log

4 years agosd-netlink: add missing address types
Yu Watanabe [Sat, 17 Apr 2021 16:32:19 +0000 (01:32 +0900)] 
sd-netlink: add missing address types

4 years agoMerge pull request #19371 from poettering/repart-initrd-usr-only
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

4 years agoMerge pull request #19372 from poettering/repart-initrd-usr-begin
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

4 years agoMerge pull request #19368 from poettering/loop-seqnum
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

4 years agotools: shellcheck-ify most of the tool scripts 19370/head
Frantisek Sumsal [Tue, 20 Apr 2021 11:02:02 +0000 (13:02 +0200)] 
tools: shellcheck-ify most of the tool scripts

4 years agoman: document new initrd-usr-fs.target 19372/head
Lennart Poettering [Wed, 31 Mar 2021 15:18:25 +0000 (17:18 +0200)] 
man: document new initrd-usr-fs.target

4 years agounits: change order of settings to match order in other similar unit
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

4 years agorepart: use /sysusr/ as --root= default in initrd, if mounted 19371/head
Lennart Poettering [Wed, 7 Apr 2021 09:18:43 +0000 (11:18 +0200)] 
repart: use /sysusr/ as --root= default in initrd, if mounted

4 years agorepart: try harder to find OS prefix
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.

4 years agosrc: shellcheck-ify shell scripts
Frantisek Sumsal [Mon, 19 Apr 2021 16:07:51 +0000 (18:07 +0200)] 
src: shellcheck-ify shell scripts

4 years agofstab-generator: properly order generated mount units before "post" target units
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.

4 years agofstab-generator: extend logging a bit
Lennart Poettering [Sat, 27 Mar 2021 12:47:04 +0000 (13:47 +0100)] 
fstab-generator: extend logging a bit

4 years agofstab-generator: if usr= is specified, mount it to /sysusr/usr/ first
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.

4 years agoci: drop test/TEST-50-DISSECT/deny-list-ubuntu-ci 19368/head
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.

4 years agodissect: ignore udev database entries from before the loopback attachment
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.

4 years agoloop-util: track CLOCK_MONOTONIC timestamp immediately before attaching a loopback...
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).

4 years agosd-device: add API to query from when a udev database entry is
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.

4 years agodissect: ignore old uevents when waiting for loopback partition scan
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.

4 years agoloop-util: read kernel's uevent seqnum right before attaching a 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.

4 years agoloop-util: initialize .devno in loop_device_open() too
Lennart Poettering [Tue, 20 Apr 2021 15:10:45 +0000 (17:10 +0200)] 
loop-util: initialize .devno in loop_device_open() too

4 years agoloop-util: port to random_u64_range()
Lennart Poettering [Tue, 20 Apr 2021 08:48:22 +0000 (10:48 +0200)] 
loop-util: port to random_u64_range()

Doesn't matter, but it's a bit easier to read I'd claim.

4 years agoloop-util: make loop_device_make() return fd in all code paths
Lennart Poettering [Tue, 20 Apr 2021 08:46:34 +0000 (10:46 +0200)] 
loop-util: make loop_device_make() return fd in all code paths

Previously, loop_device_make() would return the device fd in one success
code path, but not the other (where' we'd just return 0).
loop_device_open() returns it in all cases.

Hence, let's clean this up, and make sure in all success code paths of
both functions we return it (even though it strictly speaking is
redundant, since we return it in LoopDevice anyway, and currently noone
actually relies on this).

4 years agosd-device: use right clock when comparing initialization usec
Lennart Poettering [Tue, 20 Apr 2021 13:56:03 +0000 (15:56 +0200)] 
sd-device: use right clock when comparing initialization usec

we actually use CLOCK_MONOTONIC for the timestamp, hence when
comparing/subtracting it from the current time, also use
CLOCK_MONOTONIC.

4 years agosd-device: use right type for usec_initialized
Lennart Poettering [Tue, 20 Apr 2021 15:06:21 +0000 (17:06 +0200)] 
sd-device: use right type for usec_initialized

4 years agoupdate TODO
Lennart Poettering [Tue, 20 Apr 2021 13:33:15 +0000 (15:33 +0200)] 
update TODO

4 years agorelay role implementation
Yegor Alexeyev [Mon, 15 Mar 2021 20:19:52 +0000 (21:19 +0100)] 
relay role implementation

4 years agoman: fix typo
Yu Watanabe [Tue, 20 Apr 2021 09:59:24 +0000 (18:59 +0900)] 
man: fix typo

Follow-up for e73309c532999cb15490a78575dd882b24bbe96f.

4 years agodocument DefaultOOMPolicy
Miroslav Suchý [Tue, 20 Apr 2021 08:23:01 +0000 (10:23 +0200)] 
document DefaultOOMPolicy

the `man systemd.service` say:
   Defaults to the setting DefaultOOMPolicy= in systemd-system.conf(5) is set to
but there is no such line in this config.
This is the default value I extracted from
   systemctl show --property=DefaultOOMPolicy

4 years agowifi-util: do not set zero errno to log_debug_errno()
Yu Watanabe [Tue, 20 Apr 2021 00:23:33 +0000 (09:23 +0900)] 
wifi-util: do not set zero errno to log_debug_errno()

4 years agotest: make the test entrypoint scripts shellcheck-compliant
Frantisek Sumsal [Mon, 19 Apr 2021 11:01:59 +0000 (13:01 +0200)] 
test: make the test entrypoint scripts shellcheck-compliant

4 years agomount-util: make umount_and_rmdir_and_freep() cleanup handler deal with NULL
Lennart Poettering [Mon, 19 Apr 2021 20:50:32 +0000 (22:50 +0200)] 
mount-util: make umount_and_rmdir_and_freep() cleanup handler deal with NULL

4 years agoMerge pull request #19096 from poettering/repart-features
Lennart Poettering [Tue, 20 Apr 2021 08:20:22 +0000 (10:20 +0200)] 
Merge pull request #19096 from poettering/repart-features

repart: four new features: CopyBlocks=auto + --image= + ReadOnly=/Flags= + MakeDirectories=

4 years agoshell-completion: use base.lst, not xorg.lst
Peter Hutterer [Tue, 20 Apr 2021 07:09:48 +0000 (17:09 +1000)] 
shell-completion: use base.lst, not xorg.lst

Since 2005 xorg.lst has been the legacy symlink to the real file base.lst.

4 years agoMerge pull request #19356 from zxzax/sd-login-typos
Luca Boccassi [Mon, 19 Apr 2021 21:26:36 +0000 (22:26 +0100)] 
Merge pull request #19356 from zxzax/sd-login-typos

Fix some typos in sd-login header, docs

4 years agoupdate TODO 19096/head
Lennart Poettering [Tue, 23 Mar 2021 18:00:32 +0000 (19:00 +0100)] 
update TODO

4 years agotest: add test for new repart features
Lennart Poettering [Mon, 19 Apr 2021 15:30:33 +0000 (17:30 +0200)] 
test: add test for new repart features

4 years agodissect: ext4 and loopback files are unimpressed by read-only access
Lennart Poettering [Mon, 19 Apr 2021 20:47:33 +0000 (22:47 +0200)] 
dissect: ext4 and loopback files are unimpressed by read-only access

Even if we set up a loopback device read-only and mount it read-only
this means nothing, ext4 will still write through to the backing storage
file.

Yes, I lost 6h debugging time on this.

Apparently, we have to specify "norecovery" when mounting such file
systems, to force them into truly read-only mode. Let's do so.

4 years agorepart: add new ReadOnly= and Flags= settings for repart dropins
Lennart Poettering [Tue, 23 Mar 2021 15:16:42 +0000 (16:16 +0100)] 
repart: add new ReadOnly= and Flags= settings for repart dropins

Let's make the GPT partition flags configurable when creating new
partitions. This is primarily useful for the read-only flag (which we
want to set for verity enabled partitions).

This adds two settings for this: Flags= and ReadOnly=, which strictly
speaking are redundant. The main reason to have both is that usually the
ReadOnly= setting is the one wants to control, and it' more generic.
Moreover we might later on introduce inherting of flags from CopyBlocks=
partitions, where one might want to control most flags as is except for
the RO flag and similar, hence let's keep them separate.

4 years agorepart: add CopyBlocks=auto support
Lennart Poettering [Tue, 23 Mar 2021 13:12:38 +0000 (14:12 +0100)] 
repart: add CopyBlocks=auto support

When using systemd-repart as an installer that replicates the install
medium on another medium it is useful to reference the root
partition/usr partition or verity data that is currently booted, in
particular in A/B scenarios where we have two copies and want to
reference the one we currently use. Let's add a CopyBlocks=auto for this
case: for a partition that uses that we'll copy a suitable partition
from the host.

CopyBlocks=auto finds the partition to copy like this: based on the
configured partition type uuid we determine the usual mount point (i.e.
for the /usr partition type we determine /usr/, and so on). We then
figure out the block device behind that path, through dm-verity and
dm-crypt if necessary. Finally, we compare the partition type uuid of
the partition found that way with the one we are supposed to fill and
only use it if it matches (the latter is primarily important on
dm-verity setups where a volume is likely backed by two partitions and
we need to find the right one).

This is particularly fun to use in conjunction with --image= (where
we'll restrict the device search onto the specify device, for security
reasons), as this allows "duplicating" an image like this:

    # systemd-repart --image=source.raw --empty=create --size=auto target.raw

If the right repart data is embedded into "source.raw" this will be able
to create and initialize a partition table on target.raw that carrries
all needed partitions, and will stream the source's file systems onto it
as configured.

4 years agogpt: add some simple helpers for categorizing GPT partition types
Lennart Poettering [Mon, 22 Mar 2021 20:23:40 +0000 (21:23 +0100)] 
gpt: add some simple helpers for categorizing GPT partition types

4 years agoloop-util: store device major/minor in LoopDevice object
Lennart Poettering [Mon, 22 Mar 2021 20:22:22 +0000 (21:22 +0100)] 
loop-util: store device major/minor in LoopDevice object

Let's store this away. It's useful when matching up mounts (i.e.  struct
stat's .st_dev field) with loopback devices.

4 years agorepart: add high-level setting for creating dirs in formatted file systems
Lennart Poettering [Sat, 20 Mar 2021 13:05:28 +0000 (14:05 +0100)] 
repart: add high-level setting for creating dirs in formatted file systems

So far we already had the CopyFiles= option in systemd-repart drop-in
files, as a mechanism for populating freshly formatted file systems with
files and directories. This adds MakeDirectories= in similar style, and
creates simple directories as listed. The option is of course entirely
redundant, since the same can be done with CopyFiles= simply by copying
in a directory. It's kinda nice to encode the dirs to create directly in
the drop-in files however, instead of providing a directory subtree to
copy in somehere, to make the files more self-contained — since often
just creating dirs is entirely sufficient.

The main usecase for this are GPT OS images that carry only a /usr/
tree, and for which a root file system is only formatted on first boot
via repart.  Without any additional CopyFiles=/MakeDirectories=
configuration these root file systems are entirely empty of course
initially. To mount in the /usr/ tree, a directory inode for /usr/ to
mount over needs to be created.  systemd-nspawn will do so automatically
when booting up the image, as will the initrd during boot. However, this
requires the image to be writable – which is OK for npawn and
initrd-based boots, but there are plenty tools where read-only operation
is desirable after repart ran, before the image was booted for the first
time. Specifically, "systemd-dissect" opens the image in read-only to
inspect its contents, and this will only work of /usr/ can be properly
mounted. Moreover systemd-dissect --mount --read-only won't succeed
either if the fs is read-only.

Via MakeDirectories= we now provide a way that ensures that the image
can be mounted/inspected in a fully read-only way immediately after
systemd-repart completed. Specifically, let's consider a GPT disk image
shipping with a file usr/lib/repart.d/50-root.conf:

       [Partition]
       Type=root
       Format=btrfs
       MakeDirectories=/usr
       MakeDirectories=/efi

With this in place systemd-repart will create a root partition when run,
and add /usr and /efi into it as directory inods. This ensures that the
whole image can then be mounted truly read-only anf /usr and /efi can be
overmounted by the /usr partition and the ESP.

4 years agorepart: use free_and_strdup_warn() where appropriate
Lennart Poettering [Fri, 19 Mar 2021 21:45:28 +0000 (22:45 +0100)] 
repart: use free_and_strdup_warn() where appropriate

4 years agorepart: deal with empty partition label sensibly
Lennart Poettering [Fri, 19 Mar 2021 21:45:15 +0000 (22:45 +0100)] 
repart: deal with empty partition label sensibly

libfdisk appears to return NULL when encountering an empty partition
label, let's handle this sanely, and treat NULL and "" for the current
label as the same, but for the new label as distinct: there NULL means
nothing is set, and "" means an actual empty label.

4 years agorepart: handle DISCARD failing with EBUSY gracefully
Lennart Poettering [Fri, 19 Mar 2021 21:25:09 +0000 (22:25 +0100)] 
repart: handle DISCARD failing with EBUSY gracefully

4 years agorepart: add one more overflow check
Lennart Poettering [Fri, 19 Mar 2021 21:24:48 +0000 (22:24 +0100)] 
repart: add one more overflow check

4 years agorepart: when we can't fit in all partitions explain how large the image would have...
Lennart Poettering [Fri, 19 Mar 2021 19:31:29 +0000 (20:31 +0100)] 
repart: when we can't fit in all partitions explain how large the image would have to be

4 years agorepart: add --image= switch
Lennart Poettering [Fri, 19 Mar 2021 10:19:00 +0000 (11:19 +0100)] 
repart: add --image= switch

This is similar to the --image= switch in the other tools, like
systemd-sysusers or systemd-tmpfiles, i.e. it apply the configuration
from the image to the image.

This is particularly useful for downloading minimized GPT image, and
then extending it to the desired size via:

   # systemd-repart --image=foo.image --size=5G

4 years agorepart: slightly improve error message if partition is not on dm-crypt/dm-verity
Lennart Poettering [Fri, 19 Mar 2021 10:16:22 +0000 (11:16 +0100)] 
repart: slightly improve error message if partition is not on dm-crypt/dm-verity

4 years agorepart: move NOP destructors into shared code
Lennart Poettering [Thu, 18 Mar 2021 21:47:24 +0000 (22:47 +0100)] 
repart: move NOP destructors into shared code

4 years agodissect: split read-only flag into two
Lennart Poettering [Fri, 19 Mar 2021 21:19:08 +0000 (22:19 +0100)] 
dissect: split read-only flag into two

Let's have one flag to request that when dissecting an image the
loopback device is made read-only, and another one to request that when
it is mounted to make it read-only. Previously both concepts were always
done read-only together.

(Of course, making the loopback device read-only but mounting it
read-write doesn't make too much sense, but the kernel should catch that
for us, no need to make restrictions from our side there)

Use-case for this: in systemd-repart we'd like to operate on images for
adding partitions. Thus we'd like to have the loopback device writable,
but if we read repart.d/ snippets from it, we want to do that read-only.

4 years agorepart: port more code to generic path_simplify_and_warn()
Lennart Poettering [Mon, 19 Apr 2021 15:50:02 +0000 (17:50 +0200)] 
repart: port more code to generic path_simplify_and_warn()

We have this nice helper, hence use it when parsing paths and logging
about it.

4 years agorepart: fix incorrect error code propagation
Lennart Poettering [Mon, 19 Apr 2021 15:35:54 +0000 (17:35 +0200)] 
repart: fix incorrect error code propagation

4 years agoudev/cdrom_id: add forgotten return and fix typo
Zbigniew Jędrzejewski-Szmek [Mon, 19 Apr 2021 14:00:05 +0000 (16:00 +0200)] 
udev/cdrom_id: add forgotten return and fix typo

Fixup for 092c05717c.

4 years agosd-login: fix wrong constructor used in sd_login_monitor manpage example 19356/head
Jason Francis [Mon, 19 Apr 2021 16:16:26 +0000 (12:16 -0400)] 
sd-login: fix wrong constructor used in sd_login_monitor manpage example