Commit Graph

30914 Commits

Author SHA1 Message Date
Yu Watanabe fc9e3b8129 udevadm: also support alias .device units to specify devices
Previously, .device units generated by SYSTEMD_ALIAS= udev properties
are not supported to specify devices for e.g. 'udevadm info'.

Before:
```
$ udevadm info sys-subsystem-net-devices-enp0s31f6.device
Unknown device "sys-subsystem-net-devices-enp0s31f6.device": No such device
```

After:
```
$ ./udevadm info sys-subsystem-net-devices-enp0s31f6.device
P: /devices/pci0000:00/0000:00:1f.6/net/enp0s31f6
L: 0
E: DEVPATH=/devices/pci0000:00/0000:00:1f.6/net/enp0s31f6
E: INTERFACE=enp0s31f6
E: IFINDEX=2
E: SUBSYSTEM=net
E: USEC_INITIALIZED=25317523
E: ID_NET_NAMING_SCHEME=v245
(snip)
```
2020-10-20 10:09:01 +02:00
Lennart Poettering 67bd5620f6 util: make size macros unsigned
By making them unsigned comparing them with other sizes is less likely
to trigger compiler warnings regarding signed/unsigned comparisons.
After all sizes (i.e. size_t) are generally assumed to be unsigned, so
these should be too.

Prompted-by: https://github.com/systemd/systemd/pull/17345#issuecomment-709402332
2020-10-20 15:51:48 +09:00
Yu Watanabe 0ce8a9d6e5
Merge pull request #16939 from Rahix/robust-first-boot-machine-id
Make ConditionFirstBoot safe against power failures
2020-10-20 14:01:41 +09:00
Yu Watanabe 1586d324bd
Merge pull request #17352 from msekletar/ens-names-fix
udev/net_id: don't generate slot based names if multiple devices might claim the same slot
2020-10-20 13:49:29 +09:00
Felix Riemann 1eee15c388 update-done: Do not fail with read-only /etc or /var
With the switch from log_debug() to log_debug_errno() in commit c413bb28df
systemd-update-done would fail without any error message if /etc
or /var were read-only. This restores the previous behaviour to
silently ignore these directories again.
2020-10-20 13:46:36 +09:00
Yu Watanabe 4b28e50f9e
Merge pull request #17390 from keszybz/logind-notifications-and-links
Fix sd_notify() usage in various daemons and update some documentation links
2020-10-20 13:44:52 +09:00
Michal Sekletár 2c8ec0095e udev/net_id: don't generate slot based names if multiple devices might claim the same slot 2020-10-19 17:55:44 +02:00
Lennart Poettering 43e7dd70bc
Merge pull request #17344 from keszybz/bus-connect-more-logs
Add some debug logs to help diagnose bus connections
2020-10-19 17:39:37 +02:00
Lennart Poettering 115fae8a07
Merge pull request #17387 from anitazha/systoomd_fixups
oomd fixups
2020-10-19 17:29:22 +02:00
Harald Seiler c261a5d014 machine-id-setup: sync before committing machine-id
sync() before committing a transient machine-id to disk.  This will
ensure that any filesystem changes made by first-boot units will have
been persisted before the first boot is marked as completed.
2020-10-19 16:28:22 +02:00
Harald Seiler 3023f2fead core: keep machine-id transient until first boot completes
Currently, a loss of power after the machine-id was written but before
all units with ConditionFirstBoot=yes ran would lead to the next boot
finding a valid machine-id, thus not being marked first boot and not
re-running these units.

To make the first boot mechanism more robust, instead of writing
/etc/machine-id very early, fill it with a marker value "uninitialized"
and overmount it with a transiently provisioned machine-id.  Then, after
the first boots completes (when systemd-machine-id-commit.service runs),
write the real machine-id to disk.

This mechanism is of course only invoked on first boot.  If a first boot
is not detected, the machine-id is handled as previously.

