]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
4 years agoupdate TODO 17741/head
Lennart Poettering [Thu, 26 Nov 2020 13:42:23 +0000 (14:42 +0100)] 
update TODO

4 years agomkosi: add TPM2 packages to debian/ubuntu/fedora mkosi files
Lennart Poettering [Thu, 17 Dec 2020 13:16:15 +0000 (14:16 +0100)] 
mkosi: add TPM2 packages to debian/ubuntu/fedora mkosi files

As suggested: https://github.com/systemd/systemd/pull/17741#issuecomment-743479834

4 years agoman: document new features
Lennart Poettering [Mon, 7 Dec 2020 16:18:52 +0000 (17:18 +0100)] 
man: document new features

4 years agofido2: when listing fido2/hmac-secret devices, actually validate feature set
Lennart Poettering [Thu, 17 Dec 2020 12:55:50 +0000 (13:55 +0100)] 
fido2: when listing fido2/hmac-secret devices, actually validate feature set

4 years agotest: add tpm2 and fido2 libs to dlopen test
Lennart Poettering [Wed, 9 Dec 2020 20:13:58 +0000 (21:13 +0100)] 
test: add tpm2 and fido2 libs to dlopen test

4 years agorepart: optionally lock encrypted partitions to TPM2
Lennart Poettering [Tue, 8 Dec 2020 14:12:29 +0000 (15:12 +0100)] 
repart: optionally lock encrypted partitions to TPM2

This useful for bootstrapping encrypted systems: on first boot let's
create a /var/ partition that is locked to the local TPM2.

4 years agostring-table: add private version of lookup macro with boolean fallback
Lennart Poettering [Tue, 8 Dec 2020 13:39:49 +0000 (14:39 +0100)] 
string-table: add private version of lookup macro with boolean fallback

4 years agocryptsetup: add support for TPM2 unlocking of volumes
Lennart Poettering [Fri, 4 Dec 2020 16:26:37 +0000 (17:26 +0100)] 
cryptsetup: add support for TPM2 unlocking of volumes

4 years agocryptenroll: support listing and wiping tokens
Lennart Poettering [Sat, 28 Nov 2020 21:59:21 +0000 (22:59 +0100)] 
cryptenroll: support listing and wiping tokens

4 years agocryptenroll: add support for TPM2 enrolling
Lennart Poettering [Sat, 28 Nov 2020 14:27:34 +0000 (15:27 +0100)] 
cryptenroll: add support for TPM2 enrolling

4 years agojson: add APIs for quickly inserting hex blobs into as JSON strings
Lennart Poettering [Tue, 1 Dec 2020 12:45:32 +0000 (13:45 +0100)] 
json: add APIs for quickly inserting hex blobs into as JSON strings

This is similar to the base64 support, but fixed-size hash values are
typically preferably presented as series of hex values, hence store them
here like that too.

4 years agosort-util: make cmp_int() generic, so that we can reuse it elsewhere
Lennart Poettering [Mon, 30 Nov 2020 15:23:15 +0000 (16:23 +0100)] 
sort-util: make cmp_int() generic, so that we can reuse it elsewhere

4 years agocryptenroll: add new "systemd-cryptenroll" tool for enrolling FIDO2+PKCS#11 security...
Lennart Poettering [Tue, 24 Nov 2020 12:41:47 +0000 (13:41 +0100)] 
cryptenroll: add new "systemd-cryptenroll" tool for enrolling FIDO2+PKCS#11 security tokens

4 years agocryptsetup: add fido2 support
Lennart Poettering [Thu, 26 Nov 2020 11:46:10 +0000 (12:46 +0100)] 
cryptsetup: add fido2 support

4 years agofido2: don't use up/uv/rk when device doesn't support it
Lennart Poettering [Fri, 4 Dec 2020 09:19:47 +0000 (10:19 +0100)] 
fido2: don't use up/uv/rk when device doesn't support it

Apparently devices are supposed to generate failures if we try to turn
off features they don't have. Thus don't.

Prompted-by: https://github.com/systemd/systemd/issues/17784#issuecomment-737730395
4 years agohomed: split out HMAC-HASH fido2 decode code into src/shared/
Lennart Poettering [Thu, 26 Nov 2020 12:30:24 +0000 (13:30 +0100)] 
homed: split out HMAC-HASH fido2 decode code into src/shared/

That way we can use it later on in systemd-cryptsetup to unlock devices
with FIDO2 tokens.

4 years agohomed: move fido2 setup code to src/shared/
Lennart Poettering [Wed, 25 Nov 2020 15:34:54 +0000 (16:34 +0100)] 
homed: move fido2 setup code to src/shared/

That way we can reuse it from systemd-cryptenroll

4 years agohomed: move fido2 device enumeration logic to shared code
Lennart Poettering [Wed, 25 Nov 2020 14:15:25 +0000 (15:15 +0100)] 
homed: move fido2 device enumeration logic to shared code

4 years agohomed: turn libfido2 into a dlopen() type dependency
Lennart Poettering [Wed, 25 Nov 2020 14:07:06 +0000 (15:07 +0100)] 
homed: turn libfido2 into a dlopen() type dependency

4 years agocryptsetup: split up attach_luks_or_plain_or_bitlk() into smaller functions
Lennart Poettering [Thu, 26 Nov 2020 12:29:56 +0000 (13:29 +0100)] 
cryptsetup: split up attach_luks_or_plain_or_bitlk() into smaller functions

