1
0
mirror of https://github.com/systemd/systemd.git synced 2025-01-27 18:04:05 +03:00

64810 Commits

Author SHA1 Message Date
Yu Watanabe
230f663e3e update-utmp: use verbs
No functional change, just refactoring.
2023-05-24 20:04:33 +09:00
Yu Watanabe
5f1f05b961
Merge pull request #27740 from dtardon/list-sessions-idle
Show idle status in `loginctl list-sessions`
2023-05-24 20:03:39 +09:00
Yu Watanabe
8ddc5f7699
Merge pull request #27757 from dtardon/bus-locator
Convert more DBus calls to BusLocator
2023-05-24 20:02:57 +09:00
Luca Boccassi
fe830b84d4
Merge pull request #27761 from yuwata/network-vlan-qos-mapping
network: fix vlan qos mapping
2023-05-24 09:59:41 +01:00
David Tardon
556723e738 loginctl: show session idle status in list-sessions 2023-05-24 10:04:45 +02:00
Yu Watanabe
5c4e96c28c test: rotate journal before storing coredumps
Hopefully fixes the failure like
https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/job/upstream-vagrant-archlinux-sanitizers/2558/
---
[   66.708894] testsuite-74.sh[728]: + coredumpctl --json=off
[   66.709344] testsuite-74.sh[826]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.709773] testsuite-74.sh[826]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.711134] testsuite-74.sh[826]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.711789] testsuite-74.sh[826]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.712460] testsuite-74.sh[826]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.713505] testsuite-74.sh[728]: + coredumpctl --root=/
[   66.714144] testsuite-74.sh[828]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.714535] testsuite-74.sh[828]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.715208] testsuite-74.sh[828]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.715907] testsuite-74.sh[828]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.716565] testsuite-74.sh[828]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.717494] testsuite-74.sh[728]: + coredumpctl --directory=/var/log/journal
[   66.718188] testsuite-74.sh[830]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.882072] testsuite-74.sh[830]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.882642] testsuite-74.sh[830]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.883450] testsuite-74.sh[830]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.883944] testsuite-74.sh[830]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.885448] testsuite-74.sh[728]: + coredumpctl --file=/var/log/journal/2e1ed84be19a4e22adfc99ad849be1f6/system.journal
[   66.885989] testsuite-74.sh[728]: + at_exit
[   66.894162] coredumpctl[833]: No coredumps found.
---
2023-05-24 09:22:13 +02:00
David Tardon
3ac26d0718 oomctl: convert a oom1.Manager call to BusLocator 2023-05-24 08:50:02 +02:00
David Tardon
86257d9fd8 bus-locator: sort the list 2023-05-24 08:50:02 +02:00
David Tardon
1925011748 bus-locator: declare bus locator for oom1 and timesync1 2023-05-24 08:50:02 +02:00
David Tardon
d14bd34f25 hostnamectl: convert more hostname1 calls to BusLocator 2023-05-24 08:33:22 +02:00
David Tardon
7f8a85e6d8 tree-wide: convert more resolve1.Manager calls to BusLocator 2023-05-24 08:33:22 +02:00
David Tardon
daecc5b95b journalctl: convert a machine1.Manager call to BusLocator 2023-05-24 08:33:22 +02:00
David Tardon
a29f13f296 sleep: convert a home1.Manager call to BusLocator 2023-05-24 08:33:22 +02:00
David Tardon
6ce68c7c51 login: use NULL to denote arg-less method call
"" and NULL are equivalent, but the latter is normally used.
2023-05-24 08:32:13 +02:00
David Tardon
d962e73796 tree-wide: convert more login1.Manager calls to BusLocator 2023-05-24 08:24:00 +02:00
David Tardon
b71471684a tree-wide: convert more system1.Manager calls to BusLocator 2023-05-24 08:23:59 +02:00
Yu Watanabe
73d24e45f8 test-network: add tests for vlan QoS mapping 2023-05-24 11:15:44 +09:00
Yu Watanabe
4194478af8 network/vlan: paranoia about type safety
No functional change, as the struct is defined as the following:
```
struct ifla_vlan_qos_mapping {
      __u32 from;
      __u32 to;
};
```
2023-05-24 11:06:43 +09:00
Yu Watanabe
4d13d175f8 network/vlan: drop unnecessary restriction for QoS mapping
Fixes #27460.
2023-05-24 11:02:39 +09:00
Yu Watanabe
5dc0c21b31 core/slice: shorten code a bit 2023-05-24 10:26:21 +09:00
Jan Janssen
ab7d54b9dd elf2efi: Do not emit an empty relocation section
At least shim will choke on an empty relocation section when loading the
binary. Note that the binary is still considered relocatable (just with
no base relocations to apply) as we do not set the
IMAGE_FILE_RELOCS_STRIPPED DLL characteristic.
2023-05-23 22:47:28 +01:00
msizanoen1
b458659a16 core: Do not check child freezability when thawing slice
We want thawing operations to still succeed even in the presence of an
unfreezable unit type (e.g. mount) appearing under a slice after the
slice was frozen. The appearance of such units should never cause the
slice thawing operation to fail to prevent potential future repeats of
https://github.com/systemd/systemd/issues/25356.
2023-05-24 06:22:41 +09:00
Yu Watanabe
a484320572
Merge pull request #27755 from keszybz/fix-root-resize-new
Reload keymap and locale config after firstboot writes it out
2023-05-24 06:08:54 +09:00
Yu Watanabe
dd57168144
Merge pull request #27754 from poettering/cloexec-fdset-madness
pid1: when taking possession of passed fds check O_CLOEXEC state first
2023-05-24 06:08:17 +09:00
Zbigniew Jędrzejewski-Szmek
badea0d6df sd-boot,sd-stub: also print version after the address
The kernel, systemd, and many other things print their version during boot.
sd-boot and sd-stub are also important, so let's print the version if EFI_DEBUG.
(If !EFI_DEBUG, continue to be quiet.)

