Commit Graph

29902 Commits

Author SHA1 Message Date
Yu Watanabe 28266c446a udev: drop unnecessary checks
Also, drop one unnecessary sd_device_unref(), as dev_db_clone will be
unref()ed in udev_event_free().
2020-07-21 11:55:28 +09:00
Yu Watanabe ae353ec2f6 udev: save ID_RENAMING= property to database before renaming network interface 2020-07-21 11:55:28 +09:00
Yu Watanabe 1cdea1a2f7 network: update one log message 2020-07-21 11:55:28 +09:00
Hans de Goede 3a978b30cd logind: Fix org.freedesktop.login1.set-reboot-to-boot-loader-menu saving to the wrong file in the non EFI case
According to the docs, and to the
org.freedesktop.login1.get-reboot-to-boot-loader-menu code, the
(oneshot) boot-loader-menu timeout should be stored in
/run/systemd/reboot-to-boot-loader-menu, but the set method was storing it
in /run/systemd/reboot-to-loader-menu.

This commit fixes this. Note that the fixed name also is a better match
for the dbus call names and matches the related
/run/systemd/reboot-to-boot-loader-entry structure, so fixing the set code,
rather then the get code + docs seems like the right thing to do here.
2020-07-21 10:02:34 +09:00
fangxiuning ddbab78f9a bus: use bus_log_connect_error to print error message 2020-07-21 10:02:01 +09:00
Yu Watanabe a574b7d152 resolvectl: use bus_message_read_in_addr_auto() 2020-07-21 04:12:11 +09:00
Yu Watanabe 7695e2cbbe network, resolve: use bus_message_read_ifindex() or friends 2020-07-21 04:08:22 +09:00
Yu Watanabe 3dd95ab6c5 util: introduce bus_message_read_ifindex() 2020-07-21 04:08:22 +09:00
Yu Watanabe 10d4620467 util: introduce bus_mesage_read_dns_servers() 2020-07-21 04:08:22 +09:00
Yu Watanabe 976009897b util: introduce helper functions to read in_addr from bus message 2020-07-21 04:08:22 +09:00
Yu Watanabe e293e755d5 util: drop duplicated inclusion of sd-bus.h 2020-07-21 04:08:22 +09:00
Yu Watanabe a747e71c56 resolvectl: show DNS servers with port and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe b1881e8320 resolvectl: make DNS servers can be specified with port number and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe 8e56ea4c88 resolve: add DBus properties which support DNS SNI and port number 2020-07-21 04:08:22 +09:00
Yu Watanabe 95ce1ba87b resolve: add DBus method to set DNS server with port number and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe 4e11ddfdd3 network: add DBus method to set DNS server with port number and SNI 2020-07-21 04:08:22 +09:00
Yu Watanabe 87d6489776 network: save DNS servers specified by DBus interface
Also, filter out DNS servers which do not match link ifindex.
2020-07-21 04:08:22 +09:00
Yu Watanabe 6458176514 network: do not save DNS= entries not match link ifindex 2020-07-21 04:08:22 +09:00
Yu Watanabe e77bd3fdff network: support port number and SNI in [Network] DNS= 2020-07-21 04:08:22 +09:00
Yu Watanabe 8aa5afd20f resolve: read/save port number and SNI from/into link state file 2020-07-21 04:08:16 +09:00
Yu Watanabe b6af282475 resolve: compare port and SNI in dns_server_hash_ops 2020-07-21 04:04:49 +09:00
Yu Watanabe 1b86009298 resolve: also compare port and SNI in dns_server_find() 2020-07-21 04:04:49 +09:00
Yu Watanabe da9de7385a resolve: support port specifier in DNS= setting 2020-07-21 04:04:42 +09:00
Yu Watanabe 395aa34023 resolve: ignore empty server name
Just for safety.
2020-07-21 03:55:34 +09:00
Yu Watanabe 408f8fbc0f util: introduce 'struct in_addr_full' and its helper functions 2020-07-21 03:55:34 +09:00
Yu Watanabe a723fb85da util: introduce in_addr_port_ifindex_name_from_string_auto() and in_addr_port_ifindex_name_to_string() 2020-07-21 03:55:34 +09:00
Yu Watanabe cbe194b39e resolve: propagate error in link_load_user()
Most error path in link_load_user() are ENOMEM. Hence, it is critical.
2020-07-21 03:55:34 +09:00
Yu Watanabe eced0d2a46
Merge pull request #16518 from yuwata/network-fix-failure-in-updating-mac-address
network: fix failures in updating MAC address
2020-07-21 02:13:24 +09:00
Zbigniew Jędrzejewski-Szmek 7e8279c0a6
Merge pull request #16501 from yuwata/udev-fix-renaming
udev: fix issues in renaming interface vs alternative names
2020-07-20 09:00:02 +02:00
Yu Watanabe 807667f7ac network: stop already running engines before updating MAC address
In NetworkdBridgeTests.test_bridge_configure_without_carrier of
systemd-networkd-tests.py

```
bridge99: MAC address: 2e:3a:ec:4d:d3:62
Assertion 'sd_ipv4ll_is_running(ll) == 0' failed at src/libsystemd-network/sd-ipv4ll.c:110, function int sd_ipv4ll_set_mac(sd_ipv4ll *, const struct ether_addr *)(). Ignoring.
bridge99: Could not update MAC address in IPv4LL client: Device or resource busy
```
2020-07-20 15:29:55 +09:00
Yu Watanabe 96fe813c42 radv: introduce sd_radv_is_running() 2020-07-20 15:29:12 +09:00
Yu Watanabe 48c5398951 networkctl: do not ignore -EOPNOTSUPP when reading netlink message
If the kernel does not support alternative interface names, then
sd_netlink_message_read_strv() should just return -ENODATA.
2020-07-20 15:24:40 +09:00
Yu Watanabe ae5b779252 networkctl: sort alternative names 2020-07-20 15:24:40 +09:00
Franck Bui 0ef1adf512 vconsole-setup: downgrade log message when setting font fails on dummy console
Since commit 883eb9be98, vconsole-setup might be
called again to operate on dummy console where font operations are not
supported but where it's still important to have the correct keymap set [0][1].

vconsole-setup is mainly called by udev but can also be run via a dependency of
an early service. Both cases might end up calling vconsole-setup on the dummy
console.

The first case can happen during early boot even on systems that use (instead
of the dummy console) a "simple" video console driver supporting font
operations (such as vgacon) until a more specific driver (such as i915) takes
the console over. While this is happening vgacon is deactivated and temporarly
replaced by the dummy console [2].

There are also other cases where systemd-vconsole-setup might be called on
dummy console especially during (very) early boot. Indeed
systemd-vconsole-setup.service might be pulled in by early interactive services
such as 'dracut-cmdline-ask.service` which is run before udev.

If that happens on platforms with no grapical HWs (such as embedded ARM) or
with dummy console initially installed until a driver takes over (like Xen and
xen-fbfront) then setting font will fail.

Therefore this patch downgrades the log message emitted when setting font fails
to LOG_DEBUG and when font operations is not implemented like it's the case for
the dummy console.

Fixes: #16406.

[0] https://github.com/systemd/systemd/issues/10826
[1] https://bugzilla.redhat.com/show_bug.cgi?id=1652473
[2] https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/drivers/gpu/vga/vgaarb.c?h=v5.7#n204
2020-07-20 08:15:50 +02:00
Yu Watanabe 628f08b66d sd-netlink: make timeout message sealed
When sd_netlink_call_async() timed out, then we reply the synthetic
error message, but it was not sealed. So, reading the message causes
the following assertion:

```
Assertion 'm->sealed' failed at src/libsystemd/sd-netlink/netlink-message.c:652, function netlink_message_read_internal(). Ignoring.
```
2020-07-20 07:49:55 +02:00
Zbigniew Jędrzejewski-Szmek d735e4f2d6
Merge pull request #16505 from yuwata/network-manage-foreign-routes-cleanups
network: do not enumerate foreign routes when ManageForeignRoutes=no, and tiny cleanups
2020-07-20 07:48:57 +02:00
Luca Boccassi ed4512d009 nspawn: set container_host env vars before user arguments
Allows users on the command line to seamlessly override
$container_host_* just like they can override $container_id and
$container
2020-07-20 07:28:22 +02:00
YmrDtnJu a9c9b18a95 networkd: Use NLM_F_ACK on the netlink message to add a neighbor.
sd_netlink_message_set_flags is called without NLM_F_ACK which results in
a timeout while networkd is waiting for an ACK that the kernel will never send.
2020-07-20 11:30:35 +09:00
Yu Watanabe 4573592ddf
Merge pull request #16512 from keszybz/offline-passwd-altfiles
Support alternate passwd/group locations in tmpfiles
2020-07-19 06:46:05 +09:00
Zbigniew Jędrzejewski-Szmek 241947d1b4 shared/offline-passwd: look at /usr/lib/{passwd,group} too
This changes the code to allow looking at multiple files with different
prefixes, but uses "/etc" and "/usr/lib". rpm-ostree uses
/usr/lib/{passwd,group} with nss-altfiles. I see no harm in simply trying both
paths on all systems.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1857530.

A minor memory leak is fixed: hashmap_put() returns -EEXIST is the key is
present *and* and the value is different. It return 0 if the value is the
same. Thus, we would leak the user/group name if it was specified multiple
times with the same uid/gid. I opted to remove the warning message completely:
with multiple files it is reasonable to have the same name defined more than
once. But even with one file the warning is dubious: all tools that read those
files deal correctly with duplicate entries and we are not writing a linter.
2020-07-18 14:14:19 +02:00
Zbigniew Jędrzejewski-Szmek 3e5d2264b5 Move offline-password.[ch] to shared and add test-offline-passwd
The test binary has two modes: in the default argument-less mode, it
just checks that "root" can be resolved. When invoked manually, a root
prefix and user/group names can be specified.
2020-07-18 14:14:19 +02:00
Yu Watanabe 0119ab3d6c
Merge pull request #16476 from keszybz/qemu-autosuspend-rules
Add autosuspend rules for emulated QEMU devices
2020-07-18 09:10:20 +09:00
Yu Watanabe a8c10331b4 network: replace NDISC -> NDisc in log messages 2020-07-18 05:51:41 +09:00
Yu Watanabe 5eec0a0810 network: introduce address_exists() helper function 2020-07-18 05:51:41 +09:00
Yu Watanabe d15818f227 network: update debug log when foreign routes are received with ManageForeignRoutes=no 2020-07-18 05:51:41 +09:00
Yu Watanabe 5ff1ef31f2 network: do not enumerate routes if ManageForeignRoutes=no 2020-07-18 05:51:32 +09:00
Yu Watanabe 97fdae33df udev: do not try to reassign alternative names
Setting alternative names may fail if some of them are already assigned.
2020-07-17 21:36:11 +09:00
Yu Watanabe 434a348380 netlink: do not fail when new interface name is already used as an alternative name
When renaming a network interface, the new name may be used as an
alternative name. In that case, let's swap the current name and the
alternative name. That is, first drop the new name from the list of
alternative names, then rename the interface, finally set the old name
as an alternative name.
2020-07-17 21:31:47 +09:00
Yu Watanabe 1498252614 netlink: introduce rtnl_get/delete_link_alternative_names() 2020-07-17 21:29:13 +09:00
Yu Watanabe 7f16ef9fba
Merge pull request #16490 from yuwata/network-radv-ndisc-cleanups
network: cleanups for radv and ndisc
2020-07-17 15:12:53 +09:00
Zbigniew Jędrzejewski-Szmek dc9e9a18be
Merge pull request #16491 from keszybz/udev-logging
Improvements to udev logging and related code
2020-07-17 07:12:58 +02:00
Zbigniew Jędrzejewski-Szmek 9e79123884 tree-wide: use SYNTHETIC_ERRNO with log_device_* in more places 2020-07-16 22:08:12 +02:00
Zbigniew Jędrzejewski-Szmek 46d4149d0f sd-device: use LOG_PRI() in log_device_full()
We use LOG_PRI() in all log_*() functions, so let's do that here too for
consistency. Effectively this doesn't change anything since we only use
LOG_{INFO,DEBUG,...} as the argument.
2020-07-16 22:05:21 +02:00
Anita Zhang b5ef66101a analyze: CAP_RAWIO -> CAP_SYS_RAWIO
Fixes #16489
2020-07-16 21:14:59 +02:00
Yu Watanabe 94ec163ad2 timedatectl: do not show (null) if the address of NTP server is not resolved 2020-07-17 03:10:42 +09:00
Zbigniew Jędrzejewski-Szmek df7667323d udev: change the modalias string for usb devices to include the device name
When the kernel does not provide a modalias, we generate our own for usb devices.
For some reason, we generated the expected usb:vXXXXpYYYY string, suffixed by "*".
It was added that way already in 796b06c21b, but I
think that was a mistake, and Kay was thinking about the match pattern instead
of the matched string.

For example, for a qemu device:
old: "usb:v0627p0001*"
new: "usb:v0627p0001:QEMU USB Tablet"

On the match side, all hwdb files in the wild seem to be using match patterns
with "*" at the end. So we can add more stuff to our generated modalias with
impunity.

This will allow more obvious and more certain matches on USB devices. In
principle the vendor+product id should be unique, but it's only 8 digits, and
there's a high chance of people getting this wrong. And matching the wrong
device would be quite problematic. By including the name in the match string we
make a mismatch much less likely.
2020-07-16 19:00:26 +02:00
Zbigniew Jędrzejewski-Szmek d6d4961b01 udev: don't complain when udev_watch_end() is called without udev_watch_init()
E.g. udevadm test prints "Invalid inotify descriptor." which is
meaningless without any context. I think it should be OK to call udev_watch_end()
from a cleanup path without any warning (even at debug level).
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek 6b9f5f01cb basic/string-table: reduce variable scope 2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek 5992f362bf udevadm: use STR_IN_SET(), add comment 2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek fe20121a4c sd-device: use strjoin instead of asprintf
strjoin should be faster for string concatenation.
Also drop "_"-prefix from function prototypes.
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek 22ba4525d3 udev: tweak debug logs for udev rules
We shouldn't say "ignoring" when running a program because the result is used for
the match/nomatch result of the rule.
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek ba60127df7 udev: accept OPTIONS+= without any fuss
There is no reason to consider this wrong. In fact one could argue that +=
is more appropriate, because we always add to options, and not replace previous
assignments. If we output a debug message, we implicitly ask people to "fix" this,
and we shouldn't.

Also, all our rules use += right now.
2020-07-16 18:38:03 +02:00
Zbigniew Jędrzejewski-Szmek b6a80b83bc udev: accept IMPORT{}= without any fuss
Udev logs are full of messages about wrong operator type:
...
Reading rules file: /usr/lib/udev/rules.d/60-persistent-storage.rules
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:30 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:54 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:57 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:60 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:63 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:66 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:67 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:93 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:107 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:110 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-storage.rules:113 IMPORT key takes '==' or '!=' operator, assuming '=='.
Reading rules file: /usr/lib/udev/rules.d/60-persistent-v4l.rules
/usr/lib/udev/rules.d/60-persistent-v4l.rules:7 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-v4l.rules:9 IMPORT key takes '==' or '!=' operator, assuming '=='.
/usr/lib/udev/rules.d/60-persistent-v4l.rules:16 IMPORT key takes '==' or '!=' operator, assuming '=='.
...

The warning was downgraded in f0beb6f816, but I
think it should be removed altogether. IMPORT{program}="asdf" seems like an
obvious way to write this, and people don't expect to have to write "==".
So let's just allow any operator.
2020-07-16 18:38:03 +02:00
Yu Watanabe 13e8a49a58 network: ndisc: any failures in processing event make the link in failed state
Also adjust log levels.
2020-07-17 01:18:44 +09:00
Yu Watanabe c97785168b network: radv: clean up conf parsers 2020-07-17 01:16:38 +09:00
Yu Watanabe d96edb2c6e network: downgrade log level in conf parsers 2020-07-17 00:40:09 +09:00
Lennart Poettering 4d939d2c84
Merge pull request #16485 from bluca/nspawn_os_release_mounts
Follow-up for comments on #15891
2020-07-16 15:09:35 +02:00
Yu Watanabe 9e54462cd5
Merge pull request #16482 from poettering/coverity-246
two coverity fixes
2020-07-16 20:23:23 +09:00
Luca Boccassi 14f1c47a0c nspawn: mount os-release in two steps to make it read-only
The kernel interface requires setting up read-only bind-mounts in
two steps, the bind first and then a read-only remount.
Fix nspawn-mount, and cover this case in the integration test.