Just some refactoring.

4 years agocryptsetup: read PKCS#11 key and token info from LUKS2 metadata
Lennart Poettering [Wed, 25 Nov 2020 10:10:29 +0000 (11:10 +0100)] 
cryptsetup: read PKCS#11 key and token info from LUKS2 metadata

Optionally, embedd PKCS#11 token URI and encrypted key in LUKS2 JSON
metadata header. That way it becomes very easy to unlock properly set up
PKCS#11-enabled LUKS2 volumes, a simple /etc/crypttab line like the
following suffices:

    mytest /dev/disk/by-partuuid/41c1df55-e628-4dbb-8492-bc69d81e172e - pkcs11-uri=auto

Such a line declares that unlocking via PKCS#11 shall be attempted, and
the token URI and the encrypted key shall be read from the LUKS2 header.
An external key file for the encrypted PKCS#11 key is hence no longer
necessary, nor is specifying the precise URI to use.

4 years agocryptsetup: be more careful with erasing key material from memory
Lennart Poettering [Wed, 25 Nov 2020 10:58:55 +0000 (11:58 +0100)] 
cryptsetup: be more careful with erasing key material from memory

4 years agocryptsetup: split code that allocates udev security device monitor into its own function
Lennart Poettering [Wed, 25 Nov 2020 10:51:39 +0000 (11:51 +0100)] 
cryptsetup: split code that allocates udev security device monitor into its own function

4 years agocryptsetup-util: add helper for setting minimal PBKDF
Lennart Poettering [Tue, 8 Dec 2020 13:46:31 +0000 (14:46 +0100)] 
cryptsetup-util: add helper for setting minimal PBKDF

4 years agocryptsetup-util: add helper call for extracting/parsing token JSON
Lennart Poettering [Tue, 8 Dec 2020 12:18:28 +0000 (13:18 +0100)] 
cryptsetup-util: add helper call for extracting/parsing token JSON

4 years agohomed: move code to list and resolve "auto" pkcs#11 URL into common code
Lennart Poettering [Wed, 25 Nov 2020 09:28:11 +0000 (10:28 +0100)] 
homed: move code to list and resolve "auto" pkcs#11 URL into common code

That way we can reuse it from systemd-cryptenroll.

4 years agohomed: split out code that determines suitable LUKS passphrase size from RSA key
Lennart Poettering [Tue, 24 Nov 2020 14:29:03 +0000 (15:29 +0100)] 
homed: split out code that determines suitable LUKS passphrase size from RSA key

We can use this in cryptenroll later on, hence let's make this generic.

4 years agohomed: move pkcs11 LUKS glue into shared code
Lennart Poettering [Tue, 24 Nov 2020 14:08:20 +0000 (15:08 +0100)] 
homed: move pkcs11 LUKS glue into shared code

That way we can lter reuse it from cryptsetup/cryptenroll too.

4 years agohomed: move helper calls for RSA encryption to shared code
Lennart Poettering [Tue, 24 Nov 2020 14:07:53 +0000 (15:07 +0100)] 
homed: move helper calls for RSA encryption to shared code

4 years agohomed: move homectl's recovery key generation/modhex code to src/shared/
Lennart Poettering [Tue, 24 Nov 2020 12:55:02 +0000 (13:55 +0100)] 
homed: move homectl's recovery key generation/modhex code to src/shared/

This allows us to later reuse the code to generate recovery keys for
traditional LUKS volumes, too and share the code.

4 years agotest: fix fd_is_mount_point() check
Lennart Poettering [Thu, 17 Dec 2020 15:19:09 +0000 (16:19 +0100)] 
test: fix fd_is_mount_point() check

So the currentl and only fd_is_mount_point() check is actually entirely
bogus: it passes "/" as filename argument, but that's not actually a
a valid filename, but an absolute path.

fd_is_mount_point() is written in a way tha the fd refers to a directory
and the specified path is a file directly below it that shall be
checked. The test call actually violated that rule, but still expected
success.

Let's fix this, and check for this explicitly, and refuse it.

Let's extend the test and move it to test-mountpoint-util.c where the
rest of the tests for related calls are placed.

Replaces: #18004
Fixes: #17950
4 years agotree-wide: suggest meson command lines instead of ninja ones
Lennart Poettering [Fri, 11 Dec 2020 10:33:39 +0000 (11:33 +0100)] 
tree-wide: suggest meson command lines instead of ninja ones

This only changes documentation. In various places we call "ninja"
directly. I figured it would be safer to leave those in place for now,
given the meson replacement commands lines appears to be supported in
newer meson versions only.

4 years agoMerge pull request #18001 from systemd/wip/hadess/unsupported-dmi
Zbigniew Jędrzejewski-Szmek [Thu, 17 Dec 2020 08:16:33 +0000 (09:16 +0100)] 
Merge pull request #18001 from systemd/wip/hadess/unsupported-dmi

meson: Disable dmi_memory_id on arches without DMI

4 years agoterminal-util: use 256 color mode for PID 1 output, too
Lennart Poettering [Wed, 16 Dec 2020 18:55:32 +0000 (19:55 +0100)] 
terminal-util: use 256 color mode for PID 1 output, too

Follow-up for: #17702

Alsoe, see earlier review comment: https://github.com/systemd/systemd/pull/17702#pullrequestreview-552329600