When updating the docs, I saw that that the text in HACKING.md was out of date.
Instead of trying to update the instructions there, make it shorter and refer
the reader to tools/debug-sd-boot.sh for details.
2023-05-24 04:34:56 +09:00
Daan De Meyer
a1a4bbea2d mkfs-util: Silence noisy warning from mkfs.btrfs 2023-05-23 19:46:31 +01:00
Lennart Poettering
d7aee3f41f test: test O_CLOEXEC filtering of fdset fill logic 2023-05-23 20:46:13 +02:00
Lennart Poettering
42dc1cd468 fdset: minor modernizations 2023-05-23 20:46:13 +02:00
Daan De Meyer
3d41b6b8e8 tree-wide: Fix false positives on newer gcc
Recent gcc versions have started to trigger false positive
maybe-uninitialized warnings. Let's make sure we initialize
variables annotated with _cleanup_ to avoid these.
2023-05-23 19:45:27 +01:00
Frantisek Sumsal
909eb4c01d json: correctly handle magic strings when parsing variant strv
We can't dereference the variant object directly, as it might be
a magic object (which has an address on a faulting page); use
json_variant_is_sensitive() instead that handles this case.

For example, with an empty array:

==1547789==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000023 (pc 0x7fd616ca9a18 bp 0x7ffcba1dc7c0 sp 0x7ffcba1dc6d0 T0)
==1547789==The signal is caused by a READ memory access.
==1547789==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
    #0 0x7fd616ca9a18 in json_variant_strv ../src/shared/json.c:2190
    #1 0x408332 in oci_args ../src/nspawn/nspawn-oci.c:173
    #2 0x7fd616cc09ce in json_dispatch ../src/shared/json.c:4400
    #3 0x40addf in oci_process ../src/nspawn/nspawn-oci.c:428
    #4 0x7fd616cc09ce in json_dispatch ../src/shared/json.c:4400
    #5 0x41fef5 in oci_load ../src/nspawn/nspawn-oci.c:2187
    #6 0x4061e4 in LLVMFuzzerTestOneInput ../src/nspawn/fuzz-nspawn-oci.c:23
    #7 0x40691c in main ../src/fuzz/fuzz-main.c:50
    #8 0x7fd61564a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #9 0x7fd61564a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #10 0x405da4 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/fuzz-nspawn-oci+0x405da4)

DEDUP_TOKEN: json_variant_strv--oci_args--json_dispatch
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../src/shared/json.c:2190 in json_variant_strv
==1547789==ABORTING

Or with an empty string in an array:

../src/shared/json.c:2202:39: runtime error: member access within misaligned address 0x000000000007 for type 'struct JsonVariant', which requires 8 byte alignment
0x000000000007: note: pointer points here
<memory cannot be printed>
    #0 0x7f35f4ca9bcf in json_variant_strv ../src/shared/json.c:2202
    #1 0x408332 in oci_args ../src/nspawn/nspawn-oci.c:173
    #2 0x7f35f4cc09ce in json_dispatch ../src/shared/json.c:4400
    #3 0x40addf in oci_process ../src/nspawn/nspawn-oci.c:428
    #4 0x7f35f4cc09ce in json_dispatch ../src/shared/json.c:4400
    #5 0x41fef5 in oci_load ../src/nspawn/nspawn-oci.c:2187
    #6 0x4061e4 in LLVMFuzzerTestOneInput ../src/nspawn/fuzz-nspawn-oci.c:23
    #7 0x40691c in main ../src/fuzz/fuzz-main.c:50
    #8 0x7f35f364a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #9 0x7f35f364a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #10 0x405da4 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/fuzz-nspawn-oci+0x405da4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/shared/json.c:2202:39 in