Fixes: #4511
2020-10-19 16:28:22 +02:00
Harald Seiler ab763cb2be dissect-image: support "uninitialized" machine-id
If the first boot was aborted, /etc/machine-id might read as
"uninitialized" in some cases.  Add a separate case for this
instead of printing a confusing error message.
2020-10-19 16:28:22 +02:00
Harald Seiler 448b782cb2 repart: correctly handle "uninitialized" machine-id
When systemd-repart runs from initramfs, it reads out /etc/machine-id
from the rootfs as a seed for partition UUIDs.  However, the machine-id
could be in an "uninitialized" state from a previous failed first boot.
In this situation the -ENOMEDIUM code-path (no machine-id set) should be
taken.
2020-10-19 16:28:21 +02:00
Harald Seiler c5fbeedb0c nspawn: robustly deal with "uninitialized" machine-id
When nspawn starts an image, this image could be in any state, including
an aborted first boot.  For this case, it needs to correctly handle the
situation like there was no machine-id at all.
2020-10-19 16:28:21 +02:00
Harald Seiler 8085114828 id128: add format which treats "uninitialized" like an empty id
Add a new ID128_PLAIN_OR_UNINIT format which treats the string
"uninitialized" like the file was empty and return -ENOMEDIUM.  This
format should be used when reading an /etc/machine-id file from an image
that is not currently running.
2020-10-19 16:28:21 +02:00
Zbigniew Jędrzejewski-Szmek 6c75e31703 logind: minor indentation adjustments 2020-10-19 15:23:37 +02:00
Zbigniew Jędrzejewski-Szmek 21fe744cfb logind: use notify_start/notify_on_cleanup
Logging about the pid is dropped, pid1 does that better.
2020-10-19 15:23:37 +02:00
Zbigniew Jędrzejewski-Szmek 297fc20dc4 shared/daemon-util: fix notify_on_cleanup()
p itself is never null. Because of this, we would always
call sd_notify() in cleanup, even though the intention was to only
call it if notify_start() was executed.
2020-10-19 15:23:37 +02:00
Lennart Poettering 6008336ffa tmpfiles: no need to specify a synthetic error code if we don't propagate it 2020-10-19 14:22:25 +02:00
Lennart Poettering dfc22cb472 bootspec: tweak error message
Clarify that the name of the entry failed validation, not the entry
itself.
2020-10-19 14:22:25 +02:00
Harald Seiler 583cef3b73 core: treat "uninitialized" in /etc/machine-id as first boot as well
When /etc/machine-id contains the string "uninitialized" instead of
a valid machine-id, treat this like the file was missing and mark this
boot as the first (-> units with ConditionFirstBoot=yes will run).
2020-10-19 12:33:39 +02:00
Michal Sekletár 3e545ae5ab udev/net_id: parse _SUN ACPI index as a signed integer
Negative value means there is no match between a PCI device and any of
the slots. In the following commit we will extend this and value of 0
will indicate that there is a match between some slot and PCI device,
but that device is a PCI bridge.
2020-10-19 12:18:03 +02:00
Anita Zhang 349a2003fd oomd: simplify if/else error check 2020-10-19 02:46:07 -07:00
Anita Zhang f561e8c659 core: move where we send unit change updates to oomd
Post-merge suggestion from #15206
2020-10-19 02:46:07 -07:00
Anita Zhang 620ed14e44 core: reindent and align table in load-fragment-gperf.gperf.m4 2020-10-19 02:46:07 -07:00
Anita Zhang 2801d36e25 core: varlink tweaks
Suggested post-merge in #15206
2020-10-19 02:46:00 -07:00
Anita Zhang 3e9b4f9156 oomd: fix unit test when xattrs not supported 2020-10-16 16:19:15 -07:00
Lennart Poettering d991100291 core: log about "systemctl kill" requests
let's add informational logging about each client requested signal
sending. While we are at, let's beef up error handling/log messages in
this case quite a bit: let's log errors both to syslog and report errors
back to client.

Fixes: #17254
2020-10-16 17:21:51 +02:00
Lennart Poettering 2ae0508e6d core: correct handling of "systemctl kill --kill-who=main-fail"
--kill-who=main-fail never worked correctly, due to a copy and paste
mistake in ac5e3a505e, where the same item
was listed twice. The mistake was
later noticed, but fixed incorrectly, in
201f0c916d.

Let's list all *-fail types correctly, finally.

