]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
3 years agoMove os-util.[ch] to basic/
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 15:51:18 +0000 (16:51 +0100)] 
Move os-util.[ch] to basic/

parse_os_release() will be used basic/hostname-util.c later on.

3 years agosysext: move extension_release_validate() out of os-util.c
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 15:36:07 +0000 (16:36 +0100)] 
sysext: move extension_release_validate() out of os-util.c

3 years agoos-release: add the DEFAULT_HOSTNAME= setting
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 14:08:07 +0000 (15:08 +0100)] 
os-release: add the DEFAULT_HOSTNAME= setting

The motivation is that variants of the same distro that share the same compiled
rpm want to customize various aspects of the system, in particular the
hostname. In some sense the default hostname is part of the identity of the
system, so setting it through os-release makes sense. In particular, instead of
setting a default value in /etc/hostname, the appropriate default can be baked
into the image, leaving /etc/hostname for local overrides only.

Why make this a separate field instead of e.g. using NAME from os-release?
NAME is already used for other purposes, and it seems likely that people want
to set those independently.

3 years agoman: use ~/.config instead of XDG_CONFIG_HOME
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 10:02:52 +0000 (11:02 +0100)] 
man: use ~/.config instead of XDG_CONFIG_HOME

e3820eeaf11f3b4614cbdfbc85675bc16a486e21 did that replacement XDG_CONFIG_HOME, in one
of two places. Let's use ~/.config everywhere.

Quoting https://github.com/systemd/systemd/pull/18704#discussion_r579465254:
> I'd really drop XDG_CONFIG_HOME from the docs. It's confusing enough as it
> is. Where we don't need the indirections we should not confuse people with
> it, in particular as people might then think it's actually a good idea to use
> that env var and redirect things. I'd just show the literal path everywhere,
> even if we internally use the env var.

3 years agomanager: add ManagerEnvironment configuration setting
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 23:06:26 +0000 (00:06 +0100)] 
manager: add ManagerEnvironment configuration setting

This is useful for various variables that modify process behaviour. This makes
it easy to set it for pid1 without touching the kernel command line. Even for
the *user manager* this also can be convenient for the unprivileged user, who
cannot modify user@.service definition.

Variables that could be set like this include $SD_EVENT_PROFILE_DELAYS,
$SYSTEMD_FALLBACK_HOSTNAME, $SYSTEMD_MEMPOOL, $SYSTMED_RDRAND, etc.

3 years agobasic/env-util: add putenv_dup()
Zbigniew Jędrzejewski-Szmek [Sat, 20 Feb 2021 18:25:32 +0000 (19:25 +0100)] 
basic/env-util: add putenv_dup()

3 years agomanager: read ~/.config/systemd/user.conf in user mode
Zbigniew Jędrzejewski-Szmek [Fri, 19 Feb 2021 09:56:04 +0000 (10:56 +0100)] 
manager: read ~/.config/systemd/user.conf in user mode

This changes the paths we read user manager config from in two ways:

- split-usr-root paths are dropped. The user manager is a poster boy for
  non-early-boot, so reading dropins only from /usr is appropriate.

- we look at ~/.config/systemd/user.conf. Users should be allowed to override
  their own config.

As user managers become more and more used, it becomes more important for users
to customize their own daemon. By reading from ~/.config, this is possible
without privileges.

3 years agoshared/conf-parser: allow more than one location of the main config file
Zbigniew Jędrzejewski-Szmek [Sat, 20 Feb 2021 16:04:05 +0000 (17:04 +0100)] 
shared/conf-parser: allow more than one location of the main config file

No functional change as long as only one path is passed.

3 years agonetwork: rename UseFQDN= -> UseHostname=
Yu Watanabe [Wed, 17 Feb 2021 20:30:09 +0000 (05:30 +0900)] 
network: rename UseFQDN= -> UseHostname=

Prompted by
https://github.com/systemd/systemd/pull/18543#issuecomment-780798451.

3 years agoMerge pull request #18685 from poettering/network-type-tweaks
Lennart Poettering [Thu, 18 Feb 2021 20:19:51 +0000 (21:19 +0100)] 
Merge pull request #18685 from poettering/network-type-tweaks

sd-network.h type tweaks

3 years agorandom-util: fix type of random_u64_range()
Lennart Poettering [Thu, 18 Feb 2021 15:18:51 +0000 (16:18 +0100)] 
random-util: fix type of random_u64_range()

As the name of the function suggests this is supposed to return
uint64_t, of course. Fix it. Not sure how this mistake happened in the
first place...

3 years agoMerge pull request #18546 from poettering/sd-device-action
Lennart Poettering [Thu, 18 Feb 2021 19:54:25 +0000 (20:54 +0100)] 
Merge pull request #18546 from poettering/sd-device-action

export sd_device_get_action() API + more

3 years agohttps://github.com/systemd/systemd/issues/15360
chri2 [Thu, 11 Feb 2021 13:48:50 +0000 (14:48 +0100)] 
https://github.com/systemd/systemd/issues/15360

The additional rules fix a firmware bug in the en keyboard of Librem notebooks by Purism.

By doing so the break the keyboard with other layouts which do not have the same bug in their firmware.