Note: this happens only if json_variant_copy() in json_variant_set_source() fails.

Found by Nallocfuzz.
2023-05-23 20:18:21 +02:00
Lennart Poettering
a3dff21ae8 pid1: when taking possession of passed fds check O_CLOEXEC state first
So here's the thing. One library we use (libselinux) is opening fds
behind our back when we initialize it and keeps it open. On the other
hand we want to automatically pick up all fds passed in to us, so that
we can distribute them to our services and close the rest. We pick them
up very early in our code, to ensure that we don't get confused by open
fds at that point. Except that libselinux insists on being initialized
even earlier. So suddenly we might take possession of libselinux' fds,
and then close them later when we decide no service wants them. Then
during shutdown we close down selinux and selinux closes its fds, but
since already closed long ago this ight close our fds instead. Hilarity
ensues.

I wish low-level software wouldn't do such things behind our back, but
well, let's make the best of it.

This changes the fd pick-up logic to only pick up fds that have
O_CLOEXEC unset. O_CLOEXEC must be unset for any fds passed in to us
over execve() after all. And for all our own fds we should set O_CLOEXEC
since we generally don't want to litter fd tables for execve(). Also,
libselinux thankfully appears to set O_CLOEXEC correctly on its fds,
hence the filter works.

Fixes: #27491
2023-05-23 19:23:32 +02:00
Lennart Poettering
13f37e6e97 log: propagate max log level into glibc's setlogmask()
Follow-up for: #27734

It makes sense to propagate the select log level we maintain also into
glibc, so that any code that uses syslog() directly that ends up in our
processes (libraries and such) are affected by our settings the same way
as we are ourselves.
2023-05-23 09:53:58 -07:00
Lennart Poettering
dc53421de5 udevadm: improve debug logging when triggering/watching events
Let's make debugging udev triggering a bit easier, by generating debug
log messages whenever we trigger a device, and also when we see the
event in pid1.
2023-05-23 09:53:37 -07:00
Lennart Poettering
3fa7e62c4c
Merge pull request #27750 from keszybz/fix-root-resize-new
Allow firstboot.service to be started after sysusers.service
2023-05-23 09:53:13 -07:00
Zbigniew Jędrzejewski-Szmek
2ad1e0671b localed: simplify method call
Also remove lines between call and result handling.
2023-05-23 17:39:12 +02:00
Zbigniew Jędrzejewski-Szmek
d0c50d8dfa firstboot: reload manager after writing /etc/locale.conf
Requested in https://github.com/systemd/systemd/pull/27750#issuecomment-1559258861.
I didn't apply the locale configuration in firstboot itself, because
we don't have any localized messages, so that wouldn't change anything.
2023-05-23 17:38:43 +02:00
Zbigniew Jędrzejewski-Szmek
cea32691c3 firstboot: do vconsole setup after configuring keymap
Fixes #13466.
2023-05-23 17:38:43 +02:00
Zbigniew Jędrzejewski-Szmek
a777a59243 firstboot: process the root account after sysusers created it
We would create root account from sysusers or from firstboot, depending on
which one ran earlier. Since firstboot offers more options, in particular can
set the root password, we needed to order it earlier. This created an ugly
ordering requirement:

systemd-sysusers.service > systemd-firstboot.service > ... >
  systemd-remount-fs.service > systemd-tmpfiles-setup-dev.service >
  systemd-sysusers.service

We want sysusers.service to create basic users, so we can create nodes in dev,
so we can operate on block devices and such, so that we can resize and remount
things. But at the same time, systemd-firstboot.service can only work if it is
run early, before systemd-sysusers.service has created /etc/passwd. We can't
have it both ways: the units that want to have a fully writable root file
system cannot be ordered before units which are required to do file system
preparation.

Instead of trying to order firstboot very early, let's let it do its thing even
if it is started later. Instead of refusing to create to the root account if
/etc/passwd and /etc/shadow exist, actually check if the account is configured.
Now sysusers writes root account with password PASSWORD_UNPROVISIONED
("!unprovisioned"), and then firstboot checks for this, and will configure root
in this case.

This allows sysusers to be executed earlier (or accounts to be set up earlier
in another way).