And while we are at it, add a nice comment and generate a prettier D-Bus
error about this.
2020-10-16 17:19:20 +02:00
Lennart Poettering 8aff7ac4a7 core: add comment explaining unit_kill_context() vs. unit_kill_common() a bit 2020-10-16 17:16:02 +02:00
Michal Koutný 0bc2f071e1 meson: Fix missing libseccomp dependencies
The builds with HAVE_SECCOMP fail on missing include paths:

FAILED: src/basic/libbasic.a.p/parse-util.c.o
cc -Isrc/basic/libbasic.a.p -Isrc/basic -I../src/basic -Isrc/boot -I../src/boot -Isrc/home -I../src/home -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -Isrc/core -I../src/core -Isrc/shutdown -I../src/shutdown -I../src/xdg-autostart-generator -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Werror=shadow -include config.h -fPIC -pthread -fvisibility=default -MD -MQ src/basic/libbasic.a.p/parse-util.c.o -MF src/basic/libbasic.a.p/parse-util.c.o.d -o src/basic/libbasic.a.p/parse-util.c.o -c ../src/basic/parse-util.c
In file included from ../src/basic/parse-util.c:20:
../src/shared/seccomp-util.h:4:10: fatal error: seccomp.h: No such file or directory
    4 | #include <seccomp.h>
      |          ^~~~~~~~~~~
compilation terminated.

FAILED: test-parse-util.p/src_test_test-parse-util.c.o
cc -Itest-parse-util.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/boot -I../src/boot -Isrc/home -I../src/home -Isrc/shared -I../src/shared -Isrc/systemd -I../src/systemd -Isrc/journal -I../src/journal -Isrc/journal-remote -I../src/journal-remote -Isrc/nspawn -I../src/nspawn -Isrc/resolve -I../src/resolve -Isrc/timesync -I../src/timesync -I../src/time-wait-sync -Isrc/login -I../src/login -Isrc/udev -I../src/udev -Isrc/libudev -I../src/libudev -Isrc/core -I../src/core -Isrc/shutdown -I../src/shutdown -I../src/xdg-autostart-generator -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/libsystemd-network -I../src/libsystemd-network -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu99 -g -Wno-unused-parameter -Wno-missing-field-initializers -Wno-unused-result -Wno-format-signedness -Werror=undef -Wlogical-op -Wmissing-include-dirs -Wold-style-definition -Wpointer-arith -Winit-self -Wfloat-equal -Wsuggest-attribute=noreturn -Werror=missing-prototypes -Werror=implicit-function-declaration -Werror=missing-declarations -Werror=return-type -Werror=incompatible-pointer-types -Werror=format=2 -Wstrict-prototypes -Wredundant-decls -Wmissing-noreturn -Wimplicit-fallthrough=5 -Wshadow -Wendif-labels -Wstrict-aliasing=2 -Wwrite-strings -Werror=overflow -Werror=shift-count-overflow -Werror=shift-overflow=2 -Wdate-time -Wnested-externs -Wno-maybe-uninitialized -ffast-math -fno-common -fdiagnostics-show-option -fno-strict-aliasing -fvisibility=hidden -fstack-protector -fstack-protector-strong --param=ssp-buffer-size=4 -Werror=shadow -include config.h -MD -MQ test-parse-util.p/src_test_test-parse-util.c.o -MF test-parse-util.p/src_test_test-parse-util.c.o.d -o test-parse-util.p/src_test_test-parse-util.c.o -c ../src/test/test-parse-util.c
In file included from ../src/test/test-parse-util.c:14:
../src/shared/seccomp-util.h:4:10: fatal error: seccomp.h: No such file or directory
    4 | #include <seccomp.h>
      |          ^~~~~~~~~~~
compilation terminated.

Add the respective deps.

Fixes: 005bfaf118 ("exec: Add kill action to system call filters")
2020-10-16 12:30:24 +09:00
Yu Watanabe dd82626a0d
Merge pull request #17361 from keszybz/oomd-introspection-stub
Implement --version,--bus-introspect in oomd, add man page for the dbus api
2020-10-16 12:24:37 +09:00
Lennart Poettering 6f997852c8 pid1: ignore whole /run/host hierarchy
Let's mark the whole /run/host hierarchy as something to ignore by PID 1
for generation of .mount units, i.e. consider it as "extrinsic".