3 years agoresolved: improve debug logging on incoming messages a bit
Lennart Poettering [Mon, 16 Nov 2020 20:04:11 +0000 (21:04 +0100)] 
resolved: improve debug logging on incoming messages a bit

3 years agoMerge pull request #18679 from keszybz/rfkill-size-leniency
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 18:53:25 +0000 (19:53 +0100)] 
Merge pull request #18679 from keszybz/rfkill-size-leniency

struct rfkill_event read/write size leniency

3 years agojournald: when we fail to add a new entry to a journal, return the seqno
Lennart Poettering [Wed, 17 Feb 2021 22:11:42 +0000 (23:11 +0100)] 
journald: when we fail to add a new entry to a journal, return the seqno

Fixes: #18005
3 years agoudevadm: after validating action, use our internal string instead of optarg 18546/head
Lennart Poettering [Wed, 10 Feb 2021 21:19:41 +0000 (22:19 +0100)] 
udevadm: after validating action, use our internal string instead of optarg

This doesn't really change anything, but feels nicer, since it abstracts
away what device_action_from_string()/device_action_to_string() do
internally, and always uses a normalized action string (yes, there's no
ambiguity, but it's nice to stay abstract, maybe one day there is
ambiguity around this)

3 years agosd-device: add sd_device_get_action() + sd_device_get_seqnum() + sd_device_new_from_s...
Lennart Poettering [Wed, 10 Feb 2021 21:15:01 +0000 (22:15 +0100)] 
sd-device: add sd_device_get_action() + sd_device_get_seqnum() + sd_device_new_from_stat_rdev()

To make sd-device properly usable for all programs we need to provide an
API for the "action" field of an event, it's one of the most relevant
ones, and it was so far missing.

This also adds sd_device_get_seqnum(), which isn't that interesting,
except for generating pretty debug output, which we use it ourselves
for.

This also makes device_new_from_stat_rdev() public, as it is truly
useful, as we can see in our own uses of it, and I think is fairly
generic to show up in the public APIs.

3 years agoMerge pull request #18664 from poettering/resolved-defrag
Lennart Poettering [Thu, 18 Feb 2021 17:20:36 +0000 (18:20 +0100)] 
Merge pull request #18664 from poettering/resolved-defrag

resolved: many UDP fragmentation tweaks

3 years agosd-device: don't compare pointers with numeric zero
Lennart Poettering [Wed, 10 Feb 2021 21:18:52 +0000 (22:18 +0100)] 
sd-device: don't compare pointers with numeric zero

Our coding style says no to this.

3 years agoMerge pull request #18667 from poettering/resolved-change-notification
Lennart Poettering [Thu, 18 Feb 2021 17:19:09 +0000 (18:19 +0100)] 
Merge pull request #18667 from poettering/resolved-change-notification

resolved: optimize dbus change notification signals a bit

3 years agonetwork: tighten table alignment a bit 18685/head
Lennart Poettering [Thu, 18 Feb 2021 16:56:11 +0000 (17:56 +0100)] 
network: tighten table alignment a bit

3 years agonetwork: suffix types with _t in public headers
Lennart Poettering [Thu, 18 Feb 2021 16:53:56 +0000 (17:53 +0100)] 
network: suffix types with _t in public headers

Apparently, in our current public headers (i.e. those called sd-*.h) we
suffixed typedefs that we use as values with _t, but we didn't do this
for enum typedefs. Fix that while this stuff is not actually public yet.

With this scheme "value typedefs" now end systematically in _t, and
"object typedefs" (i.e. structures that are typically passed around via
pointers and not values) do not.

No code changes, just some renaming.

3 years agoresolved: optimize change notification handling away if bus calls set the same values... 18667/head
Lennart Poettering [Wed, 18 Nov 2020 12:52:59 +0000 (13:52 +0100)] 
resolved: optimize change notification handling away if bus calls set the same values as were already set

Prompted-by: #17577 (but doesn't fix this, since this commit only
handles D-Bus-induced changes, not the ones made via networkd)

3 years agobasic: add set_equal() helper
Lennart Poettering [Wed, 18 Nov 2020 12:48:02 +0000 (13:48 +0100)] 
basic: add set_equal() helper

3 years agoresolved: take fragment size into consideration when determining EDNS0 udp packet... 18664/head
Lennart Poettering [Mon, 16 Nov 2020 20:02:06 +0000 (21:02 +0100)] 
resolved: take fragment size into consideration when determining EDNS0 udp packet size

3 years agoresolved: let's track fragment sizes of servers/retry on fragmenting
Lennart Poettering [Mon, 16 Nov 2020 22:26:37 +0000 (23:26 +0100)] 
resolved: let's track fragment sizes of servers/retry on fragmenting

Fragmenting sucks, let's avoid it. Thus let's start tracking the maximum
fragment size we receive.

Also, let's redo a transaction via TCP if we see fragmenting on UDP, as
effective mitigation against DNS fragment attacks.

3 years agoresolved: tweak how we calculate MTU for sending packets
Lennart Poettering [Mon, 16 Nov 2020 22:27:21 +0000 (23:27 +0100)] 
resolved: tweak how we calculate MTU for sending packets

