1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-25 06:03:40 +03:00

49630 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
05c6f341b1 Allow the fallback hostname to be overriden using an environment variable
See https://bugzilla.redhat.com/show_bug.cgi?id=1893417 for the back story:
the fallback hostname matters a lot in certain environments. Right now the only
way to configure the fallback hostname is by recompiling systemd, which is
obviously problematic in case when the fallback hostname shall differ between
different editions of the same distro that share a single compiled rpm.

By making this overridable through an envvar, we're providing an escape hatch
without making this a top-level api. Later on a way to set this through
os-release is added, but I think the approach with the variable is still
useful. It it very convenient for testing, or to override settings only in a
particular service, etc.
2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
209c14705d basic/os-util: make the sentinel implicit 2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
6ef06723b1 Move os-util.[ch] to basic/
parse_os_release() will be used basic/hostname-util.c later on.
2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
fd03a6a92b sysext: move extension_release_validate() out of os-util.c 2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
addddf565b 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.
2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
aa96ef86a7 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.
2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
d55ed7de34 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.
2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
fa256f43e7 basic/env-util: add putenv_dup() 2021-02-22 20:10:55 +01:00
Zbigniew Jędrzejewski-Szmek
f70e6fb471 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.
2021-02-22 10:03:07 +01:00
Zbigniew Jędrzejewski-Szmek
8b8024f1c2 shared/conf-parser: allow more than one location of the main config file
No functional change as long as only one path is passed.
2021-02-21 12:22:13 +01:00
Yu Watanabe
38ba3da0a1 network: rename UseFQDN= -> UseHostname=
Prompted by
https://github.com/systemd/systemd/pull/18543#issuecomment-780798451.
2021-02-18 21:47:37 +01:00
Lennart Poettering
988338eb19
Merge pull request #18685 from poettering/network-type-tweaks
sd-network.h type tweaks
2021-02-18 21:19:51 +01:00
Lennart Poettering
1a8900e7ed 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...
2021-02-18 21:19:23 +01:00
Lennart Poettering
e55daa2599
Merge pull request #18546 from poettering/sd-device-action
export sd_device_get_action() API + more
2021-02-18 20:54:25 +01:00
chri2
ba2b8f9239 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.
2021-02-18 20:49:12 +01:00
Lennart Poettering
f715584018 resolved: improve debug logging on incoming messages a bit 2021-02-18 20:34:18 +01:00
Zbigniew Jędrzejewski-Szmek
e133c454b1
Merge pull request #18679 from keszybz/rfkill-size-leniency
struct rfkill_event read/write size leniency
2021-02-18 19:53:25 +01:00
Lennart Poettering
0eaee8281d journald: when we fail to add a new entry to a journal, return the seqno
Fixes: #18005
2021-02-18 18:30:52 +01:00
Lennart Poettering
ff03bfa508 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)
2021-02-18 18:21:25 +01:00
Lennart Poettering
a113002214 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.
2021-02-18 18:20:56 +01:00
Lennart Poettering
669963968c
Merge pull request #18664 from poettering/resolved-defrag
resolved: many UDP fragmentation tweaks
2021-02-18 18:20:36 +01:00
Lennart Poettering
96fb82aa06 sd-device: don't compare pointers with numeric zero
Our coding style says no to this.
2021-02-18 18:20:09 +01:00
Lennart Poettering
5f94d96c47
Merge pull request #18667 from poettering/resolved-change-notification
resolved: optimize dbus change notification signals a bit
2021-02-18 18:19:09 +01:00
Lennart Poettering
135c4aad4c network: tighten table alignment a bit 2021-02-18 18:17:16 +01:00
Lennart Poettering
2324fd3a39 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.
2021-02-18 18:17:16 +01:00
Lennart Poettering
cbf23f3853 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)
2021-02-18 16:38:27 +01:00
Lennart Poettering
e4304fb8d4 basic: add set_equal() helper 2021-02-18 16:38:27 +01:00
Lennart Poettering
980821f3f0 resolved: take fragment size into consideration when determining EDNS0 udp packet size 2021-02-18 15:55:58 +01:00
Lennart Poettering
acbf761b5d 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.
2021-02-18 15:55:58 +01:00
Lennart Poettering
d79677ab44 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.
2021-02-18 15:55:58 +01:00
Lennart Poettering
4565863fff resolved: add udp_header_size() helper 2021-02-18 15:55:58 +01:00
Lennart Poettering
20a001bdd7 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.
2021-02-18 15:42:18 +01:00
Lennart Poettering
eb170e75ab 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.
2021-02-18 15:42:18 +01:00
Дамјан Георгиевски
95aa3937da 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"
2021-02-18 15:40:47 +01:00
Lennart Poettering
489344f24b 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
2021-02-18 14:12:42 +00:00
Zbigniew Jędrzejewski-Szmek
2a5095af0c
Merge pull request #18557 from poettering/enum-force-s64
force public enums to be 64bit wide
2021-02-18 14:16:15 +01:00
Susant Sahani
d75bf6cfe2 network: Add "route_localnet" sysctl support 2021-02-18 21:04:17 +09:00
Zbigniew Jędrzejewski-Szmek
d97a35e228
Merge pull request #18665 from poettering/resolved-fastopen
resolved: use TCP FASTOPEN on the local DNS stub
2021-02-18 12:55:10 +01:00
Luca Boccassi
905348da28
Merge pull request #18625 from bluca/sysext_refactor
dissect: parse and store extension-release metadata
2021-02-18 10:43:08 +00:00
Zbigniew Jędrzejewski-Szmek
a71c096850 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.
2021-02-18 11:25:04 +01:00
Zbigniew Jędrzejewski-Szmek
6c7afdeab0 rfkill: improve error logging
If we get something of unexpected size, log the sizes. Also, don't log twice.
2021-02-18 10:40:16 +01:00
Richard Laager
f542f3b2ed 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>
2021-02-18 16:51:27 +09:00
Lennart Poettering
dc288ffeab
Merge pull request #18596 from keszybz/systemctl-quiet-legend
systemctl: hide legends with --quiet, allow overriding
2021-02-17 23:40:04 +01:00
Lennart Poettering
a63b54eda5
Merge pull request #18651 from poettering/einval-followup
two follow-up fixes for the enum einvalification
2021-02-17 23:15:50 +01:00
Susant Sahani
176321cb95 network: DHCP option- use correct byteorder 2021-02-17 23:15:26 +01:00
Lennart Poettering
07335f7f1f
Merge pull request #18656 from yuwata/network-nexthop-tiny-cleanups
network: nexthop: tiny cleanups
2021-02-17 23:14:12 +01:00
Lennart Poettering
6e825539d2 hwdb: fix indentation
a bunch of entries use 2ch instead of 1ch indentation. Fix that.
2021-02-17 23:13:45 +01:00
Lennart Poettering
2840d6f61d
Merge pull request #18662 from yuwata/in-addr-is-set
in-addr-util: introduce in_addr_is_set() or friends
2021-02-17 23:13:27 +01:00
Zbigniew Jędrzejewski-Szmek
42a033f784 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.
2021-02-17 23:13:01 +01:00
Luca Boccassi
93547f2812 env-util: refactor parsing helper for SYSTEMD_SYSEXT_HIERARCHIES out of sysext 2021-02-17 21:45:31 +00:00