4 years agoMerge pull request #17998 from mrc0mmand/qemu-drop-trailing-whitespace
Frantisek Sumsal [Wed, 16 Dec 2020 22:48:17 +0000 (23:48 +0100)] 
Merge pull request #17998 from mrc0mmand/qemu-drop-trailing-whitespace

test: drop the trailing whitespace from the QEMU version check

4 years agoMerge pull request #17702 from rnhmjoj/master
Lennart Poettering [Wed, 16 Dec 2020 18:26:40 +0000 (19:26 +0100)] 
Merge pull request #17702 from rnhmjoj/master

Extend $SYSTEMD_COLORS to switch colors mode

4 years agomeson: Disable dmi_memory_id on arches without DMI 18001/head
Bastien Nocera [Wed, 16 Dec 2020 17:50:38 +0000 (18:50 +0100)] 
meson: Disable dmi_memory_id on arches without DMI

4 years agoMerge pull request #17026 from fw-strlen/nft_16
Lennart Poettering [Wed, 16 Dec 2020 18:18:22 +0000 (19:18 +0100)] 
Merge pull request #17026 from fw-strlen/nft_16

add networkd/nspawn nftables backend

4 years agomeson: Split off udev helper programs array
Bastien Nocera [Wed, 16 Dec 2020 17:43:26 +0000 (18:43 +0100)] 
meson: Split off udev helper programs array

4 years agoudev: Extract RAM properties from DMI information
Bastien Nocera [Wed, 2 Dec 2020 11:40:42 +0000 (12:40 +0100)] 
udev: Extract RAM properties from DMI information

Add memory_id program to set properties about the physical memory
devices in the system. This is useful on machines with removable memory
modules to show how the machine can be upgraded, and on all devices to
detect the actual RAM size, without relying on the OS accessible amount.

Closes: #16651
4 years agotree-wide: fix typo
Yu Watanabe [Wed, 16 Dec 2020 17:16:16 +0000 (02:16 +0900)] 
tree-wide: fix typo

4 years agotest-login: skip consistency checks when logind is not active
Zbigniew Jędrzejewski-Szmek [Wed, 16 Dec 2020 14:56:44 +0000 (15:56 +0100)] 
test-login: skip consistency checks when logind is not active

There are two ways in swich sd_login_* functions acquire data:
some are derived from the cgroup path, but others use the data serialized
by logind.

When the tests are executed under Fedora's mock, without systemd-spawn
but instead in a traditional chroot, test-login gets confused:
the "outside" cgroup path is visible, so sd_pid_get_unit() and
sd_pid_get_session() work, but sd_session_is_active() and other functions
that need logind data fail.

Such a buildroot setup is fairly bad, but it can be encountered in the wild, so
let's just skip the tests in that case.

/* Information printed is from the live system */
sd_pid_get_unit(0, …) → "session-237.scope"
sd_pid_get_user_unit(0, …) → "n/a"
sd_pid_get_slice(0, …) → "user-1000.slice"
sd_pid_get_session(0, …) → "237"
sd_pid_get_owner_uid(0, …) → 1000
sd_pid_get_cgroup(0, …) → "/user.slice/user-1000.slice/session-237.scope"
sd_uid_get_display(1000, …) → "(null)"
sd_uid_get_sessions(1000, …) → [0] ""
sd_uid_get_seats(1000, …) → [0] ""
Assertion 'r >= 0' failed at src/libsystemd/sd-login/test-login.c:104, function test_login(). Aborting.

4 years agonetworkd: handle ignoring ll gateway being link ll
Devon Pringle [Mon, 14 Dec 2020 04:22:18 +0000 (14:22 +1000)] 
networkd: handle ignoring ll gateway being link ll

In the event where network discovery gets a route with the gateway being
the interfaces local link address, networkd will fail the interface.

systemd-networkd[44319]: br_lan: Configuring route: dst: fdcd:41a4:5559:ec03::/64, src: n/a, gw: fe80::e4da:7eff:fe77:5c5e, prefsrc: n/a, scope: global, table: main, proto: ra, type: unicast
systemd-networkd[44319]: br_lan: Could not set NDisc route or address: Gateway can not be a local address. Invalid argument
systemd-networkd[44319]: br_lan: Failed
systemd-networkd[44319]: br_lan: State changed: configuring -> failed

This patch, instead of allowing the interface to fail, will instead log
the event and skip setting the route.

4 years agoMerge pull request #17799 from yuwata/oss-fuzz-25353
Zbigniew Jędrzejewski-Szmek [Wed, 16 Dec 2020 16:52:35 +0000 (17:52 +0100)] 
Merge pull request #17799 from yuwata/oss-fuzz-25353

logs-show: skip non-utf8 name entries

4 years agoTranslated using Weblate (Swedish)
Luna Jernberg [Wed, 16 Dec 2020 12:36:01 +0000 (13:36 +0100)] 
Translated using Weblate (Swedish)

Currently translated at 67.3% (126 of 187 strings)

Co-authored-by: Luna Jernberg <bittin@reimu.nl>
Translate-URL: https://translate.fedoraproject.org/projects/systemd/master/sv/
Translation: systemd/master

4 years agotree-wide: fix typo
Yu Watanabe [Wed, 16 Dec 2020 15:53:01 +0000 (00:53 +0900)] 
tree-wide: fix typo

4 years agoMerge pull request #17859 from keszybz/hostnamed-export-hostname-origin-and-simplify...
Yu Watanabe [Wed, 16 Dec 2020 15:55:49 +0000 (00:55 +0900)] 
Merge pull request #17859 from keszybz/hostnamed-export-hostname-origin-and-simplify-logic