Let's take all MTU info we possibly have into account, i.e. the one
reported via netlink, as before and the one the socket might now (from
PMTUD and such), clamped by our own ideas.

3 years agoresolved: add udp_header_size() helper
Lennart Poettering [Mon, 16 Nov 2020 20:00:24 +0000 (21:00 +0100)] 
resolved: add udp_header_size() helper

3 years agoresolved: collect incoming fragment size when receiving UDP datagrams
Lennart Poettering [Mon, 16 Nov 2020 13:05:52 +0000 (14:05 +0100)] 
resolved: collect incoming fragment size when receiving UDP datagrams

We can later use this to adapt our announced EDNS buffer size in order
to avoid fragmentation to make the best of large datagrams while still
avoiding he security weaknesses of it.

3 years agoresolved: disable path MTU discovery for UDP traffic
Lennart Poettering [Mon, 16 Nov 2020 13:02:52 +0000 (14:02 +0100)] 
resolved: disable path MTU discovery for UDP traffic

This disables path MTU discovery both for our UDP upstream connections
and our UDP stub, following the suggestions of:

https://blog.apnic.net/2019/07/12/its-time-to-consider-avoiding-ip-fragmentation-in-the-dns/

This more or less follows the model of other DNS servers on this.

3 years agoman: Rename duplicate Credentials section name
Дамјан Георгиевски [Thu, 18 Feb 2021 14:08:48 +0000 (15:08 +0100)] 
man: Rename duplicate Credentials section name

A "Credentials" section name in systemd.exec man page was used
both for User/Group and for actual credentials support in systemd.

Rename the first instance to "User/Group Identity"

3 years agonetworkd-test: reenable dnssec while testing
Lennart Poettering [Mon, 16 Nov 2020 20:06:56 +0000 (21:06 +0100)] 
networkd-test: reenable dnssec while testing

We need to list the synthesized domains as NTAs, otherwise the DNSSEC
validation of course cannot succeed.

Fixes: #10487 #5029
3 years agoMerge pull request #18557 from poettering/enum-force-s64
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 13:16:15 +0000 (14:16 +0100)] 
Merge pull request #18557 from poettering/enum-force-s64

force public enums to be 64bit wide

3 years agonetwork: Add "route_localnet" sysctl support
Susant Sahani [Thu, 18 Feb 2021 08:55:13 +0000 (09:55 +0100)] 
network: Add "route_localnet" sysctl support

3 years agoMerge pull request #18665 from poettering/resolved-fastopen
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 11:55:10 +0000 (12:55 +0100)] 
Merge pull request #18665 from poettering/resolved-fastopen

resolved: use TCP FASTOPEN on the local DNS stub

3 years agoMerge pull request #18625 from bluca/sysext_refactor
Luca Boccassi [Thu, 18 Feb 2021 10:43:08 +0000 (10:43 +0000)] 
Merge pull request #18625 from bluca/sysext_refactor

dissect: parse and store extension-release metadata

3 years agorfkill: use short writes and accept long reads 18679/head
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 09:48:08 +0000 (10:48 +0100)] 
rfkill: use short writes and accept long reads

I'm seeing the following with kernel-core-5.10.16-200.fc33.x86_64:

$ sudo SYSTEMD_LOG_LEVEL=debug build/systemd-rfkill
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 0 and type bluetooth.
Found cgroup2 on /sys/fs/cgroup/, full unified hierarchy
Found container virtualization none.
rfkill0: Operating on rfkill device 'tpacpi_bluetooth_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 1 and type wwan.
rfkill1: Operating on rfkill device 'tpacpi_wwan_sw'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/platform-thinkpad_acpi:wwan.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 2 and type bluetooth.
rfkill2: Operating on rfkill device 'hci0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:00:14.0-usb-0:7:1.0:bluetooth.
Reading struct rfkill_event: got 8 bytes.
A new rfkill device has been added with index 3 and type wlan.
rfkill3: Operating on rfkill device 'phy0'.
Writing struct rfkill_event successful (8 of 9 bytes).
Loaded state '0' from /var/lib/systemd/rfkill/pci-0000:04:00.0:wlan.
All events read and idle, exiting.

We were expecting a read of exactly RFKILL_EVENT_SIZE_V1==8 bytes. But the
structure has 9 after [1].

[1] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=14486c82612a177cb910980c70ba900827ca0894

For some reason the kernel does not accept the full structure size, but cuts
the write short after 8 bytes:

static ssize_t rfkill_fop_write(struct file *file, const char __user *buf,
size_t count, loff_t *pos)
{
struct rfkill_event ev;

/* we don't need the 'hard' variable but accept it */
if (count < RFKILL_EVENT_SIZE_V1 - 1)
return -EINVAL;

/*
 * Copy as much data as we can accept into our 'ev' buffer,
 * but tell userspace how much we've copied so it can determine
 * our API version even in a write() call, if it cares.
 */
count = min(count, sizeof(ev));
if (copy_from_user(&ev, buf, count))
return -EFAULT;

... so it should accept the full size. I'm not sure what is going on here.

But we don't care about the extra fields, so let's accept a write as long as
it's at least RFKILL_EVENT_SIZE_V1.

Fixes #18677.

3 years agorfkill: improve error logging
Zbigniew Jędrzejewski-Szmek [Thu, 18 Feb 2021 09:40:16 +0000 (10:40 +0100)] 
rfkill: improve error logging

If we get something of unexpected size, log the sizes. Also, don't log twice.

3 years agoRemove outdated disable_ipv6 docs
Richard Laager [Thu, 18 Feb 2021 07:11:53 +0000 (01:11 -0600)] 
Remove outdated disable_ipv6 docs

This was changed in commit 482efedc081b0c4bf2e77a3dee6b979d9c9a5765,
which was released in v243, to only enable and never disable IPv6.

Signed-off-by: Richard Laager <rlaager@wiktel.com>
3 years agoMerge pull request #18596 from keszybz/systemctl-quiet-legend
Lennart Poettering [Wed, 17 Feb 2021 22:40:04 +0000 (23:40 +0100)] 
Merge pull request #18596 from keszybz/systemctl-quiet-legend

systemctl: hide legends with --quiet, allow overriding

3 years agoMerge pull request #18651 from poettering/einval-followup
Lennart Poettering [Wed, 17 Feb 2021 22:15:50 +0000 (23:15 +0100)] 
Merge pull request #18651 from poettering/einval-followup

two follow-up fixes for the enum einvalification

3 years agonetwork: DHCP option- use correct byteorder
Susant Sahani [Wed, 17 Feb 2021 18:09:25 +0000 (19:09 +0100)] 
network: DHCP option- use correct byteorder

3 years agoMerge pull request #18656 from yuwata/network-nexthop-tiny-cleanups
Lennart Poettering [Wed, 17 Feb 2021 22:14:12 +0000 (23:14 +0100)] 
Merge pull request #18656 from yuwata/network-nexthop-tiny-cleanups

network: nexthop: tiny cleanups

3 years agohwdb: fix indentation
Lennart Poettering [Wed, 17 Feb 2021 18:10:17 +0000 (19:10 +0100)] 
hwdb: fix indentation

a bunch of entries use 2ch instead of 1ch indentation. Fix that.

3 years agoMerge pull request #18662 from yuwata/in-addr-is-set
Lennart Poettering [Wed, 17 Feb 2021 22:13:27 +0000 (23:13 +0100)] 
Merge pull request #18662 from yuwata/in-addr-is-set

in-addr-util: introduce in_addr_is_set() or friends

3 years agosysctl: downgrade warning about excluded keys
Zbigniew Jędrzejewski-Szmek [Wed, 17 Feb 2021 18:46:19 +0000 (19:46 +0100)] 
sysctl: downgrade warning about excluded keys

Our own config generates logs like this:
systemd-sysctl[1280]: Not setting net/ipv4/conf/all/rp_filter (explicit setting exists).
systemd-sysctl[1280]: Not setting net/ipv4/conf/default/rp_filter (explicit setting exists).
systemd-sysctl[1280]: Not setting net/ipv4/conf/all/accept_source_route (explicit setting exists).
systemd-sysctl[1280]: Not setting net/ipv4/conf/default/accept_source_route (explicit setting exists).
systemd-sysctl[1280]: Not setting net/ipv4/conf/all/promote_secondaries (explicit setting exists).
systemd-sysctl[1280]: Not setting net/ipv4/conf/default/promote_secondaries (explicit setting exists).

There is no error and nothing really to see.

3 years agoenv-util: refactor parsing helper for SYSTEMD_SYSEXT_HIERARCHIES out of sysext 18625/head
Luca Boccassi [Tue, 19 Jan 2021 17:11:55 +0000 (17:11 +0000)] 
env-util: refactor parsing helper for SYSTEMD_SYSEXT_HIERARCHIES out of sysext

3 years agoos-util: allow missing VERSION_ID on the host
Luca Boccassi [Fri, 12 Feb 2021 15:30:10 +0000 (15:30 +0000)] 
os-util: allow missing VERSION_ID on the host

Rolling releases, like ArchLinux, do not set VERSION_ID in
their os-release files, so allow matching simply on ID if the host
does not provide anything.

3 years agoos-util: split extension_release_validate out of sysext
Luca Boccassi [Wed, 27 Jan 2021 12:54:15 +0000 (12:54 +0000)] 
os-util: split extension_release_validate out of sysext

3 years agomachine: parse and store extension-release
Luca Boccassi [Wed, 27 Jan 2021 12:59:45 +0000 (12:59 +0000)] 
machine: parse and store extension-release

Follow the same pattern as os-release parsing, and store the key-value
pairs in a strv if found

3 years agodissect: parse, store and show extension-release info
Luca Boccassi [Wed, 27 Jan 2021 13:03:37 +0000 (13:03 +0000)] 
dissect: parse, store and show extension-release info

3 years agodissect: store image name, following usual parsing rules
Luca Boccassi [Wed, 27 Jan 2021 12:57:27 +0000 (12:57 +0000)] 
dissect: store image name, following usual parsing rules

The name of '/foo/bar/baz.raw' name is 'baz'

3 years agoenv-util: add strv_env_pairs_get helper
Luca Boccassi [Wed, 27 Jan 2021 12:51:17 +0000 (12:51 +0000)] 
env-util: add strv_env_pairs_get helper

3 years agoos-util: add load_extension_release_pairs helper
Luca Boccassi [Wed, 27 Jan 2021 12:53:13 +0000 (12:53 +0000)] 
os-util: add load_extension_release_pairs helper

3 years agoos-util: add path_is_extension_tree helper
Luca Boccassi [Wed, 27 Jan 2021 12:52:10 +0000 (12:52 +0000)] 
os-util: add path_is_extension_tree helper

3 years agoresolved: also use TCP tweaks on LLMNR (plus unify setsockopt() code) 18665/head
Lennart Poettering [Tue, 17 Nov 2020 10:42:43 +0000 (11:42 +0100)] 
resolved: also use TCP tweaks on LLMNR (plus unify setsockopt() code)

3 years agoresolved: enable TCP_FASTOPEN + TCP_NODELAY on stub TCP socket
Lennart Poettering [Tue, 17 Nov 2020 10:19:24 +0000 (11:19 +0100)] 
resolved: enable TCP_FASTOPEN + TCP_NODELAY on stub TCP socket

Latency matters. Four our local DNS stub it's not really that important,
but let's still do it, it's basically free after all.

3 years agoshell-completion: complete --legend=no for resolvectl and systemctl 18596/head
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 19:16:33 +0000 (20:16 +0100)] 
shell-completion: complete --legend=no for resolvectl and systemctl