Fixes #16484
2020-07-16 09:59:59 +01:00
Luca Boccassi eafc7d6056 nspawn: use access/F_OK instead of stat to check for file existence 2020-07-16 09:59:59 +01:00
Luca Boccassi 2094cd49c4 shared/os-util: fix comment style to follow guidelines 2020-07-16 09:59:59 +01:00
Luca Boccassi cc76bf01e3 basic/mkdir: use uid_is_valid instead of manual check 2020-07-16 09:59:59 +01:00
Zbigniew Jędrzejewski-Szmek 27806670ef
Merge pull request #16480 from yuwata/network-fix-dhcp4-races
network: fix two minor races in DHCP4 handling
2020-07-16 10:04:05 +02:00
Lennart Poettering 3cd4459003 Revert "selinux: cache enforced status and treat retrieve failure as enforced mode"
This reverts commit 257188f80c.
2020-07-16 08:49:35 +02:00
Lennart Poettering 8e32ad9557 machine: fix if check
Fixes: coverity 1430462
2020-07-16 08:35:26 +02:00
Lennart Poettering f63ef93703 execute: fix if check
Fixes: coverity 1430459
2020-07-16 08:35:18 +02:00
Yu Watanabe 0ded0e40ab dhcp4: only renewing lease when the client already has a lease
Follow-up for ceaec54a3c.

Hopefully fixes #16299.
2020-07-16 14:58:54 +09:00
Lennart Poettering 330f899079 load-fragment: downgrade log messages we ignore to LOG_WARNING
We typically don't log above LOG_WARNING about issues we then go on to
ignore. Do so here, too
2020-07-16 14:58:05 +09:00
Lennart Poettering 89a5385fb7 mountpoint-util: fix error handling 2020-07-16 14:56:40 +09:00
Yu Watanabe f766d9af38 network: dhcp4: add two warnings 2020-07-16 10:54:16 +09:00
Yu Watanabe 153cf04139 network: dhcp4: fix another race with SendDecline=yes
If the SD_IPV4ACD_EVENT_BIND event happens before all routes are
assigned, then the link stuck in configuring state.
2020-07-16 10:54:08 +09:00
Yu Watanabe 75be72d139 network: dhcp4: also release old lease in dhcp_lease_lost()
The lease lost may happen during renewing address. If it happens,
assertion hits in dhcp4_release_old_lease().
2020-07-16 10:51:46 +09:00
Lennart Poettering 8d5bb13d78 core: fix invalid assertion
We miscounted here, and would hit an assert once too early.
2020-07-16 09:13:04 +09:00
Christian Göttsche aeba8dd523 network: fix typo 2020-07-16 08:45:42 +09:00
Zbigniew Jędrzejewski-Szmek 95b29f3267
Merge pull request #16396 from yuwata/network-configured-flag
network: about xxx_configured flags
2020-07-15 15:45:38 +02:00
Zbigniew Jędrzejewski-Szmek b8ff0663e8
Merge pull request #16468 from keszybz/two-unrelated-patches
Two unrelated patches
2020-07-15 13:40:22 +02:00
Yu Watanabe 43bf28741f network: drop doubled white space 2020-07-15 17:15:25 +09:00
Yu Watanabe 93b0b88c3a network: free address when it is removed 2020-07-15 17:15:25 +09:00
Yu Watanabe 6906794dd1 network: dhcp4: do not assign new address before old one is not removed
If DHCP4 client lost a lease, and then soon acquire new lease, then
the removal of the old address may not be completed. If that happens,
and the new and old addresses are the same, then the new address will be
considered as a foreign address. Such a situation can occur when the
DHCP4 server is restarted.

This makes networkd wait for the removal of the old address when a new
lease is acquired.

This also makes the link in configuring state when renewing address.
2020-07-15 17:15:25 +09:00
Yu Watanabe 5d976f5f64 network: do not call link_check_ready() in link_request_set_routing_policy_rule()
It will be called in link_request_set_nexthop() or serveral handlers().
2020-07-15 17:15:25 +09:00
Yu Watanabe 0c816fcc7b network: make link_request_set_nexthop() called from link_request_set_routes() or route_handler()
Then we can drop static_routes_ready() flag.
2020-07-15 17:15:25 +09:00
Yu Watanabe 659ad3a0af network: do not make link in configured state when no address is assigned
When DHCP6 and RA are enabled, and RA does not provide any addresses,
then link may become configured state even if no address is assigned,
due to the time-lag between RA completion and DHCP reply.
This makes if DHCP is explicitly enabled, then link must have at least
one valid address to be in the configured state.
2020-07-15 17:15:25 +09:00
Yu Watanabe d98c546dac network: ndisc: split ndisc_configured flag into for addresses and routes 2020-07-15 17:15:25 +09:00
Yu Watanabe 01c344bdd4 network: ndisc: do not ignore remaining addresses
Follow-up for c24c83dc67.
2020-07-15 17:15:25 +09:00
Yu Watanabe 39373cb984 network: add debugging log why link is not in configured state yet 2020-07-15 17:15:16 +09:00
Yu Watanabe eb01a2dfb1 network: make link_request_set_nexthop() static 2020-07-15 17:14:30 +09:00
Yu Watanabe a4623f84ed network: add a debugging log 2020-07-15 17:14:30 +09:00
Yu Watanabe feb596b5c3 network: include error code in the log message 2020-07-15 17:14:30 +09:00
Yu Watanabe 2a877f4560 network: set dhcp6_xxx_configured flag after routes/addresses are assigned 2020-07-15 17:14:30 +09:00
Lennart Poettering ee5c1311ee logs: when embedding catalog info in log output use a dash of color and unicode
let's separate things out a bit, to make it easier to discern log output
and catalog data.

catalog data is now colored green (which is a color we don't use for log
data currently), and prefixed with a block shade.
2020-07-15 09:32:03 +02:00
Zbigniew Jędrzejewski-Szmek a996ead6a2
Merge pull request #16398 from poettering/machined-varlink
machined: move UID/GID resolution logic to userdb, i.e. from nss-mymachines to nss-systemd
2020-07-15 09:24:49 +02:00
Filipe Brandenburger 26698337f3 timer: Adjust calendar timers based on monotonic timer instead of realtime
When the RTC time at boot is off in the future by a few days, OnCalendar=
timers will be scheduled based on the time at boot. But if the time has been
adjusted since boot, the timers will end up scheduled way in the future, which
may cause them not to fire as shortly or often as expected.

Update the logic so that the time will be adjusted based on monotonic time.
We do that by calculating the adjusted manager startup realtime from the
monotonic time stored at that time, by comparing that time with the realtime
and monotonic time of the current time.

Added a test case to validate this works as expected. The test case creates a
QEMU virtual machine with the clock 3 days in the future. Then we adjust the
clock back 3 days, and test creating a timer with an OnCalendar= for every 15
minutes. We also check the manager startup timestamp from both `systemd-analyze
dump` and from D-Bus.

Test output without the corresponding code changes that fix the issue:

  Timer elapse outside of the expected 20 minute window.
    next_elapsed=1594686119
    now=1594426921
    time_delta=259198

With the code changes in, the test passes as expected.
2020-07-15 09:23:09 +02:00
Zbigniew Jędrzejewski-Szmek 76830e2500
Merge pull request #16462 from keszybz/rpm-macro-warnings
Emit better errors for rpm macro misuse
2020-07-15 08:56:28 +02:00
Zbigniew Jędrzejewski-Szmek b56a877ef8 test-fs-util: use log_info instead of printf
The test is failing in koji, and the line from printf() does not end up
in the logs for some reason. log_info() works fine, so let's just use
that here too.
2020-07-14 22:18:38 +02:00
Zbigniew Jędrzejewski-Szmek 6cdc429454
Merge pull request #16340 from keszybz/var-tmp-readonly
Create ro private /var/tmp dir when /var/tmp is read-only
2020-07-14 19:59:48 +02:00
Zbigniew Jędrzejewski-Szmek 56a13a495c pid1: create ro private tmp dirs when /tmp or /var/tmp is read-only
Read-only /var/tmp is more likely, because it's backed by a real device. /tmp
is (by default) backed by tmpfs, but it doesn't have to be. In both cases the
same consideration applies.