Export hostname origin and simplify logic in hostamed

4 years agotest: s/MUMA/NUMA/ 17998/head
Frantisek Sumsal [Wed, 16 Dec 2020 15:36:42 +0000 (16:36 +0100)] 
test: s/MUMA/NUMA/

4 years agotest: drop the trailing whitespace from the QEMU version check
Frantisek Sumsal [Wed, 16 Dec 2020 15:33:50 +0000 (16:33 +0100)] 
test: drop the trailing whitespace from the QEMU version check

I suspect the original version of the regex was written on a system,
which prints both the QEMU version and the QEMU package version in the
--version output, like Fedora:

$ /bin/qemu-system-x86_64 --version
QEMU emulator version 4.2.1 (qemu-4.2.1-1.fc32)
Copyright (c) 2003-2019 Fabrice Bellard and the QEMU Project developers

However, Arch Linux prints only the QEMU version:
$ /bin/qemu-system-x86_64 --version
QEMU emulator version 5.2.0
Copyright (c) 2003-2020 Fabrice Bellard and the QEMU Project developers

This causes the awk regex to not match the version string, since there's
no whitespace after it, causing the version check to fail (as well as the
TEST-36-NUMAPOLICY) as well.

Follow-up for 43b49470d1f2808555c07f64cd0a1529b7ddd559.

4 years agosd-netlink: routing policy rule port to fib_rule_hdr
Susant Sahani [Wed, 16 Dec 2020 10:58:46 +0000 (11:58 +0100)] 
sd-netlink: routing policy rule port to fib_rule_hdr

4 years agoresolved: always take a timestamp when first seeing a packet
Lennart Poettering [Wed, 28 Oct 2020 12:46:26 +0000 (13:46 +0100)] 
resolved: always take a timestamp when first seeing a packet

This is later useful if we want to adjust the TTLs of packets we want to
propagate to clients.

4 years agosd-dhcp-client: fix renew/rebind timeout calculation to avoid infinite loop
Dan Streetman [Tue, 15 Dec 2020 22:59:12 +0000 (17:59 -0500)] 
sd-dhcp-client: fix renew/rebind timeout calculation to avoid infinite loop

unfortunately I missed adding the timeout to 'now' which results in
an endless loop of renewal timeouts.

Fixes: 3a23834d6b0da391c1ba9cb79a7d7deea7125f4b
4 years agohostnamed,shared/hostname-setup: expose the origin of the current hostname 17859/head
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 18:40:34 +0000 (19:40 +0100)] 
hostnamed,shared/hostname-setup: expose the origin of the current hostname

In hostnamed this is exposed as a dbus property, and in the logs in both
places.

This is of interest to network management software and such: if the fallback
hostname is used, it's not as useful as the real configured thing. Right now
various programs try to guess the source of hostname by looking at the string.
E.g. "localhost" is assumed to be not the real hostname, but "fedora" is. Any
such attempts are bound to fail, because we cannot distinguish "fedora" (a
fallback value set by a distro), from "fedora" (received from reverse dns),
from "fedora" read from /etc/hostname.

/run/systemd/fallback-hostname is written with the fallback hostname when
either pid1 or hostnamed sets the kernel hostname to the fallback value. Why
remember the fallback value and not the transient hostname in /run/hostname
instead?
We have three hostname types: "static", "transient", fallback".
– Distinguishing "static" is easy: the hostname that is set matches what
  is in /etc/hostname.
– Distingiushing "transient" and "fallback" is not easy. And the
  "transient" hostname may be set outside of pid1+hostnamed. In particular,
  it may be set by container manager, some non-systemd tool in the initramfs,
  or even by a direct call. All those mechanisms count as "transient". Trying
  to get those cases to write /run/hostname is futile. It is much easier to
  isolate the "fallback" case which is mostly under our control.
And since the file is only used as a flag to mark the hostname as fallback,
it can be hidden inside of our /run/systemd directory.

For https://bugzilla.redhat.com/show_bug.cgi?id=1892235.

4 years agohostnamed: stop discriminating against "localhost" in /etc/hostname
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 18:56:49 +0000 (19:56 +0100)] 
hostnamed: stop discriminating against "localhost" in /etc/hostname

We would sometimes ignore localhost-style names in /etc/hostname. That is
brittle. If the user configured some hostname, it's most likely because they
want to use that as the hostname. If they don't want to use such a hostname,
they should just not create the config. Everything becomes simples if we just
use the configured hostname as-is.

This behaviour seems to have been a workaround for Anaconda installer and other
tools writing out /etc/hostname with the default of "localhost.localdomain".
Anaconda PR to stop doing that: https://github.com/rhinstaller/anaconda/pull/3040.
That might have been useful as a work-around for other programs misbehaving if
/etc/hostname was not present, but nowadays it's not useful because systemd
mostly controls the hostname and it is perfectly happy without that file.

Apart from making things simpler, this allows users to set a hostname like
"localhost" and have it honoured, if such a whim strikes them.

4 years agohostnamed: improve message about static hostname
Zbigniew Jędrzejewski-Szmek [Sat, 12 Dec 2020 12:34:48 +0000 (13:34 +0100)] 
hostnamed: improve message about static hostname

Changed static hostname to 'n/a' is not very nice.