I don't think it makes sense to complete --legend=yes. It is the default, and
it would be only used very rarely (and then it is easy enough to just remove
the '=no' part from the suggested string).

3 years agosystemctl: hide legends with --quiet, allow overriding
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 09:56:28 +0000 (10:56 +0100)] 
systemctl: hide legends with --quiet, allow overriding

--no-legend is replaced by --legend=no.

--quiet now implies --legend=no, but --legend=yes may be used to override that.
--quiet controls hints and warnings and such, and --legend controls just the
legends. I think it makes sense to allow both to controlled independently, in
particular --quiet --legend makes sense when using systemctl in a script to
provide some user-visible output.

Fixes #18560.

3 years agojournal-remote: inline one more iterator variable declaration
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 18:48:09 +0000 (19:48 +0100)] 
journal-remote: inline one more iterator variable declaration

3 years agojournal-remote: convert to parse_boolean_argument() and fix type confusion
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 18:47:41 +0000 (19:47 +0100)] 
journal-remote: convert to parse_boolean_argument() and fix type confusion

We were passing a reference to 'int arg_seal' to config_parse_bool(),
which expects a 'bool *'. Luckily, this would work, because 'bool'
is smaller than 'int', so config_parse_bool() would set the least-significant
byte of arg_seal. At least I think so. But let's use consistent types ;)

Also, modernize style a bit and don't use integers in boolean context.

3 years agotree-wide: use parse_boolean_argument() for variables with non-boolean type
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 18:41:39 +0000 (19:41 +0100)] 
tree-wide: use parse_boolean_argument() for variables with non-boolean type

This still works nicely, but we need to assign the return value ourselves.
As before, one nice effect is that error messages are uniform.

3 years agotree-wide: add a helper to parse boolean optarg
Zbigniew Jędrzejewski-Szmek [Mon, 15 Feb 2021 18:32:42 +0000 (19:32 +0100)] 
tree-wide: add a helper to parse boolean optarg

This nicely covers the case when optarg is optional. The same parser can be
used when the option string passed to getopt_long() requires a parameter and
when it doesn't.

The error messages are made consistent.
Also fixes a log error c&p in --crash-reboot message.

3 years agonetwork: NHA_ID should be always set 18656/head
Yu Watanabe [Fri, 5 Feb 2021 02:51:21 +0000 (11:51 +0900)] 
network: NHA_ID should be always set

3 years agonetwork: constify arguments
Yu Watanabe [Fri, 5 Feb 2021 01:07:34 +0000 (10:07 +0900)] 
network: constify arguments

3 years agonetwork: introduce log_nexthop_debug()
Yu Watanabe [Fri, 5 Feb 2021 00:44:49 +0000 (09:44 +0900)] 
network: introduce log_nexthop_debug()

3 years agoMerge pull request #18640 from poettering/resolved-dnssec-retry-harder
Lennart Poettering [Wed, 17 Feb 2021 18:50:58 +0000 (19:50 +0100)] 
Merge pull request #18640 from poettering/resolved-dnssec-retry-harder

resolved: two dnssec retry/downgrade tweaks

3 years agotree-wide: constify variables if possible 18662/head
Yu Watanabe [Wed, 17 Feb 2021 18:33:39 +0000 (03:33 +0900)] 
tree-wide: constify variables if possible

3 years agonetwork: use temporary buffer for safety
Yu Watanabe [Wed, 17 Feb 2021 18:27:35 +0000 (03:27 +0900)] 
network: use temporary buffer for safety

3 years agonetwork: use in_addr_prefix_to_string()
Yu Watanabe [Wed, 17 Feb 2021 18:22:28 +0000 (03:22 +0900)] 
network: use in_addr_prefix_to_string()

3 years agoresolve: use sockaddr_in_addr()
Yu Watanabe [Wed, 17 Feb 2021 17:51:09 +0000 (02:51 +0900)] 
resolve: use sockaddr_in_addr()