If we boot with read-only /var/tmp, any unit with PrivateTmp=yes would fail
because we cannot create the subdir under /var/tmp to mount the private directory.
But many services actually don't require /var/tmp (either because they only use
it occasionally, or because they only use /tmp, or even because they don't use the
temporary directories at all, and PrivateTmp=yes is used to isolate them from
the rest of the system).

To handle both cases let's create a read-only directory under /run/systemd and
mount it as the private /tmp or /var/tmp. (Read-only to not fool the service into
dumping too much data in /run.)

$ sudo systemd-run -t -p PrivateTmp=yes bash
Running as unit: run-u14.service
Press ^] three times within 1s to disconnect TTY.
[root@workstation /]# ls -l /tmp/
total 0
[root@workstation /]# ls -l /var/tmp/
total 0
[root@workstation /]# touch /tmp/f
[root@workstation /]# touch /var/tmp/f
touch: cannot touch '/var/tmp/f': Read-only file system

This commit has more changes than I like to put in one commit, but it's touching all
the same paths so it's hard to split.
exec_runtime_make() was using the wrong cleanup function, so the directory would be
left behind on error.
2020-07-14 19:47:15 +02:00
Zbigniew Jędrzejewski-Szmek 1061fc1c17 rpm: include macro name in errors for two args macros too 2020-07-14 19:22:42 +02:00
Zbigniew Jędrzejewski-Szmek 281014b73e rpm: adjust various macros to print macro name in the error message
Based on initial patch by Jan Engelhardt <jengelh@inai.de>.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1856122.
2020-07-14 19:21:12 +02:00
Zbigniew Jędrzejewski-Szmek 8800df5f71
Merge pull request #16430 from mikhailnov/fix-rpm-create-package-macros
Fix RPM *_create_package macros
2020-07-14 19:02:09 +02:00
Lennart Poettering 38ccb55731 nss-mymachines: drop support for UID/GID resolving
Now that we make the user/group name resolving available via userdb and
thus nss-systemd, we do not need the UID/GID resolving support in
nss-mymachines anymore. Let's drop it hence.

We keep the module around, since besides UID/GID resolving it also does
hostname resolving, which we care about. (One of those days we should
replace that by some Varlink logic between
nss-resolve/systemd-resolved.service too)

The hooks are kept in the NSS module, but they do not resolve anything
anymore, in order to keep compat at a maximum.
2020-07-14 17:08:12 +02:00
Lennart Poettering 4751364e76 machined: implement user/group lookup varlink API in machined too
Let's natively support our own API in machined too.

This allows us to remove half of nss-mymachines in a later commit.
2020-07-14 17:06:23 +02:00
Lennart Poettering 74d1b7d2ad machined: refactor UID/GID machine translation
Let's move the heavy lifting out of the bus call implemntations, and
into generic code.

This allows us to expose them easily via Varlink too in a later commit.
2020-07-14 17:06:23 +02:00
Lennart Poettering a07f18cd30 process-util: make sure procfs_file_alloca() works for non-literal field names too 2020-07-14 17:06:23 +02:00
Lennart Poettering 56870d324b docs: permit user/group services that do not support enumeration
sssd people don't like enumeration and for some other cases it's not
nice to support either, in particular when synthesizing records for
container/userns UID/GID ranges.

Hence, let's make enumeration optional.
2020-07-14 16:44:52 +02:00
Lennart Poettering 08ef688656 analyze: make testing ConditionPathExistsGlob= work
Fixes: #16439
Alternative-To: #16440
2020-07-14 14:59:18 +02:00
Lennart Poettering 77ee1783eb udevadm: beef up deprecation log warning
Let's add a catalog entry explaining further details.

Most importantly though: talk to PID 1 directly, via the private D-Bus
socket, so that this actually works correctly during early boot, where
D-Bus is not around.
2020-07-14 14:57:19 +02:00
Zbigniew Jędrzejewski-Szmek 46072ae35a repart: include more relevant information in the warning message, fix test
The test would always fail with a long uname. In F33 this is right
now "5.8.0-0.rc2.20200622git625d3449788f.1.fc33.x86_64" which caused the
test to always fail.
2020-07-13 03:43:26 +09:00
Yu Watanabe 5553041a62
Merge pull request #16435 from gaoyi1988/master
fix multi matches when use "||"
2020-07-12 21:46:22 +09:00
Zbigniew Jędrzejewski-Szmek ddcdcac519
Merge pull request #16432 from cgzones/selinux_err_fix
SELlinux followup error/logging fixes
2020-07-12 11:55:44 +02:00
gaoyi 1e67a9c2cd udev: specify the end of value
NULSTR_FOREACH may read the illegal match

Signed-off-by: gaoyi <ymuemc@163.com>
2020-07-12 03:24:42 -04:00
fangxiuning d67b1d18fc bus: use bus_log_parse_error to print message 2020-07-12 06:33:48 +09:00
Christian Göttsche f2df56bfea namespace: unify logging in mount_tmpfs
Fixes: abad72be4d
Follow up: #16426
2020-07-11 21:25:39 +02:00
Christian Göttsche db06c162e8 shared: fix error handling in make_inaccessible_nodes
_label wrappers return -errno on failure instead of returning -1 and
setting global errno.

Fixes: 8d9cbd809d
Follow up: #16426
2020-07-11 21:25:39 +02:00
Mikhail Novosyolov 3e6e0856cd rpm: avoid hiding errors and output in *_create_package macros
Commit b0ca726585 "rpm: avoid hiding errors from systemd commands" remove hiding errors and output
for other macros, but did not do that for %sysusers_create_package and %tmpfiles_create_package.

This change syncs their behaviour with %sysusers_create and %tmpfiles_create

Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
2020-07-11 17:20:23 +03:00
Mikhail Novosyolov 93406fd379 rpm: avoid odd symbols in EOF indicator
The last line in this macros was actually "SYSTEMD_INLINE_EOF " with a space at the end,
but the shell was instructed to look for a line without space.

Macros %sysusers_create_inline and %tmpfiles_create_inline did not have this mistake.