This effectively reverts b825ab1a99b69956057c79838faaf7b44afee474.
2023-05-23 15:09:39 +02:00
Zbigniew Jędrzejewski-Szmek
bd3beda283 shared/condition: add envvar override for the check for first-boot
Before 7cd43e34c5a302ff323c013f437092d2ff5ccbbf, it was possible to use
SYSTEMD_PROC_CMDLINE=systemd.condition-first-boot to override autodetection.
But now this doesn't work anymore, and it's useful to be able to do that for
testing.
2023-05-23 15:09:39 +02:00
Zbigniew Jędrzejewski-Szmek
7e4c61491a sysusers: fix argument confusion in error message
Bug introduced in 335f6ab4f13abcd8073fe84f2a3c70c67271126e. pw/sp are totally
wrong in this context, most likely NULL.
2023-05-23 15:09:39 +02:00
Zbigniew Jędrzejewski-Szmek
9740e677be sysusers: add usual "ret_" prefix, fix messages
We had 'make backup x'. 'make backup of x' would be correct, but 'backup x' is
shorter and to the point.
2023-05-23 15:09:39 +02:00
Zbigniew Jędrzejewski-Szmek
b42482af90 units: create /dev with --graceful first, allow sysusers to run later
We want to call systemd-tmpfiles-setup-dev.service to create /dev/fuse and
other device nodes so that module probing will work. But it is possible that
when we're in first boot, some users or groups need to be created by
systemd-sysusers first. But it is also possible that systemd-sysusers cannot
actually execute configuration because the root partition is not fully writable
yet. So let systemd-tmpfiles-setup-dev.service run earlier, possibly without
all users and groups in place. Since systemd-tmpfiles-setup-dev.service writes
to /dev only, it doesn't care how the root partition is mounted. In this early
run, some some nodes might be created with default permissions (i.e. not
accessible to non-root users or groups). This should be OK for the early boot
phase. Afterwards, we let systemd-tmpfiles-setup.service execute full
configuration. We will configure any files in /dev twice, but considering that
there's only a few of them and that the second run should only adjust ownership
and permissions, this should be OK. This way, we avoid the dependency loop.
2023-05-23 15:09:39 +02:00
Zbigniew Jędrzejewski-Szmek
a3256ea8f4 man: extend description of --boot 2023-05-23 15:09:39 +02:00
Zbigniew Jędrzejewski-Szmek
c264ec5f53 repart: do not require /var/tmp if not used
If systemd-repart is running sufficiently early, /var/tmp might not be in place
yet. But if there is nothing to minimize, we won't even use it. Let's move the
check right before the first use.

systemd-repart[441]: Device '/' has no dm-crypt/dm-verity device, no need to look for…
systemd-repart[441]: Device /dev/sda opened and locked.
systemd-repart[441]: Sector size of device is 512 bytes. Using grain size of 4096.
systemd-repart[441]: Could not determine temporary directory: No such file or directory
systemd[1]: systemd-repart.service: Child 441 belongs to systemd-repart.service.
systemd[1]: systemd-repart.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: systemd-repart.service: Failed with result 'exit-code'.
2023-05-23 15:09:31 +02:00
Zbigniew Jędrzejewski-Szmek
e0ea6af3b3 tmpfiles: add --graceful
See the man page diff for description.
2023-05-23 15:09:22 +02:00
Zbigniew Jędrzejewski-Szmek
c42bac6a60 basic/user-util: return -ESRCH if passwd/group are missing 2023-05-23 14:41:24 +02:00
Yu Watanabe
26a9dd6f55 sd-bus: refuse to send messages with an invalid string
Prompted by aaf7b0e41105d7b7cf30912cdac32820f011a219 and
4804da58536ab7ad46178a03f4d2da49fd8e4ba2.
2023-05-23 19:14:21 +08:00
Zbigniew Jędrzejewski-Szmek
2223a02580 tmpfiles: align table 2023-05-23 12:39:34 +02:00
Zbigniew Jędrzejewski-Szmek
fd6ee7ed42 firstboot: clarify that machine-id options are only offline, add missing docs
Let's flat out refuse to configure machine-id on a running system with
systemd-firstboot. It wouldn't work anyway, because by the time firstboot is
started, pid1 has created /etc/machine-id, possibly with "unitialized", so
firstboot wouldn't touch the file. (If --force is specified, it works. So
let's allow that in case people want to do crazy things.)

While at it, add missing descriptions of various things that were added over
time, and group descriptions of similar options together.
2023-05-23 12:39:34 +02:00
Zbigniew Jędrzejewski-Szmek
b93562a1a1 units: make sure proc-sys-binfmt_misc.automount is actually stopped
As with other units, stopping of the automount requires actual work,
and without the ordering dependency systemd might not execute the stop
job before shutdown.target is reached and units ordered after that are
executed.
2023-05-23 12:39:34 +02:00