4 years agohostnamed: minor style cleanups
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 18:40:46 +0000 (19:40 +0100)] 
hostnamed: minor style cleanups

4 years agohostnamed: when hostname is set to existing value, suppress notifications
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 18:17:45 +0000 (19:17 +0100)] 
hostnamed: when hostname is set to existing value, suppress notifications

When the hostname is set through network config or such, let's
optimize things a bit by suppressing the logs and dbus notifications.

4 years agoshared/hostname-setup: leave the terminator byte alone
Zbigniew Jędrzejewski-Szmek [Fri, 11 Dec 2020 15:52:30 +0000 (16:52 +0100)] 
shared/hostname-setup: leave the terminator byte alone

gethostname(3) says it's unspecified whether the string is properly terminated
when the hostname is too long. We created a buffer with one extra byte, and it
seems the intent was to let that byte serve as terminator even if we get an
unterminated string from gethostname().

4 years agoshared/hostname-setup: add mode where we check what would be set, without doing
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 17:45:23 +0000 (18:45 +0100)] 
shared/hostname-setup: add mode where we check what would be set, without doing

This allows the 'unsafe' mark to be removed from the test.

4 years agoMove hostname setup logic to new shared/hostname-setup.[ch]
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 17:39:23 +0000 (18:39 +0100)] 
Move hostname setup logic to new shared/hostname-setup.[ch]

No functional change, just moving a bunch of things around. Before
we needed a rather complicated setup to test hostname_setup(), because
the code was in src/core/. When things are moved to src/shared/
we can just test it as any function.

The test is still "unsafe" because hostname_setup() may modify the
hostname.

4 years agohostnamed: fix return value
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 16:35:22 +0000 (17:35 +0100)] 
hostnamed: fix return value

4 years agohostnamed: expose the fallback-hostname setting as a const dbus property
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 14:16:54 +0000 (15:16 +0100)] 
hostnamed: expose the fallback-hostname setting as a const dbus property

Various users want to know what the fallback hostname is. Since it was made
configurable in 8146c32b9264a6915d467a5cab1a24311fbede7e, we didn't expose this
nicely.

4 years agoman/hostnamectl,hostaned,hostname1: adjust the docs to match reality
Zbigniew Jędrzejewski-Szmek [Fri, 4 Dec 2020 14:16:24 +0000 (15:16 +0100)] 
man/hostnamectl,hostaned,hostname1: adjust the docs to match reality

The semantics were significantly changed in c779a44222161155c039a7fd2fd304c006590ac7
("hostnamed: Fix the way that static and transient host names interact", Feb. 2014),
but when the dbus api documentation was imported much later, it wasn't properly
adjusted to describe those new semantics.

34293dfafd2a81d80727938199769906dab321bd which added systemd.hostname= also
added new behaviour.

Let's ove various bits and pieces around so that they are in more appropriate
places. Drop recommendations to set the hostname for DHCP or mDNS purposes.
Nowadays we expect tools that want to expose some different hostname to the
outside to manage that internally without affecting visible state. Also drop
mentions of DHCP or mDNS directly setting the hostname, since nowadays network
management software is expected to (and does) go through hostnamed.

Also, add a high-level description of semantics. It glosses over the details of
handling of localhost-style names. Later commits will remove this special handling
anyway.

4 years agocoredumpctl: Add --debugger-args= option
Michal Fabik [Mon, 14 Dec 2020 14:44:36 +0000 (15:44 +0100)] 
coredumpctl: Add --debugger-args= option

This commit adds the possibility to pass command line options to the
debugger invoked with coredumpctl debug.

Resolves: #9905

4 years agoMerge pull request #17968 from yuwata/purge-libudev
Yu Watanabe [Wed, 16 Dec 2020 03:07:46 +0000 (12:07 +0900)] 
Merge pull request #17968 from yuwata/purge-libudev

udev: do not link with libudev

4 years agofirewall-util-nft: attempt table recreation when add operation fails 17026/head
Florian Westphal [Mon, 16 Nov 2020 10:15:31 +0000 (11:15 +0100)] 
firewall-util-nft: attempt table recreation when add operation fails

When someone runs 'nft flush ruleset' in the same net namespace
this will also tear down the systemd nat table.

Unlike iptables -t nat -F, which will remove all rules added by
the systemd iptables backend, iptables has builtin chains that cannot
be deleted. IOW, the next add operation will 'just work'.

In the nftables case however, the entire table gets removed.

When the systemd nat table is removed by an external entity next
attempt to add a set element will yield -ENOENT.

If this happens, recreate the table, and, if successful, re-do
the add operation.

Note that this doesn't protect against external sabotage such as
a running 'while true; nft flush ruleset;done'. However, there is
nothing that could be done short of extending the kernel to allow
tables to be "frozen" or otherwise tied to a process such as
systemd-networkd.

4 years agofirewall-util: add nftables backend
Florian Westphal [Fri, 19 Jun 2020 13:53:03 +0000 (15:53 +0200)] 
firewall-util: add nftables backend

Idea is to use a static ruleset, added when the first attempt to
add a masquerade or dnat rule is made.

The alternative would be to add the ruleset when the init function is called.
The disadvantage is that this enables connection tracking and NAT in the kernel
(as the ruleset needs this to work), which comes with some overhead that might
not be needed (no nspawn usage and no IPMasquerade option set).

There is no additional dependency on the 'nft' userspace binary or other libraries.
sd-netlinks nfnetlink backend is used to modify the nftables ruleset.