An example:
[root@rosa-2019 bind-server]# cat /etc/passwd | grep named
[root@rosa-2019 bind-server]# cat /tmp/bs
systemd-sysusers --replace=/usr/lib/sysusers.d/named.conf - <<SYSTEMD_INLINE_EOF >/dev/null 2>&1 || :
u named - "BIND DNS Server" /var/lib/named
g named - -
m named named
SYSTEMD_INLINE_EOF
[root@rosa-2019 bind-server]# sh /tmp/bs
/tmp/bs: line 5: warning: here-document at line 1 delimited by end-of-file (wanted `SYSTEMD_INLINE_EOF')
[root@rosa-2019 bind-server]# bash /tmp/bs
/tmp/bs: line 5: warning: here-document at line 1 delimited by end-of-file (wanted `SYSTEMD_INLINE_EOF')
[root@rosa-2019 bind-server]# bash --version
GNU bash, version 5.0.17(1)-release (x86_64-openmandriva-linux-gnu)

The user and group named were NOT created!

Now I remove the trailing space after "SYSTEMD_INLINE_EOF" and rerun:
[root@rosa-2019 bind-server]# sh /tmp/bs
[root@rosa-2019 bind-server]# tail -n 1 /etc/group
named485:named
[root@rosa-2019 bind-server]#

The user and group have been created correctly.

Signed-off-by: Mikhail Novosyolov <m.novosyolov@rosalinux.ru>
2020-07-11 17:20:16 +03:00
Zbigniew Jędrzejewski-Szmek b159831b61
Merge pull request #16424 from keszybz/cap-bpf-compat
Handle new capabilities gracefully
2020-07-11 13:35:34 +02:00
Christian Göttsche abad72be4d namespace: fix MAC labels of TemporaryFileSystem=
Reproducible with:
  systemd-run -p TemporaryFileSystem=/root -t /bin/bash
    ls -dZ /root

Prior:
  root:object_r:tmpfs_t:s0 /root
Past:
  root:object_r:user_home_dir_t:s0 /root
2020-07-11 00:09:05 +02:00
Christian Göttsche 8d9cbd809d selinux: create standard user-runtime nodes with default context
Currently systemd-user-runtime-dir does not create the files in
/run/user/$UID/systemd/inaccessible with the default SELinux label.
The user and role part of these labels should be based on the user
related to $UID and not based on the process context of
systemd-user-runtime-dir.

Since v246-rc1 (9664be199a) /run/user/$UID/systemd is also created by
systemd-user-runtime-dir and should also be created with the default
SELinux context.
2020-07-10 21:55:13 +02:00
Christian Göttsche 7a3e4dc38b basic: add helper function mknod_label() 2020-07-10 21:55:13 +02:00
Zbigniew Jędrzejewski-Szmek 5700780389 basic/cap-list: reduce scope of variables 2020-07-10 16:55:24 +02:00
Zbigniew Jędrzejewski-Szmek 864a25d99b basic/capability-util: let cap_last_cap() return unsigned integer
We never return anything higher than 63, so using "long unsigned"
as the type only confused the reader. (We can still use "long unsigned"
and safe_atolu() to parse the kernel file.)
2020-07-10 16:55:24 +02:00
Zbigniew Jędrzejewski-Szmek 417770f303 basic/cap-list: parse/print numerical capabilities
We would refuse to print capabilities which were didn't have a name
for. The kernel adds new capabilities from time to time, most recently
cap_bpf. 'systmectl show -p CapabilityBoundingSet ...' would fail with
"Failed to parse bus message: Invalid argument" because
capability_set_to_string_alloc() would fail with -EINVAL. So let's
print such capabilities in hexadecimal:

CapabilityBoundingSet=cap_chown cap_dac_override cap_dac_read_search
  cap_fowner cap_fsetid cap_kill cap_setgid cap_setuid cap_setpcap
  cap_linux_immutable cap_net_bind_service cap_net_broadcast cap_net_admin
  cap_net_raw cap_ipc_lock cap_ipc_owner 0x10 0x11 0x12 0x13 0x14 0x15 0x16
  0x17 0x18 0x19 0x1a ...

For symmetry, also allow capabilities that we don't know to be specified.

Fixes https://bugzilla.redhat.com/show_bug.cgi?id=1853736.
2020-07-10 16:55:24 +02:00
fangxiuning 76fb53c94a install: fix wrong data type 2020-07-10 10:05:39 +02:00
Zbigniew Jędrzejewski-Szmek a127c6208f userdb: fix dlopen call
The call would always fail with:
systemd-userwork[780]: Failed to dlopen(libnss_systemd.so.2), ignoring: /usr/lib64libnss_systemd.so.2: cannot open shared object file: No such file or directory
2020-07-09 07:55:56 +02:00
Zbigniew Jędrzejewski-Szmek 55aacd502b
Merge pull request #15891 from bluca/host_os_release
Container Interface: expose the host's os-release metadata to nspawn and portable guests
2020-07-08 23:52:13 +02:00
Zbigniew Jędrzejewski-Szmek 48c190822b Merge pull request #16405 from sipraga/master 2020-07-08 22:32:04 +02:00
Zbigniew Jędrzejewski-Szmek 02b0109af5
Merge pull request #15955 from anitazha/nullorempty
core: check null_or_empty_path for masked units instead of /dev/null
2020-07-08 22:18:17 +02:00
Alvin Šipraga 0d0de133f0 network: add support for MACVLAN source mode
Add support for creating a MACVLAN interface in "source" mode by
specifying Mode=source in the [MACVLAN] section of a .netdev file.

A list of allowed MAC addresses for the corresponding MACVLAN can also
be specified with the SourceMACAddress= option of the [MACVLAN] section.

An example .netdev file:

    [NetDev]
    Name=macvlan0
    Kind=macvlan
    MACAddress=02:DE:AD:BE:EF:00

    [MACVLAN]
    Mode=source
    SourceMACAddress=02:AB:AB:AB:AB:01 02:CD:CD:CD:CD:01
    SourceMACAddress=02:EF:EF:EF:EF:01

The same keys can also be specified in [MACVTAP] for MACVTAP kinds of
interfaces, with the same semantics.
2020-07-08 18:01:52 +02:00
Zbigniew Jędrzejewski-Szmek cbc056c819 core: wrap some long lines and other formatting changes 2020-07-08 16:37:23 +02:00
Lennart Poettering 24e2494407
Merge pull request #16385 from JackFangXN/master
table add table_log_xx_error()
2020-07-08 12:12:29 +02:00
Yu Watanabe 43b24a0716 sd-device: use log_device_debug_errno() 2020-07-08 12:11:19 +02:00
fangxiuning 4b6607d949 table use table_log_print_error() instead of table_log_show_error 2020-07-08 15:16:52 +08:00
fangxiuning df83eb546b table add table_log_sort_error() 2020-07-08 10:53:57 +08:00
fangxiuning d836018a73 table add table_log_show_error() 2020-07-08 10:50:59 +08:00
Yu Watanabe c253a95bca
Merge pull request #16379 from yuwata/network-dhcp6-delegated-prefix-address-handler
network: fix assertion in assigning dhcp6 delegated prefix
2020-07-08 10:22:08 +09:00
Zbigniew Jędrzejewski-Szmek 2e2f6a01a0
Merge pull request #16143 from fbuihuu/fstab-generator-fix
fstab-generator: make sure explicit deps configured via mount options apply to .mount, not .automount unit
2020-07-07 20:06:18 +02:00
Alan Perry 5dc60faae5 add error message when bind mount src missing 2020-07-07 20:04:19 +02:00
Yu Watanabe 3650173fec network: make address_handler() static 2020-07-07 19:48:38 +02:00
Yu Watanabe a211ff4b84 network: introduce own address handler for dhcp6 delegated prefix
Fixes #16365.
2020-07-07 19:48:26 +02:00
Zbigniew Jędrzejewski-Szmek 2b0bf3ccf8
Merge pull request #16301 from poettering/firstboot-image
Add --image= switch to firstboot, similar to --root= but with support for operating on disk image
2020-07-07 19:44:12 +02:00
Zbigniew Jędrzejewski-Szmek 9870cfdf7f
Merge pull request #16388 from keszybz/xdg-desktop-fuzz-case
xdg-desktop fuzz case
2020-07-07 19:41:31 +02:00
Zbigniew Jędrzejewski-Szmek dea7f5cc87 xdg-autostart: ignore all empty entries in multi-string entries
The desktop file specification allows entries like ";;;;;;", full of empty strings.
But looking at the actual list of supported keys [1], empty entries are meaningless
(unless we would allow e.g. the desktop name to be the empty string. But that doesn't
seem very useful either). So let's just simplify our life and skip any empty substrings
entirely.

This would also resolve the fuzzer case:
$ valgrind build/fuzz-xdg-desktop test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812
test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812... ok
==2899241== HEAP SUMMARY:
==2899241==     in use at exit: 0 bytes in 0 blocks
==2899241==   total heap usage: 484,385 allocs, 484,385 frees, 12,411,330 bytes allocated
↓
==2899650== HEAP SUMMARY:
==2899650==     in use at exit: 0 bytes in 0 blocks
==2899650==   total heap usage: 1,325 allocs, 1,325 frees, 1,463,602 bytes allocated
2020-07-07 14:02:16 +02:00
Zbigniew Jędrzejewski-Szmek d1ca1f7c2a xdg-autostart: avoid quadratic behaviour in strv parsing
The fuzzer test case has a giant line with ";;;;;;;;;;;..." which is turned into
a strv of empty strings. Unfortunately, when pushing each string, strv_push() needs
to walk the whole array, which leads to quadratic behaviour. So let's use
greedy_allocation here and also keep location in the string to avoid iterating.

build/fuzz-xdg-desktop test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812  51.10s user 0.01s system 99% cpu 51.295 total
↓
build/fuzz-xdg-desktop test/fuzz/fuzz-xdg-desktop/oss-fuzz-22812  0.07s user 0.01s system 96% cpu 0.083 total

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

Other minor changes:
- say "was already defined" instead of "defined multiple times" to make it
  clear that we're ignoring this second definition, and not all definitions
  of the key
- unescaping needs to be done also for the last entry
2020-07-07 12:20:43 +02:00
Zbigniew Jędrzejewski-Szmek a53f024d71 journald: minor wording tweak in message
For a user "from the kernel" might be rather unclear.
2020-07-07 12:14:41 +02:00
Zbigniew Jędrzejewski-Szmek cd990847b9 tree-wide: more repeated words 2020-07-07 12:08:22 +02:00
Zbigniew Jędrzejewski-Szmek 0da425df65 networkd: use capitalized "IP" and "TOS" in messages 2020-07-07 12:06:26 +02:00
Zbigniew Jędrzejewski-Szmek 8ab0f03266 journal/compress: drop "future" code in zstd compression
We generally don't include stuff that is not used. This can be
easily ressurected if ever needed.

Fixes CID#1430210.
2020-07-07 12:06:26 +02:00
Yuri Chornoivan d7b34e3841 all: fix minor typos
[thaller@redhat.com: original patch by Yuri, extracted from [1]]

[1] https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/merge_requests/565
2020-07-07 18:52:49 +09:00
Lennart Poettering a122502077 firstboot: add option to turn off welcome text display 2020-07-07 11:20:42 +02:00
Lennart Poettering 3ff9fa591e firstboot: add --image= switch
This is like --root=, but takes an image file path or device node path
and dissects the image directly, mounting it internally.
2020-07-07 11:20:42 +02:00
Lennart Poettering 827ea52125 mount-util: use UMOUNT_NOFOLLOW in recursive umounter
When we only want to unmount mount points below some path then it is
against our interest to follow symlinks. Hence don't.
2020-07-07 11:20:42 +02:00
Lennart Poettering e49ee28522 mount-util: add destructor helper that umounts + rmdirs a path 2020-07-07 11:20:42 +02:00
Lennart Poettering e2ec9c4d3a namespace-util: introduce helper for combining unshare() + MS_SLAVE remount
We have multiple places we do these two non-trivial operations together,
let's introduce a unified helper for doing both at once.
2020-07-07 11:20:42 +02:00
Luca Boccassi cda667722c core: refresh unit cache when building a transaction if UNIT_NOT_FOUND
When a command asks to load a unit directly and it is in state
UNIT_NOT_FOUND, and the cache is outdated, we refresh it and
attempto to load again.
Use the same logic when building up a transaction and a dependency in
UNIT_NOT_FOUND state is encountered.
Update the unit test to exercise this code path.
2020-07-07 10:09:24 +02:00
Zbigniew Jędrzejewski-Szmek 3f2e15abc5 sleep: one spelling unification
We use "writable" everywhere else.
2020-07-07 10:02:02 +02:00
Zbigniew Jędrzejewski-Szmek 77ecc1aaa5
Merge pull request #16380 from yuwata/network-dhcp6-update-prefix-route
Network: update acquired dhcp6 prefix routes
2020-07-07 09:05:08 +02:00
Zbigniew Jędrzejewski-Szmek 9389a271b7
Merge pull request #16381 from yuwata/dhcp4-renewing
dhcp4: fixes around renewing address
2020-07-07 08:59:35 +02:00
Zbigniew Jędrzejewski-Szmek a240147bdc
Merge pull request #16383 from yuwata/network-dhcp6-radv-update-prefix
network: do not restart radv engine when adding prefix
2020-07-07 08:53:31 +02:00
Yu Watanabe 58e6c62191 network: fix memleak
If init() is failed, the allocated memory was leaked.
2020-07-07 08:23:17 +02:00
Yu Watanabe 1d596fdec2 network: do not restart radv engine when adding prefix
Replaces d469cea3bd.
2020-07-07 11:20:35 +09:00
Yu Watanabe 8fc2a5dff4 network: fix indentation 2020-07-07 11:18:28 +09:00
Yu Watanabe 290696e512 Revert "network: Don't send RA with zero router lifetime when restarting radv"
This reverts commit d469cea3bd.
2020-07-07 11:06:08 +09:00
Michael Marley d469cea3bd network: Don't send RA with zero router lifetime when restarting radv
While investigating https://github.com/systemd/systemd/issues/16356, I
discovered that networkd stops the radv service before adding or updating
prefixes and then starts it again.  This causes networkd to send an RA with
a router lifetime of zero, causing the routes to flap on systems receiving
the RA for a fraction of a second before radv is started again and proper
RAs are sent.  That has the potential to cause issues with latency-sensitive
traffic like gaming or VoIP.  This patch adds a boolean argument to the
sd_radv_stop() function to control this behavior.  The zero lifetime RA is
still sent whenever radv is actually being stopped, but when it is being
restarted for a prefix update (from networkd-dhcp6.c), the final RA is no
longer sent to avoid the route flapping.
2020-07-07 10:49:25 +09:00
Yu Watanabe 921693a0f3 dhcp4: do not try to renew address when client has no lease 2020-07-07 10:18:58 +09:00
Yu Watanabe ceaec54a3c dhcp4: do not renew address if client is not running yet 2020-07-07 10:18:22 +09:00
Yu Watanabe f050c94df0 network: always update acquired prefix route
Otherwise, routes become lifetime 0.

Fixes #16356.
2020-07-07 09:20:44 +09:00
Yu Watanabe 1419ff0401 network: decrease indentation level 2020-07-07 09:14:21 +09:00
Yu Watanabe cecd68c70f network: fix indentation 2020-07-07 08:47:38 +09:00
Yu Watanabe c82012605b
Merge pull request #16374 from keszybz/docs-and-networkd
Docs and networkd
2020-07-07 08:29:56 +09:00
Susant Sahani 98ebef62c7 DHCPv4: client add support for DHCP server allow list 2020-07-06 22:28:54 +02:00
Lennart Poettering b3077c47a8
Merge pull request #16344 from keszybz/update-utmp-erofs
Make update-utmp not fail if it only fails to write wtmp records
2020-07-06 17:52:17 +02:00
Zbigniew Jędrzejewski-Szmek 5544cd3199
Merge pull request #16373 from JackFangXN/master
userdbctl homectl use table_log_add_error()
2020-07-06 17:14:07 +02:00
Frantisek Sumsal 9a61e8fca2 unit-name: fix a potential memory leak
Also, add a test which verifies the issue is indeed gone.

Fixes: CID#1429014
Followup to: ab19db01ae
2020-07-06 17:13:37 +02:00
Zbigniew Jędrzejewski-Szmek 1f68f77292 networkd: we should not loop when extract_first_word() fails
While at it, define iterator in the loop to reduce the indentation a bit.
2020-07-06 16:32:34 +02:00
Zbigniew Jędrzejewski-Szmek b37e4d9c87
Merge pull request #16370 from keszybz/tree-wide-spelling
Assorted spelling, markup, and grammar fixes
2020-07-06 15:57:47 +02:00
Vito Caputo e26538dd04 network: tc: fix n_prio bounds check
Looks like a simple copy and paste error

Fixes https://github.com/systemd/systemd/issues/16367
2020-07-06 15:52:17 +02:00
fangxiuning f987a261b4 userdbctl homectl use table_log_add_error()
Signed-off-by: fangxiuning <fangxiuning123@126.com>
2020-07-06 21:32:22 +08:00
Zbigniew Jędrzejewski-Szmek f04a98e13f Fix two typos found by codespell 2020-07-06 15:09:23 +02:00
Zbigniew Jędrzejewski-Szmek e9dd698407 tree-wide: fixes for assorted grammar and spelling issues
Fixes #16363. Also includes some changes where I generalized the pattern.
2020-07-06 11:29:05 +02:00
Yu Watanabe c5fbdebec6
Merge pull request #16287 from yuwata/udevadm-info-attribute-walk
udevadm: make --attribute-walk show subdir attributes
2020-07-06 14:47:51 +09:00
Zbigniew Jędrzejewski-Szmek 4276749dd3 shared/install: do not require /dev/null to be present in chroots
This partially undoes the parent commit. We follow the symlink and
if it appears to be a symlink to /dev/null, even if /dev/null is not
present, we treat it as such. The addition of creation of /dev/null
in the test is reverted.
2020-07-05 20:06:22 +02:00
Zbigniew Jędrzejewski-Szmek ca1d199b48 update-utmp: do not fail on EROFS
Right now systemd-update-utmp.service would fail on read-only /var because
it was not able to write the wtmp record. But it still writes the utmp
record just fine, so runtime information is OK. I don't think we need to
make too much fuss about not being able to save wtmp info.
2020-07-05 12:44:35 +02:00
Zbigniew Jędrzejewski-Szmek c2a9909377 Define _cleanup_ helper for setutxent()+endutxent() 2020-07-05 12:16:01 +02:00
Zbigniew Jędrzejewski-Szmek 21c7fe6d12 sd-device: be more defensive in FOREACH_DEVICE_SYSATTR
Follow-up for fadcc12229.
2020-07-05 10:55:18 +02:00
Dan Callaghan 2fadbb4535 core: set private section name for automount units
Because this was left unset, the unit_write_setting() function was
refusing to write out the automount-specific TimeoutIdleSec= and
DirectoryMode= settings when creating transient automount units.
Set it to the proper value in line with other unit types.
2020-07-04 18:48:36 +02:00
Zbigniew Jędrzejewski-Szmek 071be2fa9f
Merge pull request #15442 from poettering/fido2
add fido2 authentication support to homed
2020-07-03 17:27:15 +02:00
Yu Watanabe 21df146501 udevadm: sort entries in `udevadm info -a` by attribute name 2020-07-03 22:21:44 +09:00
Yu Watanabe fadcc12229 sd-device: make FOREACH_DEVICE_SYSATTR() list attributes in subdirectories
Then, `udevadm info -a` can show subdir attributes.

Closes #12191.
2020-07-03 22:21:44 +09:00
gzjsgdsb 33d943d168 initialize arg_clock_usec 2020-07-03 14:52:20 +02:00
Anita Zhang 640f3b143d core: check null_or_empty for masked units instead of /dev/null
There's some inconsistency in the what is considered a masked unit:
some places (i.e. load-fragment.c) use `null_or_empty()` while others
check if the file path is symlinked to "/dev/null". Since the latter
doesn't account for things like non-absolute symlinks to "/dev/null",
this commit switches the check for "/dev/null" to use `null_or_empty_path()`
2020-07-03 02:33:50 -07:00
Zbigniew Jędrzejewski-Szmek 272ac70a21 various daemons: emit Stopping... notification before destructing the manager object
This is mostly cosmetic, but let's reorder the destructors so that
we do the final sd_notify() call before we run the destructor for
the manager object.
2020-07-02 17:12:23 +02:00
Zbigniew Jędrzejewski-Szmek cc090ca7fe initctl: use _cleanup_ and run() 2020-07-02 17:12:23 +02:00
Zbigniew Jędrzejewski-Szmek e9d9d50cef initctl,update-utmp: define iterator variable in loop 2020-07-02 17:12:23 +02:00
Zbigniew Jędrzejewski-Szmek bc9d1dbfc8 update-utmp,initctl: drop ppid check
Such checks make debugging harder but serve no useful purpose otherwise.
We got rid of all the checks for root, let's kill those too.
2020-07-02 17:12:23 +02:00
Yu Watanabe c03ef420fa network: tc: rename several settings which take size in bytes 2020-07-02 16:51:11 +02:00
Zbigniew Jędrzejewski-Szmek cc832f9772
Merge pull request #16338 from keszybz/spelling2
Tree-wide spelling fixes
2020-07-02 15:10:27 +02:00
Zbigniew Jędrzejewski-Szmek 63b7e7b4ba
Merge pull request #16336 from yuwata/ifindex-cleanups
tiny cleanups related to ifindex
2020-07-02 15:08:41 +02:00
Yu Watanabe 1447dc625a
Merge pull request #16219 from ssahani/network-sr-iov
network: Introduce SR-IOV
2020-07-02 20:24:13 +09:00
Zbigniew Jędrzejewski-Szmek 52e085af82 tree-wide: "unparseable" → "unparsable"
"unparsable" is the more common spelling. We already pick "movable" over
"moveable". Let's do the same with this pair.
2020-07-02 09:58:23 +02:00
Yu Watanabe 13adf35343 resolve: use appropriate type 2020-07-02 16:58:06 +09:00
Yu Watanabe 5e958e1d6c util: use setsockopt_int() at one more place 2020-07-02 16:58:06 +09:00
Yu Watanabe 1a6c913676 libsystemd-network: rename index -> ifindex 2020-07-02 16:58:06 +09:00
Yu Watanabe 7fa69c0a6f dhcp6, radv: only accept valid ifindex 2020-07-02 16:58:06 +09:00
Zbigniew Jędrzejewski-Szmek 15e6a6e87b tree-wide: spell "lifecycle" without hyphen everywhere
We had 2 more instances of unhyphentated spelling.
2020-07-02 09:55:44 +02:00
Zbigniew Jędrzejewski-Szmek 37b22b3b47 tree: wide "the the" and other trivial grammar fixes 2020-07-02 09:51:38 +02:00
Susant Sahani 838d39af93 network: Allow DHCPv6 client to start solicit mode
Now DHCPv6 client start only DHCPv6 INFORMATION-REQUEST mode.
Let's enable Solicit mode too.
2020-07-02 16:18:48 +09:00
Franck Bui 6371e69b49 fstab-generator: introduce an helper to write extra dependencies specified via the mount options
No functional change.
2020-07-01 16:35:13 +02:00
Franck Bui 045c5faf5a fstab-generator: extra dependencies specified in fstab should be applied to the mount unit
If an entry in fstab uses "x-systemd.automount" option and also asks for
additionnal dependencies via x-systemd.requires or such, then the dependencies
were applied to the automount unit.

But this unlikely to do the right thing and is inconsistent with what's done
for network mounts.

Indeed when an fstab entries has "_netdev,x-systemd.automount" options, the
dependencies against the network requested by "_netdev" are (correctly) applied
to the mount unit only and the automount unit remains ordered against
local-fs.target.

The same logic should be followed when extra deps are specified via the mount
options as automount units should always be ordered against local-fs.target.

Note: in general explicit deps specified via mount options should be used with
care and should be used to specify dependencies on other mount units only as it
can easily create ordering cycles otherwise like it's been seen in
https://github.com/systemd/systemd-stable/issues/69. Mount units (as well as
automount ones) are ordered before local-fs.target by default which is a
low-level target that most other units depend on.
2020-07-01 16:34:42 +02:00
Lennart Poettering 0eb3be4644 homectl: add --pkcs11-uri=auto and --pkcs-11-uri=list support
We have the same for FIDO2 devices, for listing suitable devices, or
picking the right one automatically, let's add that for PKCS11 too.
2020-07-01 11:20:26 +02:00
Lennart Poettering 2af3966af3 homectl: add acquired fido2 PIN to user record
If we successfully acquired the PIN for the fido2 key, let's add it to
our user record, so that we can pass it to homed, which will need it
too.
2020-07-01 11:20:26 +02:00
Lennart Poettering 93295a2501 homectl: split out pkcs#11 related code bits into own .c/.h file
There's some highly specific PKCS#11 code in homectl.c. Let's split that
out, since it is easily isolatable, to make homectl.c a bit more
readable.

