Commit Graph

40112 Commits

Author SHA1 Message Date
Yu Watanabe
0cf1fe8888 network: make sec_to_usec() map 0sec -> 0usec
Zero lifetime in RA is special, and we should not assign possibly very
short lifetime addresses or friends.

This should not change anything at least now, preparation for later
commits. Note, DHCPv4 and v6 code also uses it, but sd-dhcp-client and
sd-dhcp6-client already filtered messages with zero lifetime. Hence,
the change should not affect DHCP code.
2022-10-04 00:25:14 +09:00
Yu Watanabe
773024685b network: ndisc: also introduce timer event source to drop outdated settings
Otherwise, settings based on previously received RA messages will never
removed without receiving a new RA message.
2022-10-04 00:25:14 +09:00
Yu Watanabe
94e6d37c2b network: ndisc: drop outdated settings before processing RA message
Otherwise, e.g. if a router is replaced, then the previously received
settings may never dropped.

Follow-up for 2ccada8dc4.
2022-10-04 00:25:14 +09:00
Yu Watanabe
8d1babc51d network: ndisc: address_get() returns 0 on success
After the commit 3b6a3bdebf, address_get()
does not return 1.
2022-10-04 00:25:14 +09:00
Yu Watanabe
d4b7631468 network: introduce {address,route}_remove_and_drop()
Preparation for later commits.
2022-10-04 00:25:14 +09:00
Yu Watanabe
a115c60e0d network: ndisc: ignore prefix option with link-local prefix
See https://www.rfc-editor.org/rfc/rfc4861#section-4.6.2.
2022-10-04 00:25:14 +09:00
Yu Watanabe
167c7ae511 network: ndisc: read prefix earlier
No functional changes.
2022-10-04 00:25:14 +09:00
Daan De Meyer
898db9f3cf repart: Use chase_symlinks() instead of path_join()
Let's properly resolve symlinks and check if the source actually
exists.
2022-10-03 14:16:13 +01:00
Luca Boccassi
419f2742e7 repart: workaround spurious maybe-uninitialized warning
Build fails on Ubuntu Jammy
2022-10-03 10:26:31 +01:00
Yu Watanabe
0a8720c7f0 network: fix use-after-free
If the lifetime of the route is already expired, do not try to
configure it.

Fixes a use-after-free, as the Request object is already freed, thus, we
cannot use Route or Link stored in Request object.
2022-10-03 09:15:10 +02:00
Yu Watanabe
2ff7862bf2 resolve: drop remaining references for Monitor=
Follow-up for b25d819aee.
2022-10-03 08:26:05 +02:00
Thomas Hebb
2ccada8dc4 network: don't forget old RAs when a new one arrives
IPv6 Neighbor Discovery lets us autoconfigure a link's IPv6 addresses,
routes, DNS servers, and DNS search domains by listening for Router
Advertisement (RA) packets broadcast by one or more routers on the link.
Each RA can contain zero or more "options," each describing one piece of
configuration (e.g. a single route).

Currently, when we receive an RA from a router, we delete any addresses,
routes, etc. that originated from that router's previous RAs unless
they're also present as options in the new RA.

That behavior is a violation of RFC 4861[1]. In Section 9, the RFC
states that

    Senders MAY send a subset of options in different packets. ... Thus,
    a receiver MUST NOT associate any action with the absence of an
    option in a particular packet. This protocol specifies that
    receivers should only act on the expiration of timers and on the
    information that is received in the packets.

Several other passages in the RFC reiterate this. Section 6.2.3:

    A router MAY choose not to include some or all options when sending
    unsolicited Router Advertisements.

Section 6.3.4:

    Hosts accept the union of all received information; the receipt of a
    Router Advertisement MUST NOT invalidate all information received in
    a previous advertisement or from another source.

At least one consumer router in production today, the Google Nest Wifi,
often sends RAs that omit its global IPv6 prefix. When current versions
of systemd-networkd receive those RAs, they immediately delete the
interface's global IPv6 address, which breaks IPv6 connectivity.