3 years agoresolve: make manager_find_ifindex() or friends return earlier
Yu Watanabe [Wed, 17 Feb 2021 17:50:50 +0000 (02:50 +0900)] 
resolve: make manager_find_ifindex() or friends return earlier

3 years agotree-wide: use in_addr_is_set() or friends
Yu Watanabe [Wed, 17 Feb 2021 16:29:43 +0000 (01:29 +0900)] 
tree-wide: use in_addr_is_set() or friends

3 years agonetwork: assign values after all checks are passed
Yu Watanabe [Wed, 17 Feb 2021 17:23:42 +0000 (02:23 +0900)] 
network: assign values after all checks are passed

3 years agoin-addr-util: introduce in6_addr_equal()
Yu Watanabe [Wed, 17 Feb 2021 17:17:08 +0000 (02:17 +0900)] 
in-addr-util: introduce in6_addr_equal()

3 years agoin-addr-util: introduce in6_addr_is_link_local()
Yu Watanabe [Wed, 17 Feb 2021 16:56:47 +0000 (01:56 +0900)] 
in-addr-util: introduce in6_addr_is_link_local()

3 years agoin-addr-util: introduce in_addr_is_set() or friends
Yu Watanabe [Wed, 17 Feb 2021 15:36:38 +0000 (00:36 +0900)] 
in-addr-util: introduce in_addr_is_set() or friends

3 years agonetwork: enumerate nexthops before routes
Yu Watanabe [Sun, 14 Feb 2021 18:29:55 +0000 (03:29 +0900)] 
network: enumerate nexthops before routes

Preparation for the later commits.
Routes may have RTA_NH_ID attribute. To resolve the nexthop ID, all
nexthops must be enumerated earlier.

3 years agonetwork: nexthop: first create nexthops with ID
Yu Watanabe [Fri, 5 Feb 2021 01:21:19 +0000 (10:21 +0900)] 
network: nexthop: first create nexthops with ID

Otherwise, an ID-less nexthop may conflict with a later nexthop with ID.

3 years agoportable: make PortableChangeType enum anonymous 18651/head
Lennart Poettering [Wed, 17 Feb 2021 09:47:30 +0000 (10:47 +0100)] 
portable: make PortableChangeType enum anonymous

Same reasons as previous commit.

3 years agoinstall: make UnitFileChangeType enum anonymous
Lennart Poettering [Wed, 17 Feb 2021 09:38:12 +0000 (10:38 +0100)] 
install: make UnitFileChangeType enum anonymous

We almost never use the named enum type, in almost all cases we use
"int" instead, since we overload it with negative errnos. To simplify
things, let's use "int" really everywhere.

Moreover, let's rename the fields for this enum to "type_or_errno", to
make the overloading clear. And let's ad some assertions that things are
in the right range.

3 years agoresolved: see if it's worth retrying a lookup on "failed-auxiliary" DNSSEC error 18640/head
Lennart Poettering [Thu, 12 Nov 2020 17:10:18 +0000 (18:10 +0100)] 
resolved: see if it's worth retrying a lookup on "failed-auxiliary" DNSSEC error

Maybe we learnt something about the server feature set, let's hence
retry.

Fixes: #11102
3 years agoresolved: in DNSSEC permissive mode, check if DO bit wasn't copied from request to...
Lennart Poettering [Thu, 12 Nov 2020 16:33:08 +0000 (17:33 +0100)] 
resolved: in DNSSEC permissive mode, check if DO bit wasn't copied from request to response

If the server doesn't copy the DO bit from request to response, this is
a very early and easy indication that it doesn#t support DNSSEC
properly. Hence, let's immediately downgrade to non-DNSSEC mode if we
see this – if permissive mode is on and this is allowed.

3 years agotest: avoid leaking open loop devices
Luca Boccassi [Tue, 16 Feb 2021 23:47:34 +0000 (23:47 +0000)] 
test: avoid leaking open loop devices

When a subshell is used ('make' or 'make all') the LOOPDEV environment
variable, which is used to store the opened loop device, is lost.
So the cleanup on trap/exit doesn't do anything, and the loop
device used to mount the test image is left around.

Avoid using a subshell to fix the issue.

3 years agoMerge pull request #18653 from yuwata/in-addr-prefix-nth
Lennart Poettering [Wed, 17 Feb 2021 17:52:24 +0000 (18:52 +0100)] 
Merge pull request #18653 from yuwata/in-addr-prefix-nth

in-addr-util: fix in_addr_prefix_nth() and use the function to get ip address range in firewall-util

3 years agoresolved: address DVE-2018-0001
Lennart Poettering [Thu, 12 Nov 2020 16:05:36 +0000 (17:05 +0100)] 
resolved: address DVE-2018-0001

This is an updated version of #8608 with more restrictive logic. To
quite the original bug:

    Some captive portals, lie and do not respond with the captive portal
    IP address, if the query is with EDNS0 enabled and D0 bit set to
    zero. Thus retry "secure" domain name look ups with less secure
    methods, upon NXDOMAIN.

https://github.com/dns-violations/dns-violations/blob/master/2018/DVE-2018-0001.md

Yes, this fix sucks hard, but I guess this is what we need to do to make
sure resolved works IRL.