No funcional changes, just some moving around and renaming two functions
to make them more suitably named when exported.
2020-07-01 11:20:25 +02:00
Lennart Poettering c98811d837 homectl: rework how we log when doing a home directory update
When updating a home directory we might update the record first, then
resize the image and finally synchronize the passwords to the storage
layers. These are three individually authenticated operations. Since
each might require touching a FIDO2 or PKCS#11 key we should say what we
are doing. Hence do so.

Usually we are pretty quiet with what we do, and let's stick to that.
Hence show this information only if we actually do more than one thing.
If we only update (and do not resize/sync passwords) then let's be quiet
as usual, as the command line then sufficiently clarifies what we are
doing.
2020-07-01 11:17:28 +02:00
Lennart Poettering 8e62dfb12a homectl: do generic error handling/retry also when creating a home directory
After all, when creating we might need interaction with the security
token too, and our initial attempt to create the user will fail, since
we do not allow interactive auth on the security token, so that we then
can print a log message and retry with interactive auth then enabled.
2020-07-01 11:17:28 +02:00
Lennart Poettering f737186ab1 homectl: show touch emoji when asking for PKCS#11 protected auth path 2020-07-01 11:17:28 +02:00
Lennart Poettering 85b1294488 pam-systemd-home: print helpful message when token's PIN is locked 2020-07-01 11:17:28 +02:00
Lennart Poettering 7b78db28e5 homed: add support for authenticating with fido2 hmac-secret tokens 2020-07-01 11:17:28 +02:00
Lennart Poettering 1c0c4a43c6 homectl: add support for enrolling FIDO2 HMAC-SECRET tokens 2020-07-01 11:17:28 +02:00
Lennart Poettering 5e4fa456fa user-record: add fields for FIDO2 HMAC authentication options 2020-07-01 11:17:28 +02:00
Lennart Poettering c0bde0d240 user-record: rename JSON field "pkcs11Pin" to "tokenPin"
We'd like to use it for FIDO2 tokens too, and the concept is entirely
generic, hence let's just reuse the field, but rename it. Read the old
name for compatibility, and treat the old name and the new name as
identical for most purposes.
2020-07-01 11:17:28 +02:00
Lennart Poettering d00f318323 user-record: securely erase pkcs#11 when assigned NULL too 2020-07-01 11:17:28 +02:00
Lennart Poettering 7b8d55b72c homectl: add missing log messages when json_variant_format() fails 2020-07-01 11:17:28 +02:00
Lennart Poettering c63ec11bf5 pkcs11-util: reduce scope of a variable 2020-07-01 11:17:28 +02:00
Lennart Poettering 1146b664e6 macro: add new FOREACH_POINTER() macro magic
This allows us to iterate through a series of specified pointers. It's a
bit like FOREACH_STRING(), but for all kinds of pointers.
2020-07-01 11:17:28 +02:00
Lennart Poettering 428d32afea locale-util: add support for touch emoji
We can use this to highlight when users are supposed to touch their
security tokens.
2020-07-01 11:17:27 +02:00
Yu Watanabe 9457b6bb21
Merge pull request #16303 from poettering/dbus-util-split
shared: split src/shared/bus-util.c into multiple files
2020-07-01 14:15:40 +09:00
Yu Watanabe c3a5025dc6 network: add MACAddress= setting in [SR-IOV] section 2020-07-01 13:51:35 +09:00
Yu Watanabe e64b31c848 network: add VLANProtocol= setting in [SR-IOV] section 2020-07-01 13:51:35 +09:00
Susant Sahani 518cd6b527 network: Introduce SR-IOV
SR-IOV provides the ability to partition a single physical PCI
resource into virtual PCI functions which can then be injected in
to a VM. In the case of network VFs, SR-IOV improves north-south n
etwork performance (that is, traffic with endpoints outside the
host machine) by allowing traffic to bypass the host machine’s network stack.
2020-07-01 13:51:33 +09:00
Susant Sahani 5908ddd763 sd-netlink: Add SR-IOV netlink properties 2020-07-01 13:50:49 +09:00
Marc Kleine-Budde b46d8c1c70 udev: spi: include chip select number in ID_PATH
All devices behind a SPI controller have the same udev ID_PATH property.
This is a problem for predicable network names for CAN controllers.