The commit message/comments still use nft syntax since that is what
users will see when they use the nft tool to list the ruleset.

The added initial skeleton (added on first fw_add_masquerade/local_dnat
call) looks like this:

table ip io.systemd.nat {
        set masq_saddr {
                type ipv4_addr
                flags interval
                elements = { 192.168.59.160/28 }
        }

        map map_port_ipport {
                type inet_proto . inet_service : ipv4_addr . inet_service
                elements = { tcp . 2222 : 192.168.59.169 . 22 }
        }

        chain prerouting {
                type nat hook prerouting priority dstnat + 1; policy accept;
                fib daddr type local dnat ip addr . port to meta l4proto . th dport map @map_port_ipport
        }

        chain output {
                type nat hook output priority -99; policy accept;
                ip daddr != 127.0.0.0/8 oif "lo" dnat ip addr . port to meta l4proto . th dport map @map_port_ipport
        }

        chain postrouting {
                type nat hook postrouting priority srcnat + 1; policy accept;
                ip saddr @masq_saddr masquerade
        }
}

Next calls to fw_add_masquerade/add_local_dnat will then only add/delete the
element/mapping to masq_saddr and map_port_ipport, i.e. the ruleset doesn't
change -- only the set/map content does.

Running test-firewall-util with this backend gives following output
on a parallel 'nft monitor':

$ nft monitor
add table ip io.systemd.nat
add chain ip io.systemd.nat prerouting { type nat hook prerouting priority dstnat + 1; policy accept; }
add chain ip io.systemd.nat output { type nat hook output priority -99; policy accept; }
add chain ip io.systemd.nat postrouting { type nat hook postrouting priority srcnat + 1; policy accept; }
add set ip io.systemd.nat masq_saddr { type ipv4_addr; flags interval; }
add map ip io.systemd.nat map_port_ipport { type inet_proto . inet_service : ipv4_addr . inet_service; }
add rule ip io.systemd.nat prerouting fib daddr type local dnat ip addr . port to meta l4proto . th dport map @map_port_ipport
add rule ip io.systemd.nat output ip daddr != 127.0.0.0/8 fib daddr type local dnat ip addr . port to meta l4proto . th dport map @map_port_ipport
add rule ip io.systemd.nat postrouting ip saddr @masq_saddr masquerade
add element ip io.systemd.nat masq_saddr { 10.1.2.3 }
add element ip io.systemd.nat masq_saddr { 10.0.2.0/28 }
delete element ip io.systemd.nat masq_saddr { 10.0.2.0/28 }
delete element ip io.systemd.nat masq_saddr { 10.1.2.3 }
add element ip io.systemd.nat map_port_ipport { tcp . 4711 : 1.2.3.4 . 815 }
delete element ip io.systemd.nat map_port_ipport { tcp . 4711 : 1.2.3.4 . 815 }
add element ip io.systemd.nat map_port_ipport { tcp . 4711 : 1.2.3.5 . 815 }
delete element ip io.systemd.nat map_port_ipport { tcp . 4711 : 1.2.3.5 . 815 }
CTRL-C

Things not implemented/supported:
1. Change monitoring.  The kernel allows userspace to learn about changes
   made by other clients (using nfnetlink notifications). It would be
   possible to detect when e.g. someone removes the systemd nat table.
   This would need more work.  Its also not clear on how to react to
   external changes -- it doesn't seem like a good idea to just auto-undo
   everthing.
2. 'set masq_saddr' doesn't handle overlaps.
   Example:

   fw_add_masquerade(true, AF_INET, "10.0.0.0" , 16);
   fw_add_masquerade(true, AF_INET, "10.0.0.0" , 8); /* fails */

With the iptables backend the second call works, as it adds an
independent iptables rule.

With the nftables backend, the range 10.0.0.0-10.255.255.255 clashes with
the existing range of 10.0.0.0-10.0.255.255 so 2nd add gets rejected by the
kernel.