Heavily based on the original patch from Dimitri John Ledkov, and I
copied the commentary verbatim.

Replaces: #8608

3 years agoci: enable DNS over TLS using OpenSSL in the build test
Frantisek Sumsal [Wed, 17 Feb 2021 08:56:59 +0000 (09:56 +0100)] 
ci: enable DNS over TLS using OpenSSL in the build test

Prompted by:
    * https://github.com/systemd/systemd/pull/18641#issuecomment-780371055
    * https://github.com/systemd/systemd/issues/18639

3 years agoMerge pull request #18632 from yuwata/network-nexthop-add-family
Zbigniew Jędrzejewski-Szmek [Wed, 17 Feb 2021 14:02:50 +0000 (15:02 +0100)] 
Merge pull request #18632 from yuwata/network-nexthop-add-family

network: introduce Family= setting in [NextHop] section

3 years agofirewall-util: replace nft_in6addr_to_range() with in_addr_prefix_range() 18653/head
Yu Watanabe [Wed, 17 Feb 2021 13:57:10 +0000 (22:57 +0900)] 
firewall-util: replace nft_in6addr_to_range() with in_addr_prefix_range()

3 years agoin-addr-util: introduce in_addr_prefix_range()
Yu Watanabe [Wed, 17 Feb 2021 13:55:01 +0000 (22:55 +0900)] 
in-addr-util: introduce in_addr_prefix_range()

This will replace nft_in6addr_to_range() in later commit.

3 years agoin-addr-util: make in_addr_prefix_nth() always return valid prefix
Yu Watanabe [Wed, 17 Feb 2021 11:01:26 +0000 (20:01 +0900)] 
in-addr-util: make in_addr_prefix_nth() always return valid prefix

Previously, e.g. in_addr_prefix_nth(2400::1, prefixlen=32, nth=1)
does not return 2400:1:: but does 2400:1::1.

3 years agoin-addr-util: make in_addr_prefix_nth() refuse prefixlen larger than maximum size
Yu Watanabe [Wed, 17 Feb 2021 10:06:36 +0000 (19:06 +0900)] 
in-addr-util: make in_addr_prefix_nth() refuse prefixlen larger than maximum size

3 years agoin-addr-util: make in_addr_prefix_nth() returns 0 on success
Yu Watanabe [Wed, 17 Feb 2021 08:32:54 +0000 (17:32 +0900)] 
in-addr-util: make in_addr_prefix_nth() returns 0 on success

3 years agonetwork: refuse IPv4 multipath route for IPv6 route
Yu Watanabe [Thu, 4 Feb 2021 15:49:49 +0000 (00:49 +0900)] 
network: refuse IPv4 multipath route for IPv6 route

3 years agonetwork: Route::gw_family may be AF_UNSPEC
Yu Watanabe [Tue, 9 Feb 2021 09:35:45 +0000 (18:35 +0900)] 
network: Route::gw_family may be AF_UNSPEC

3 years agologs-show: move show_journal_by_unit _BOOT_ID match
Vito Caputo [Tue, 27 Oct 2020 06:24:34 +0000 (23:24 -0700)] 
logs-show: move show_journal_by_unit _BOOT_ID match

In scrutinizing the journal overhead of `systemctl status $service`
it became apparent that the matching engine was performing the unit
matches on every journal in my system, even ones containing nothing
relevant to the current boot.

This seemed strange and likely suboptimal to me, since there's likely
far more unit data to rifle through than boot IDs in any given
journal.  The _BOOT_ID match seemed like it should be serving as an
early exit match on irrelevant journals, but that wasn't what seemed
to be happening.

As a quick experiment to see if I could get the _BOOT_ID match to be
something along the lines of a higher priority when matching, and try
early exit on these unrelated journals, I moved add_match_this_boot()
to after the unit match adds, inserting a conjunction between them.

The end result seems to be a very substantial performance gain in my
simple uncached tests, and I still get the expected journal output
from the `systemctl status $service` command:

----------------------------------------------------------------------

Unmodified systemctl times:

 root@localhost:/# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/# time systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
    Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
    Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
      Docs: man:dbus-daemon(1)
  Main PID: 572 (dbus-daemon)
    Memory: 2.8M
       CPU: 110ms
    CGroup: /system.slice/dbus.service
            └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.695s
 user    0m0.005s
 sys     0m0.043s
 root@localhost:/# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/# time systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
    Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
    Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
      Docs: man:dbus-daemon(1)
  Main PID: 572 (dbus-daemon)
    Memory: 2.8M
       CPU: 110ms
    CGroup: /system.slice/dbus.service
            └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.696s
 user    0m0.003s
 sys     0m0.046s
 root@localhost:/# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/# time systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
    Loaded: loaded (/lib/systemd/system/dbus.service; static; vendor preset: enabled)
    Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
      Docs: man:dbus-daemon(1)
  Main PID: 572 (dbus-daemon)
    Memory: 2.8M
       CPU: 110ms
    CGroup: /system.slice/dbus.service
            └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.694s
 user    0m0.006s
 sys     0m0.041s

----------------------------------------------------------------------