CAN controllers, in contrast to Ethernet controllers, don't have a MAC
Address, so there's no way to tell two CAN controllers on the same SPI
host controller apart:

$ udevadm info /sys/class/net/can0
P: /devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.1/net/can0
L: 0
E: DEVPATH=/devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.1/net/can0
E: INTERFACE=can0
E: IFINDEX=3
E: SUBSYSTEM=net
E: USEC_INITIALIZED=11187199
E: ID_PATH=platform-fe204000.spi
E: ID_PATH_TAG=platform-fe204000_spi
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/can0
E: TAGS=:systemd:

$ udevadm info /sys/class/net/can1
P: /devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.0/net/can1
L: 0
E: DEVPATH=/devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.0/net/can1
E: INTERFACE=can1
E: IFINDEX=4
E: SUBSYSTEM=net
E: USEC_INITIALIZED=11192211
E: ID_PATH=platform-fe204000.spi
E: ID_PATH_TAG=platform-fe204000_spi
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/can1
E: TAGS=:systemd:

With this the chip select number is added to the ID_PATH, to make
predictable network names possible.

$ sudo udevadm info /sys/class/net/can0
P: /devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.1/net/can0
L: 0
E: DEVPATH=/devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.1/net/can0
E: INTERFACE=can0
E: IFINDEX=3
E: SUBSYSTEM=net
E: USEC_INITIALIZED=11187199
E: ID_PATH=platform-fe204000.spi-cs-1
E: ID_PATH_TAG=platform-fe204000_spi-cs-1
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/can0
E: TAGS=:systemd:

$ sudo udevadm info /sys/class/net/can1
P: /devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.0/net/can1
L: 0
E: DEVPATH=/devices/platform/soc/fe204000.spi/spi_master/spi0/spi0.0/net/can1
E: INTERFACE=can1
E: IFINDEX=4
E: SUBSYSTEM=net
E: USEC_INITIALIZED=11192211
E: ID_PATH=platform-fe204000.spi-cs-0
E: ID_PATH_TAG=platform-fe204000_spi-cs-0
E: SYSTEMD_ALIAS=/sys/subsystem/net/devices/can1
E: TAGS=:systemd:
2020-07-01 13:12:11 +09:00
Zbigniew Jędrzejewski-Szmek d17eabb105 Fix build with µhttpd 0.9.71
The return type of callbacks was changed from int to an enum.
2020-07-01 13:10:48 +09:00
Yu Watanabe 116739cfb6
Merge pull request #16316 from yuwata/backlight-use-actual-brightness
backlight: use actual_brightness attribute to get current backlight level
2020-07-01 13:10:15 +09:00
Zbigniew Jędrzejewski-Szmek 6c3a19d5b3
Merge pull request #16313 from yuwata/network-move-ipv6ll-gen-mode
network: move IPv6LinkLocalAddressGenerationMode= to [Network] section
2020-06-30 17:13:02 +02:00
Luca Boccassi 7233e91af0 core: store timestamps of unit load attempts
When the system is under heavy load, it can happen that the unit cache
is refreshed for an unrelated reason (in the test I simulate this by
attempting to start a non-existing unit). The new unit is found and
accounted for in the cache, but it's ignored since we are loading
something else.
When we actually look for it, by attempting to start it, the cache is
up to date so no refresh happens, and starting fails although we have
it loaded in the cache.

When the unit state is set to UNIT_NOT_FOUND, mark the timestamp in
u->fragment_loadtime. Then when attempting to load again we can check
both if the cache itself needs a refresh, OR if it was refreshed AFTER
the last failed attempt that resulted in the state being
UNIT_NOT_FOUND.

Update the test so that this issue reproduces more often.
2020-06-30 16:50:00 +02:00
Zbigniew Jędrzejewski-Szmek f93dd4b940
Merge pull request #16282 from poettering/repart-copy-blocks
repart: add new CopyBlocks= setting
2020-06-30 15:26:06 +02:00
Yu Watanabe 437b9a7f75 backlight: read current backlight brightness from 'actual_brightness' attribute
Closes #16302.
2020-06-30 22:19:21 +09:00
Yu Watanabe daa227a320 backlight: call log_setup_service() before logging 2020-06-30 22:19:21 +09:00
Yu Watanabe 74f1bb5c9f backlight: use SYNTHETIC_ERRNO() macro 2020-06-30 22:19:21 +09:00
Lennart Poettering 40af3d020f shared: split out property get helpers
No code changes, just some refactoring.
2020-06-30 15:10:17 +02:00
Lennart Poettering 9176326ba2 shared: split out code for printing properties
No code changes, just some refactoring.
2020-06-30 15:09:56 +02:00