This will generate an error message from networkd ("Could not enable IP
masquerading: File exists").

To resolve this it would be needed to either keep track of the added elements
and perform range merging when overlaps are detected.

However, the add erquests are done using the configured network on a
device, so no overlaps should occur in normal setups.

IPv6 support is added in a extra changeset.

Fixes: #13307
4 years agosd-netlink: add a read function
Florian Westphal [Thu, 3 Sep 2020 23:04:51 +0000 (01:04 +0200)] 
sd-netlink: add a read function

Will be used by nftables nfnetlink backend.
It sends a series of netlink messages that form a nftables
update transaction.

The transaction will then generate a series of ack messages
(or an error).

This function will be used to read these acks.

4 years agosd-netlink: add sd_netlink_sendv
Florian Westphal [Fri, 19 Jun 2020 12:58:41 +0000 (14:58 +0200)] 
sd-netlink: add sd_netlink_sendv

nftables uses a transaction-based netlink model: one netlink write
comes with multiple messages.

A 'BEGIN' message to tell nf_tables/kernel that a new transaction starts.

Then, one more messages to add/delete tables/chains/rules etc.

Lastly, an END message that commits all changes.

This function will be used to send all the individual messages that should
make up a single transaction as a single write.

4 years agosd-netlink: add nfnetlink helper routines
Florian Westphal [Fri, 19 Jun 2020 12:42:31 +0000 (14:42 +0200)] 
sd-netlink: add nfnetlink helper routines

add nfnetlink_nftables helper functions to:
 * open a new nfnetlink socket to kernel
 * add tables, chains, rules, sets and maps
 * delete/flush table
 * add and delete elements from sets/maps

4 years agosd-netlink: add nfnetlink/nftables type system
Florian Westphal [Fri, 19 Jun 2020 12:03:03 +0000 (14:03 +0200)] 
sd-netlink: add nfnetlink/nftables type system

Will be used by upcoming nftables support -- it will use the netlink
interface directly rather than add another library dependency.

4 years agolinux: import nf_tables and nfnetlink headers from Linux 5.8
Florian Westphal [Sat, 14 Mar 2020 14:21:19 +0000 (15:21 +0100)] 
linux: import nf_tables and nfnetlink headers from Linux 5.8

Will be used/needed in the upcoming nfnetlink/nftables support.
This follows existing model where kernel uapi headers are cached
locally.

4 years agofirewall-util: introduce context structure
Florian Westphal [Tue, 15 Sep 2020 17:58:44 +0000 (19:58 +0200)] 
firewall-util: introduce context structure

for planned nft backend we have three choices:

- open/close a new nfnetlink socket for every operation
- keep a nfnetlink socket open internally
- expose a opaque fw_ctx and stash all internal data here.

Originally I opted for the 2nd option, but during review it was
suggested to avoid static storage duration because of perceived
problems with threaded applications.

This adds fw_ctx and new/free functions, then converts the existing api
and nspawn and networkd to use it.

4 years agonspawn: pass userdata pointer, not inet_addr union
Florian Westphal [Tue, 13 Oct 2020 18:29:09 +0000 (20:29 +0200)] 
nspawn: pass userdata pointer, not inet_addr union

Next patch will need to pass two pointers to the callback instead
of just the addr mask.  Caller will pass a compound structure, so
make this 'void *userdata' to de-clutter the next patch.

4 years agofirewall-util: prepare for alternative to iptables backend
Florian Westphal [Thu, 25 Jun 2020 13:00:54 +0000 (15:00 +0200)] 
firewall-util: prepare for alternative to iptables backend

In a nutshell:
1. git mv firewall-util.c firewall-util-iptables.c
2. existing external functions gain _iptables_ in their names
3. firewall-util.c provides old function names
4. build system always compiles firewall-util.c,
   firewall-util-iptables.c is conditional instead (libiptc).
5. On first call to any of the 'old' API functions performs
   a probe that should return the preferred backend.

In a future step, can add firewall-util-FOOTYPE.c, add its
probe function to firewall-util.c and then have calls to
fw_add_masq/local_dnat handed to the detected backend.

For now, only iptables backend exists, and no special probing
takes place for it, i.e. when systemd was built with iptables,
that will be used.  If not, requets to add masquerade/dnat will
fail with same error (-EOPNOTSUPP) as before this change.

For reference, the rules added by the libiptc/iptables backend look like this:

for service export (via systemd-nspawn):
[0:0] -A PREROUTING -p tcp -m tcp --dport $exportedport -m addrtype --dst-type LOCAL -j DNAT --to-destination $containerip:$port
[0:0] -A OUTPUT ! -d 127.0.0.0/8 -p tcp -m tcp --dport $exportedport -m addrtype --dst-type LOCAL -j DNAT --to-destination $containerip:$port

for ip masquerade:
[0:0] -A POSTROUTING -s network/prefix -j MASQUERADE

4 years agofirewall-util: reject NULL source or address with prefixlen 0
Florian Westphal [Wed, 24 Jun 2020 09:55:14 +0000 (11:55 +0200)] 
firewall-util: reject NULL source or address with prefixlen 0

Make sure we don't add masquerading rules without a explicitly
specified network range we should be masquerading for.

The only caller aside from test case is
networkd-address.c which never passes a NULL source.

As it also passes the network prefix, that should always be > 0 as well.

This causes expected test failure:
Failed to modify firewall: Invalid argument
Failed to modify firewall: Invalid argument
Failed to modify firewall: Invalid argument
Failed to modify firewall: Protocol not available
Failed to modify firewall: Protocol not available
Failed to modify firewall: Protocol not available
Failed to modify firewall: Protocol not available

The failing test cases are amended to expect failure on
NULL source or prefix instead of success.

4 years agonetwork: Allow to configure interface promiscuous mode
Susant Sahani [Tue, 15 Dec 2020 04:00:17 +0000 (05:00 +0100)] 
network: Allow to configure interface promiscuous mode

4 years agotest: use modern qemu numa arguments
Christian Ehrhardt [Tue, 15 Dec 2020 11:05:14 +0000 (12:05 +0100)] 
test: use modern qemu numa arguments

Upgrading to qemu 5.2 breaks TEST-36-NUMAPOLICY like:
  qemu-system-x86_64: total memory for NUMA nodes (0x0) should
  equal RAM size (0x20000000)

Use the new (as in >=2014) form of memdev in test 36:
 -object memory-backend-ram,id=mem0,size=512M -numa node,memdev=mem0,nodeid=0

Since some target systems are as old as qemu 1.5.3 (CentOS7) but the new
kind to specify was added in qemu 2.1 this needs to add version parsing and
add the argument only when qemu is >=5.2.

Fixes #17986.

Signed-off-by: Christian Ehrhardt <christian.ehrhardt@canonical.com>
4 years agoMerge pull request #17967 from poettering/connect-user-bus
Lennart Poettering [Tue, 15 Dec 2020 20:14:01 +0000 (21:14 +0100)] 
Merge pull request #17967 from poettering/connect-user-bus

add support for "systemctl --user --machine=foobar@.host" for connecting to user bus of user "foobar"

4 years agobusctl: add a timestamp to the output of the busctl monitor command
d032747 [Tue, 15 Dec 2020 09:40:06 +0000 (10:40 +0100)] 
busctl: add a timestamp to the output of the busctl monitor command

4 years agoMerge pull request #17908 from ddstreet/dhcpv4_rfc2131_intervals
Yu Watanabe [Tue, 15 Dec 2020 20:05:06 +0000 (05:05 +0900)] 
Merge pull request #17908 from ddstreet/dhcpv4_rfc2131_intervals

Fix dhcpv4 renew/rebind intervals to match rfc2131

4 years agologs-show: refuse data which contain invalid fields 17799/head
Yu Watanabe [Tue, 15 Dec 2020 19:50:39 +0000 (04:50 +0900)] 
logs-show: refuse data which contain invalid fields

4 years agojournal: refuse data which contain invalid fields
Yu Watanabe [Tue, 15 Dec 2020 19:44:31 +0000 (04:44 +0900)] 
journal: refuse data which contain invalid fields

Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=25353.

4 years agojournal: move journal_field_valid() to journal_file.c
Yu Watanabe [Tue, 15 Dec 2020 19:36:14 +0000 (04:36 +0900)] 
journal: move journal_field_valid() to journal_file.c

4 years agobasic/term-util: inline colors_enabled function 17702/head
rnhmjoj [Tue, 15 Dec 2020 18:40:30 +0000 (19:40 +0100)] 
basic/term-util: inline colors_enabled function

There is no need to cache colors_enabled because the function
is now simply calling get_color_mode, which is already cached.

4 years agotree-wide: avoid direct use of color macros
rnhmjoj [Sun, 22 Nov 2020 23:40:57 +0000 (00:40 +0100)] 
tree-wide: avoid direct use of color macros

4 years agobasic/term-util: extend $SYSTEMD_COLORS
rnhmjoj [Sun, 22 Nov 2020 01:37:27 +0000 (02:37 +0100)] 
basic/term-util: extend $SYSTEMD_COLORS

This commit extends $SYSTEMD_COLORS to an enum variable (compared to
a simple boolean) which specifies the "colors mode". This means that, in
addition to disabling colors altogether, it's now possible to restrict
the console output to 16 or 256 colors only.

4 years agoudev: drop license boilerplate 17968/head
Yu Watanabe [Mon, 14 Dec 2020 13:06:18 +0000 (22:06 +0900)] 
udev: drop license boilerplate

4 years agorules: drop broken links
Yu Watanabe [Mon, 14 Dec 2020 13:05:18 +0000 (22:05 +0900)] 
rules: drop broken links

4 years agomeson: do not link with libudev
Yu Watanabe [Mon, 14 Dec 2020 11:41:32 +0000 (20:41 +0900)] 
meson: do not link with libudev

4 years agoudev: drop unnecessary libudev-util.h inclusions
Yu Watanabe [Mon, 14 Dec 2020 08:13:48 +0000 (17:13 +0900)] 
udev: drop unnecessary libudev-util.h inclusions

4 years agoudevadm: drop udev_queue
Yu Watanabe [Mon, 14 Dec 2020 09:25:27 +0000 (18:25 +0900)] 
udevadm: drop udev_queue

4 years agoudev: introduce udev_queue_is_empty() and udev_queue_init()
Yu Watanabe [Mon, 14 Dec 2020 09:20:18 +0000 (18:20 +0900)] 
udev: introduce udev_queue_is_empty() and udev_queue_init()

4 years agolibudev: fix indentation
Yu Watanabe [Mon, 14 Dec 2020 08:52:20 +0000 (17:52 +0900)] 
libudev: fix indentation

4 years agolibudev: drop unnecessary headers from libudev-util.c
Yu Watanabe [Mon, 14 Dec 2020 08:03:15 +0000 (17:03 +0900)] 
libudev: drop unnecessary headers from libudev-util.c

4 years agoudev: use encode_devnode_name() instead of udev_util_encode_string()
Yu Watanabe [Mon, 14 Dec 2020 07:59:37 +0000 (16:59 +0900)] 
udev: use encode_devnode_name() instead of udev_util_encode_string()

As udev_util_encode_string() is a simple wrapper of
encode_devnode_name().

4 years agoudev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friends
Yu Watanabe [Mon, 14 Dec 2020 07:45:12 +0000 (16:45 +0900)] 
udev: rename UTIL_LINE_SIZE -> UDEV_LINE_SIZE and friends

This also moves them to udev-util.h

4 years agoudev: move util_resolve_subsys_kernel() to udev-util.c
Yu Watanabe [Mon, 14 Dec 2020 07:40:10 +0000 (16:40 +0900)] 
udev: move util_resolve_subsys_kernel() to udev-util.c

4 years agoudev: move util_replace_chars() to udev-util.c
Yu Watanabe [Mon, 14 Dec 2020 07:26:13 +0000 (16:26 +0900)] 
udev: move util_replace_chars() to udev-util.c

4 years agoudev: move util_path_encode() and rename it to escape_path()
Yu Watanabe [Mon, 14 Dec 2020 07:17:19 +0000 (16:17 +0900)] 
udev: move util_path_encode() and rename it to escape_path()