Modified systemctl including this commit:

 root@localhost:/home/vc/gh/systemd/build# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/home/vc/gh/systemd/build# time ./systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
      Loaded: loaded (/lib/systemd/system/dbus.service; static)
      Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
 TriggeredBy: ● dbus.socket
        Docs: man:dbus-daemon(1)
    Main PID: 572 (dbus-daemon)
      Memory: 2.8M
         CPU: 110ms
      CGroup: /system.slice/dbus.service
              └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.168s
 user    0m0.003s
 sys     0m0.016s
 root@localhost:/home/vc/gh/systemd/build# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/home/vc/gh/systemd/build# time ./systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
      Loaded: loaded (/lib/systemd/system/dbus.service; static)
      Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
 TriggeredBy: ● dbus.socket
        Docs: man:dbus-daemon(1)
    Main PID: 572 (dbus-daemon)
      Memory: 2.8M
         CPU: 110ms
      CGroup: /system.slice/dbus.service
              └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.167s
 user    0m0.005s
 sys     0m0.013s
 root@localhost:/home/vc/gh/systemd/build# echo 2 > /proc/sys/vm/drop_caches
 root@localhost:/home/vc/gh/systemd/build# time ./systemctl --no-pager status dbus
 ● dbus.service - D-Bus System Message Bus
      Loaded: loaded (/lib/systemd/system/dbus.service; static)
      Active: active (running) since Sun 2020-10-25 17:03:05 PDT; 1 day 6h ago
 TriggeredBy: ● dbus.socket
        Docs: man:dbus-daemon(1)
    Main PID: 572 (dbus-daemon)
      Memory: 2.8M
         CPU: 110ms
      CGroup: /system.slice/dbus.service
              └─572 /usr/bin/dbus-daemon --system --address=systemd: --nofork --nopidfile --systemd-activation

 Oct 25 17:03:05 localhost systemd[1]: Started D-Bus System Message Bus.
 Oct 25 17:06:26 localhost dbus[572]: [system] Activating via systemd: service name='org.freedesktop.machine1' unit='dbus-org.freedesktop.machine1.service'
 Oct 25 17:06:26 localhost dbus[572]: [system] Successfully activated service 'org.freedesktop.machine1'

 real    0m0.170s
 user    0m0.005s
 sys     0m0.014s

3 years agoresolved: include NSID support to DNS stub
Lennart Poettering [Thu, 12 Nov 2020 19:47:35 +0000 (20:47 +0100)] 
resolved: include NSID support to DNS stub

This adds minimal support for RFC5001 NSID to the stub resolver. This
useful to identify systemd-resolved when talking to the stub resolver,
and distuingishing the packets resolved answers itself (where NSID is
now set) from those which it proxies 1:1 upstream (where NSID will not
be set, or set to whatever the upstream server has it set to).

The NSID chosen consist of two parts:

1. The first part is derived from /etc/machine-id and identifies the
   resolved instance in a stable way.

2. The second part is the fixed string ".resolved.systemd.io".

This thus maybe used for a veriety of checks:

a. Am I talking to a resolved stub?
b. Am I talking to the same stub as last time?
c. Am I talking to the local resolved?

Given that the first part leaks the identity of the system in away two
protections are in place:

I) The NSID is only included on the main stub, not the extra stub. The
   main stub has with a TTL of 1 and other protections a lot of safety
   in place that the datagrams never leave the local system, thus the
   identifying info is only accessible to the local system — but
   /etc/machine-id is accessible to local software anyway.

II) The NSID is hashed from /etc/machine-id in a non-invertable way, so
    that the machine ID itself isn't leaked, but only an identifier
    derived from it.

Example dig run:

```
$ dig +nsid localhost @127.0.0.53

; <<>> DiG 9.11.23-RedHat-9.11.23-1.fc33 <<>> +nsid localhost @127.0.0.53
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 46917
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
; NSID: 35 33 64 34 61 34 66 63 32 31 32 65 34 31 61 30 39 66 30 39 65 33 32 34 63 64 64 38 30 36 32 33 2e 72 65 73 6f 6c 76 65 64 2e 73 79 73 74 65 6d 64 2e 69 6f ("53d4a4fc212e41a09f09e324cdd80623.resolved.systemd.io")
;; QUESTION SECTION:
;localhost. IN A

;; ANSWER SECTION:
localhost. 0 IN A 127.0.0.1

;; Query time: 0 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Do Nov 12 20:57:16 CET 2020
;; MSG SIZE  rcvd: 110
```

3 years agohwdb: Add accel orientation quirk for the Trekstor Surftab Wintron 10.1 ST10432-3...
Hans de Goede [Tue, 16 Feb 2021 20:24:40 +0000 (21:24 +0100)] 
hwdb: Add accel orientation quirk for the Trekstor Surftab Wintron 10.1 ST10432-3 tablet

Add a quirk to fix the accelerometer orientation on the
Trekstor Surftab Wintron 10.1 ST10432-3 tablet.

3 years agoMerge pull request #18641 from benjarobin/fix-enum-invalid-val
Zbigniew Jędrzejewski-Szmek [Wed, 17 Feb 2021 07:46:09 +0000 (08:46 +0100)] 
Merge pull request #18641 from benjarobin/fix-enum-invalid-val

Various follow-up: Fix build and EINVAL for _INVALID enum value