Fix the issue by removing the invalidation logic entirely. It's not
needed at all, since we already invalidate addresses, routes, and DNS
configuration when the interface goes down or their lifetimes expire.

This fix does have the side effect of preventing changes to the .network
file (e.g. denylisted prefixes, whether to add routes from RAs) from
taking effect as soon as a new RA arrives. Instead, a full interface
reconfiguration is needed. But triggering those changes on RA receipt
was already rather arbitrary and out of the administrator's control, so
I think this change is fine.

commit 69203fba70 ("network: ndisc: remove old addresses and routes
after at least one SLAAC address becomes ready") introduced this
behavior. commit 50550722e3 fixed it partially, by preventing one
router's RAs from invalidating another router's configuration.

[1] https://www.rfc-editor.org/rfc/rfc4861

Fixes: 69203fba70 ("network: ndisc: remove old addresses and routes after at least one SLAAC address becomes ready")
2022-10-03 09:59:37 +09:00
Yu Watanabe
64ebc0da03 resolve: fix typo 2022-10-03 09:23:37 +09:00
Daan De Meyer
f0e6cb196e repart: Take --root into account in read only filesystems shortcut 2022-10-03 08:00:07 +09:00
Daan De Meyer
8e52ed024d repart: Don't fail on missing verity sig partition
Also, provide a proper error message when we fail to find a verity
sibling partition.
2022-10-02 14:08:34 +01:00
Luca Boccassi
3cd1b8f403 Merge pull request #24878 from keszybz/condition-first-boot
Tweak condition first boot to use the same logic in pid1 and units
2022-10-01 19:30:21 +01:00
Zbigniew Jędrzejewski-Szmek
7cd43e34c5 manager: fix/change evaluation of ConditionFirstBoot
The code to evaluate the kernel command line option was busted because it
was doing 'return b == !!r' at a point where 'r > 0'. Thus we'd return "true"
in both cases:

$ SYSTEMD_PROC_CMDLINE=systemd.condition-first-boot build/systemd-analyze condition 'ConditionFirstBoot=true'
test.service: ConditionFirstBoot=true succeeded.
Conditions succeeded.
$ SYSTEMD_PROC_CMDLINE=systemd.condition-first-boot build/systemd-analyze condition 'ConditionFirstBoot=false'
test.service: ConditionFirstBoot=false succeeded.
Conditions succeeded.

We only use 'ConditionFirstBoot=true' in units, so this wasn't noticed.

But I think the logic is broken in general: the condition should evaluate as
true only during initial boot. If we rerun the units at later points, we should
not consider ConditionFirstBoot to be true.

Also, the first boot logic is also used in pid1 itself. AFAICT, for two
things: in first boot machine-id is initialized transiently (this allows
first-boot operations to be restarted if boot fails), and preset-all is
executed. But this logic was different and separate from the logic to
evaluate ConditionFirstBoot. The distinction is abolished, and the operations
in pid1 now use the same logic as ConditionFirstBoot, which means that the
kernel command line option is checked, and condition_test_first_boot()
just tests whether pid1 thinks we're in first boot.

This makes things easier to grok for the user: there's just one condition for
"first boot" and it applies to both pid1 and units.
2022-10-01 11:35:46 +02:00
James Hilliard
0d73603b25 Revert "bpf: fix is_allow_list section"
GCC was modified to use the same default section as LLVM, as such
this is no longer required.

Details:
a0aafbc324

This reverts commit e8b1e9cf10.
2022-10-01 13:24:50 +09:00
Luca Boccassi
7b8e0c3e9f Merge pull request #24829 from yuwata/blockdev-new-from-fd
blockdev-util: introduce block_device_new_from_fd() and _path()
2022-09-30 20:07:49 +01:00
Luca Boccassi
e2ee0c0327 Merge pull request #24749 from yuwata/dissect-image-file
dissect-image: introduce dissect_image_file() which works for regular file instead of block device
2022-09-30 20:02:19 +01:00
Jacek Migacz
1ca3600120 resolve: unsupported DNSSEC algorithms are considered INSECURE; not BOGUS
Resolves: #19824
2022-09-30 18:46:08 +01:00
Zbigniew Jędrzejewski-Szmek
f4e5569190 Merge pull request #24639 from yuwata/test-mountpoint-util
test-mountpoint-util: support running on a mount namespace with another mount on /proc
2022-09-30 17:34:21 +02:00
Luca Boccassi
697f082697 Merge pull request #24853 from poettering/resolved-monitor-fixes
resolved: various monitor fixes
2022-09-30 15:46:13 +01:00
Luca Boccassi
e69e3830c3 Merge pull request #24739 from keszybz/coredump-formatting
Improve formatting of package metadata in coredumps
2022-09-30 15:42:15 +01:00
Zbigniew Jędrzejewski-Szmek
eb650ffedf firstboot: add debug logging
$ SYSTEMD_LOG_LEVEL=debug build/systemd-firstboot --prompt-root-password
Found container virtualization systemd-nspawn.
Found /etc/locale.conf, assuming locale information has been configured.
Failed to read credential firstboot.keymap, ignoring: No such device or address
Prompting for keymap was not requested.
Found /etc/localtime, assuming timezone has been configured.
Prompting for hostname was not requested.
Found /etc/machine-id, assuming machine-id has been configured.
Found /etc/passwd and /etc/shadow, assuming root account has been initialized.
Creation of /etc/kernel/cmdline was not requested, skipping.
2022-09-30 16:09:56 +02:00
Christian Hesse
e879434df5 systemctl: color ignored exit status in yellow, not red
If the executable path is prefixed with "-", an exit code of the command
normally considered a failure (i.e. non-zero exit status or abnormal exit
due to signal) is recorded, but has no further effect and is considered
equivalent to success.

Let's honor this with `systemctl status`, and color ignored exit status
in yellow, not red.
2022-09-30 15:02:50 +01:00
Jonas Kümmerlin
1355672437 generator: skip fsck if fsck command is missing
This is useful for systems which don't have any fsck.

We already skip emitting the fsck dependency when the fsck.$fstype helper
is missing, but fstab-generator doesn't necessarily know the fstype when
handling the root= parameter.

Previously, systemd-fsck was started for these mounts and then exited
immediately because it couldn't find the fsck.$fstype helper.
2022-09-30 15:01:41 +01:00
Luca Boccassi
ace212f577 portablectl: add --force attach/detach
Allows to skip check that ensures units must not be running.

I have a use case that would use reattach, except the orchestrator
is using a non-standard versioning scheme, so image matching cannot
work. As a workaround, need to be able to detach and then attach
manually, without stopping the units to avoid extended downtimes
and loss of FD store.
2022-09-30 13:25:31 +01:00
Lennart Poettering
fffbf1dc99 resolvectl: add new "monitor" verb 2022-09-30 14:24:08 +02:00
Franck Bui
e638a062e8 Merge pull request #24831 from poettering/dbus-dump-doc
man: clarify that D-Bus Dump() call is a debugging interface with no guarantees
2022-09-30 14:23:59 +02:00
Lennart Poettering
72c2d39ecb resolved: beef up monitor protocol, include full query info 2022-09-30 14:23:30 +02:00
Lennart Poettering
4d593fb151 resolved: add dns_question_merge() helper
Very similar to dns_answer_merge(), but for DnsQuestion objects instead
of DnsAnswer.
2022-09-30 14:22:53 +02:00
Lennart Poettering
1482c86a50 resolved: add generic formatters for RRs into JSON
For now we can use it to send broken-down records of JSON via the
monitor logic, but one day we can certainly reuse for dumping the
caches, or to implement a ResolveRecord() varlink call one day.
2022-09-30 14:22:15 +02:00
Lennart Poettering
ab26cdf730 resolved: split out helper for allocating DnsResourceRecord object from raw data
No change in behaviour, just some refactoring.
2022-09-30 14:21:38 +02:00
Lennart Poettering
b497a958d6 resolved: split out main server listening code from manager_varlink_init()
Just some minor refactoring, to make binding the two sockets (main +
minitor) symmetric
2022-09-30 14:21:05 +02:00
Lennart Poettering
b25d819aee resolved: don't make monitoring optional
The socket is only accessible to privileged clients anyway, no need to
add another (user unfriendly) restriction via opt-in setting. let's just
allow this for privileged clients, mirroring "busctl monitor", or
"tcpdump" and similar, which all just work if you have privs.

(This does not break API, since we never did a release witht the
"Monitor" dbus property or config setting in place, i.e. with
cb456374e0)
2022-09-30 14:20:28 +02:00
Lennart Poettering
227e127943 resolved: rename 'notification' → 'monitor'
We expose this externally already as "monitor", name it internally the
same way. (Which is nice since it mirrors busctl monitor)
2022-09-30 14:19:50 +02:00
Lennart Poettering
baf3fdec27 sd-event: add helper for exiting event loop on SIGTERM/SIGINT
In many (most?) of our event loops we want to exit once SIGTERM/SIGINT
is seen. Add a common helper for that, that does the right things in a
single call.
2022-09-30 14:18:43 +02:00
Lennart Poettering
897448bd37 sd-event: if signal nr has high bit set sd_event_add_signal() auto-block it via sigprocmask()
So far we expected callers to block the signals manually. Which is
usually a good idea, since they should do that before forking off
threads and similar. But let's add a mode where we automatically block
it for the caller, to simplify things.
2022-09-30 14:17:46 +02:00
Lennart Poettering
0b8218b901 json: explicitly support offsets relative to NULL when dispatching
Let's trick out UndefinedBehaviourSanitizer:

https://github.com/systemd/systemd/pull/24853#issuecomment-1263380745
2022-09-30 14:17:15 +02:00
Lennart Poettering
84738d864b json: add helper for json builder for octescape/base32hex
These encodings for binary data are mandated by DNS RFCs, so let's give
make them nice and easy to use with json builder logic.
2022-09-30 14:16:23 +02:00
Lennart Poettering
e085625f09 json: add dispatchers for 16bit integers 2022-09-30 14:15:37 +02:00
Lennart Poettering
24fe5e9807 glyph-util: add left arrow special glyph entry 2022-09-30 14:14:48 +02:00
Yu Watanabe
a78049fc0e resolve: do not cache mDNS goodbye packet
Fixes #24842.
2022-09-30 18:50:56 +09:00
Yu Watanabe
9449268fae Merge pull request #24820 from keszybz/tmpfiles-warning
Downgrade warning about unitialized-/etc in tmpfiles
2022-09-30 18:50:31 +09:00
Lennart Poettering
acf2de5217 manager: make clear internal Dump() logic is debugging only. 2022-09-30 11:32:24 +02:00
Adam Williamson
950aeeb8ff kbd-model-map: correct variants for cz-qwerty to include comma
As explained by @poncovka , the 'xvariant' string should contain
the same number of comma-separated elements as 'xlayout'. When
we have two layouts we need two items in xvariant, in this case
one of them is empty.

See https://github.com/rhinstaller/anaconda/pull/4355#pullrequestreview-1119913870
for @poncovka's full explanation.

Signed-off-by: Adam Williamson <awilliam@redhat.com>
2022-09-29 23:53:26 +01:00
Yu Watanabe
4273a041f1 udevadm: do not try to find device unit when a path like string is provided
Otherwise, we provide misleading error message.
Before:
---
$ udevadm info /sys/class/foo
Bad argument "/sys/class/foo", expected an absolute path in /dev/ or /sys/ or a unit name: Invalid argument
---
After:
---
$ udevadm info /sys/class/foo
Unknown device "/sys/class/foo": No such device
---
2022-09-30 02:05:09 +09:00
Jan Janssen
957dfcc96d stub: Remove unused function parameter 2022-09-29 10:30:37 +02:00
Lennart Poettering
1aefb25f37 resolved: paranoia: restrict socket mode as much as we can 2022-09-29 00:42:14 +01:00