By unifying container mgr supplied resources in one dir it's also easy
to exclude the whole lot from PID1's management inside the container.
This is the right thing to do, since from the payload's PoV these mounts
are just API and not manipulatable as they are established, managed and
owned by the container manager, not the payload.

(While we are it, also add the boot ID mount to the existing list, as
nspawn and other container managers overmount that too, typically, and
it is thus owned by the container manager and not the payload
typically.)
2020-10-15 17:16:36 +02:00
Zbigniew Jędrzejewski-Szmek c9a00f5a3b oomd: add names to dbus parameters and implement --bus-introspection 2020-10-15 15:03:49 +02:00
Zbigniew Jędrzejewski-Szmek ddc543bed8 oomd: check number of arguments, add --version, fix indentation 2020-10-15 15:03:07 +02:00
Zbigniew Jędrzejewski-Szmek 69c0807432
Merge pull request #15206 from anitazha/systoomd-v0
systemd-oomd
2020-10-15 14:16:52 +02:00
Lennart Poettering edfa55174b systemctl: fix tabs indentations 2020-10-15 10:56:01 +02:00
Lennart Poettering b8f736b30e pager: lets check SYSTEMD_PAGERSECURE with secure_getenv()
I can't think of any real vulnerability about this, but it still feels
better to check a variable with "secure" in its name with
secure_getenv() rather than plain getenv().

Paranoia FTW!
2020-10-15 10:54:53 +02:00
Zbigniew Jędrzejewski-Szmek cc6ceec23e
Merge pull request #17354 from dtardon/udev-cleanup
some udev cleanup
2020-10-15 08:01:01 +02:00
Zbigniew Jędrzejewski-Szmek 93a59b1ae5 sd-bus: break the loop in bus_ensure_running() if the bus is not connecting
This might fix #17025:
> the call trace is
> bus_ensure_running -> sd_bus_process -> bus_process_internal -> process_closeing --> sd_bus_close
>                                                                                  |
>                                                                                  \-> process_match

We ended doing callouts to the Disconnected matches from bus_ensure_running()
and shouldn't. bus_ensure_running() should never do callouts. This change
should fix this however: once we notice that the connection is going down we
will now fail instantly with ENOTOCONN instead of calling any callbacks.
2020-10-15 11:15:03 +09:00
Yu Watanabe 956dbf361b network: warn if dynamic gateway is specified but corresponding protocol is disabled 2020-10-15 07:07:46 +09:00
Yu Watanabe 22d37e5df6 network: introduce network_adjust_dhcp() 2020-10-15 07:06:58 +09:00
Yu Watanabe 3773eb5485 network: introduce network_adjust_ipv6_accept_ra() 2020-10-15 07:06:36 +09:00
Yu Watanabe c27abcf4fb network: when Gateway=_dhcp4, set several properties based on lease if they are not explicitly specified
Before this commit, event when Gateway=_dhcp4 or _ra is set, the
route was configured with 'protocol static', and other properties
specified by RouteTable=, RouteMTU=, or etc, were ignored.

This commit makes set the route protocol based on the protocol the
gateway address is obtained, and apply other settings if it is not
explicitly specified in the [Route] section.
2020-10-15 07:06:23 +09:00
Yu Watanabe 5bb80a4603 network: determine a [Route] section will be used or not by gateway family instead of route family
By this commit, user can configure dynamic IPv6 Gateway with IPv4
destination.
2020-10-15 07:06:03 +09:00
Yu Watanabe c3d679c43f network: when Gateway=_dhcp, assume gateway family based on other settings 2020-10-15 07:05:58 +09:00
Yu Watanabe b8caa4ef34 network: rename Gateway=_dhcp6 -> Gateway=_ipv6ra 2020-10-15 07:04:02 +09:00
Yu Watanabe 1a3a6309a7 network: rename gateway_from_dhcp -> gateway_from_dhcp_or_ra
As for IPv6 case gateway is given by RA.
2020-10-15 06:58:53 +09:00
Lennart Poettering 1008f5b069
Merge pull request #17351 from poettering/exec-rt-typo-fix
fix one character typo in execute.c
2020-10-14 19:41:27 +02:00
Lennart Poettering 21ad331873
Merge pull request #17350 from poettering/bus-read-array
sd-bus: initialize return values on success in sd_bus_message_read_ar…
2020-10-14 19:41:01 +02:00