1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-03 01:17:45 +03:00
Commit Graph

55919 Commits

Author SHA1 Message Date
Yu Watanabe
c2939963fe core/device: ignore DEVICE_FOUND_UDEV bit on switching root
The issue #12953 is caused by the following:
On switching root,
- deserialized_found == DEVICE_FOUND_UDEV | DEVICE_FOUND_MOUNT,
- deserialized_state == DEVICE_PLUGGED,
- enumerated_found == DEVICE_FOUND_MOUNT,
On switching root, most devices are not found by the enumeration process.
Hence, the device state is set to plugged by device_coldplug(), and then
changed to the dead state in device_catchup(). So the corresponding
mount point is unmounted. Later when the device is processed by udevd, it
will be changed to plugged state again.

The issue #23208 is caused by the fact that generated udev database in
initramfs and the main system are often different.

So, the two issues have the same root; we should not honor
DEVICE_FOUND_UDEV bit in the deserialized_found on switching root.

This partially reverts c6e892bc0e.

Fixes #12953 and #23208.
Replaces #23215.

Co-authored-by: Martin Wilck <mwilck@suse.com>
(cherry picked from commit 75d7b5989f)
2022-09-30 16:56:18 +02:00
Yu Watanabe
b16a4d45eb sd-device: make sd_device_get_is_initialized() not return -ENOENT
(cherry picked from commit 591c186f2f)
(cherry picked from commit d36b2af987)
2022-07-13 13:30:45 +02:00
Yu Watanabe
b791f05992 resolve: introduce FORMAT_DNS_RCODE() macro
Fixes #23958.

(cherry picked from commit 0d609349ba)
(cherry picked from commit a03ea9798a)
2022-07-13 13:30:45 +02:00
Yu Watanabe
3f909ca95a sd-dhcp-client: fix log message
(cherry picked from commit 3857d367f0)
(cherry picked from commit d56649142b)
2022-07-13 13:30:45 +02:00
Yu Watanabe
45944e44a7 network: drop redundant warning
If file is world readable, then `read_full_file_full()` will warn
about that.

(cherry picked from commit d5ad2ec1d4)
(cherry picked from commit c87c7e7231)
2022-07-13 13:30:45 +02:00
Yu Watanabe
e2335238d9 core/load-fragment: fix error value in log_syntax()
`extract_first_word()` may return positive value on success.

(cherry picked from commit 6a35d52d78)
(cherry picked from commit 900af21558)
2022-07-13 13:30:45 +02:00
Yu Watanabe
79d9afd3d6 resolve: fix possible integer overflow
(cherry picked from commit 370999c05b)
(cherry picked from commit b7fc4ffe97)
2022-07-13 13:30:45 +02:00
Yu Watanabe
63c0ce2346 resolve: fix heap-buffer-overflow reported by ASAN with strict_string_checks=1
Fixes #23942.

(cherry picked from commit beeab352de)
(cherry picked from commit feb244676b)
2022-07-13 13:30:45 +02:00
Yu Watanabe
c32530f5bd time-util: fix buffer-over-run
Fixes #23928.

(cherry picked from commit 9102c625a6)
(cherry picked from commit 72d4c15a94)
2022-07-13 13:30:45 +02:00
Lennart Poettering
9e9d8b8ef7 tmpfiles: correct error variable to use
(cherry picked from commit 149e0ca6c7)
(cherry picked from commit 9e73f919ab)
2022-07-13 13:30:45 +02:00
Lennart Poettering
859f107020 namespace: fix propagated error number
(cherry picked from commit 1ce268c789)
(cherry picked from commit c377dc4832)
2022-07-13 13:30:45 +02:00
Lennart Poettering
2317d49cfb man: "enabled commands are started at boot" is rubbish
it's enabled units, and they might be started by various forms of
activation, not just "at boot".

Fix that.

(cherry picked from commit 0c772b1cc1)
(cherry picked from commit 81d33ab7f6)
2022-07-13 13:30:44 +02:00
Lennart Poettering
84715375d5 json: actually use numeric C locale we just allocated
This fixes formatting of JSON real values, and uses C locale for them.
It's kinda interesting that this wasn't noticed before: the C locale
object we allocated was not used, hence doing the dance had zero effect.

This makes "test-varlink" pass again on systems with non-C locale.

(My guess: noone noticed this because "long double" was used before by
the JSON code and that had no locale supporting printer or so?)

(cherry picked from commit 93258c7d72)
(cherry picked from commit 2e6e30a92f)
2022-07-13 13:30:44 +02:00
Lennart Poettering
aa65f1f24f sd-id128: don't allow chars > f in valid id128 values
(cherry picked from commit 82c3a0b74c)
(cherry picked from commit 6e6da09bd0)
2022-07-13 13:30:44 +02:00
Yu Watanabe
256ce35963 nspawn: support PrivateUsers=identity
Follow-up for 33eac552ab.

Fixes #23825.

(cherry picked from commit 5ad08191d8)
(cherry picked from commit 5478878067)
2022-07-13 13:30:44 +02:00
Yu Watanabe
c094ef34a6 journalctl: fix to show user slice
Fixes #23867.

(cherry picked from commit 3daf1f913c)
(cherry picked from commit 9d86a5ac92)
2022-07-13 13:30:44 +02:00
Daan De Meyer
001d00ac69 journal: Fix missing parenthesis
(cherry picked from commit f63d1b0efa)
(cherry picked from commit 437978fe51)
2022-07-13 13:30:44 +02:00
Yu Watanabe
a53e5e0e2f virt: fix detection of Parallels virtualization
If Parallels virtualization is detected from DMI, then trust that over CPUID.

Fixes issue caused by 28b1a3eac2.

Fixes #23856.

(cherry picked from commit 840a49f3dc)
(cherry picked from commit 0c36233a84)
2022-07-13 13:30:44 +02:00
Yu Watanabe
2e54ed4043 sd-event: make sd_event_prepare() return positive when buffered inotify data exists
Previously, even if there is buffered inotify data, sd_event_prepare()
did not process the data when there is no pending event source.

Fixes #23826.

(cherry picked from commit 067fc91702)
(cherry picked from commit 632ba5b2f0)
2022-07-13 13:30:44 +02:00
Zbigniew Jędrzejewski-Szmek
29e3dc0dfd test-sd-hwdb: adjust the test to actually do anything
Without the terminating colon we wouldn't match anything, so the loop over
properties was skipped.

(cherry picked from commit 6b0485c29a)
(cherry picked from commit 09e0ccf293)
2022-07-13 13:30:44 +02:00
Jacek Migacz
2772e75771 emacs: ignore .dir-locals-2.el (personal customization) versioning
(cherry picked from commit 25e17bddec)
(cherry picked from commit 596dc75d18)
2022-07-13 13:30:44 +02:00
Yu Watanabe
a87e130a45 udev: allow to execute longer command line
Fixes #23607.

(cherry picked from commit c3613ee51e)
(cherry picked from commit 0c5b7ee318)
2022-07-13 13:30:44 +02:00
Alban Bedel
639423416c units: remove the restart limit on the modprobe@.service
They are various cases where the same module might be repeatedly
loaded in a short time frame, for example if a service depending on a
module keep restarting, or if many instances of such service get
started at the same time. If this happend the modprobe@.service
instance will be marked as failed because it hit the restart limit.

Overall it doesn't seems to make much sense to have a restart limit on
the modprobe service so just disable it.

Fixes: #23742
(cherry picked from commit 9625350e53)
(cherry picked from commit 8539a62207)
2022-07-13 13:18:28 +02:00
Pavel Zhukov
6785d1aa74 Add sys/file.h for LOCK_
Fixes build with musl:
| ../git/src/shared/dissect-image.c: In function 'mount_image_privately_interactively':
| ../git/src/shared/dissect-image.c:2986:34: error: 'LOCK_SH' undeclared (first use in this function)
|  2986 |         r = loop_device_flock(d, LOCK_SH);
|       |                                  ^~~~~~~

(cherry picked from commit 19df770fe1)
(cherry picked from commit b777390814)
2022-07-13 13:18:23 +02:00
Zbigniew Jędrzejewski-Szmek
ee2ecdff71 pkgconfig,rpm: expose vars for user-tmpfiles.d location
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2098553.

(cherry picked from commit 107795a759)
(cherry picked from commit a82d8d1916)
2022-07-13 13:18:20 +02:00
Frantisek Sumsal
dcd77da1f4 test: use saved process PID instead of %%
As the `%%` specifier might fail if the current job (i.e. the last
background job) already finished:

```
[   61.692196] testsuite-04.sh[656]: ++ systemd-id128 new
[   61.705407] testsuite-04.sh[263]: + ID=912cb8f8ef304153a123f772bb0fe9e0
[   61.706318] testsuite-04.sh[657]: + systemd-cat -t 912cb8f8ef304153a123f772bb0fe9e0 bash -c 'echo parent; (echo child) & wait'
[   61.720940] testsuite-04.sh[263]: + PID=657
[   61.721126] testsuite-04.sh[263]: + wait %%
[   61.723014] testsuite-04.sh[263]: /usr/lib/systemd/tests/testdata/units/testsuite-04.sh: line 96: wait: %%: no such job
```

(cherry picked from commit 0897048500)
(cherry picked from commit 9facc51e2f)
2022-07-13 13:18:16 +02:00
Marc Kleine-Budde
39a47af2e5 networkctl: fix output of "status": replace "Queue Length" by "Number of Queues"
Commit 0307afc681 ("networkctl: add support to display Transmit/Recieve queue
length (#12633)") added the display of the number of RX and TX Queues to the
output of `networkctl status $DEV`. However the row description says "Queue
Length".

This patch fixes the output by replacing "Queue Length" by "Number of Queues".

Fixes: 0307afc681 ("networkctl: add support to display Transmit/Recieve queue length (#12633)")
(cherry picked from commit 25ed7633b1)
(cherry picked from commit 16b8ae51b0)
2022-07-13 13:18:13 +02:00
Yu Watanabe
ba1d285ed0 seccomp-util: make @known include @obsolete
@known is generated from syscall-list.txt, which generated from kernel
headers. So, some syscalls in @obsolete may not be listed in
syscall-list.txt.

(cherry picked from commit 6d6a08547c)
(cherry picked from commit 996979f513)
2022-07-13 13:18:09 +02:00
Yu Watanabe
c96ff736c6 analyze-security: always save syscall name
This reverts dd51e725df and fixes bugs
introduced by 1624114d74.

Previously,
- On online scan, the syscall filter was a string Hashmap, but it
  might contain syscall name with errno or error action. Hence, we need
  to drop the errno or error action in the string.
- On offline scan, the syscall filter was a Hashmap of syscall ID, so
  hashmap_contains() with syscall name did not work. We need to convert
  syscall IDs to syscall names.
- If hashmap_contains() in syscall_names_in_filter() is true, then
  the syscall is allowed when the list is an allow-list, and vice versa.
  Hence, the condition in syscall_names_in_filter() was errnously
  inverted by dd51e725df.

This makes syscalls are always stored with its name, instead of ID,
and also correct the condition.

Fixes #23663.

(cherry picked from commit 5862e5561c)
(cherry picked from commit 20a265b416)
2022-07-13 13:18:04 +02:00
Yu Watanabe
89c1fccb1e set: introduce set_put_strndup()
Note, if `n != SIZE_MAX`, we cannot check the existence of the specified
string in the set without duplicating the string. And, set_consume() also
checks the existence of the string. Hence, it is not necessary to call
set_contains() if `n != SIZE_MAX`.

(cherry picked from commit cb649d12bf)
(cherry picked from commit a64c080ccf)
2022-07-13 13:16:33 +02:00
Yu Watanabe
074e76f211 nspawn: fix UID map string
We send/recv the set of payload uid, host uid, payload gid, host gid.
Hence, the index must be incremented with 4, instead of 2.

Fixes #23664.

(cherry picked from commit 05ab439a62)
(cherry picked from commit 20037219b7)
2022-07-13 13:16:28 +02:00
Shreenidhi Shedi
6bd461a55e sd-journal: check retval of sd_id128_from_string call
Fixes: CID#1469712

CID 1469712 (#1 of 1): Unused value (UNUSED_VALUE)
returned_value: Assigning value from sd_id128_from_string(word + 2, &boot_id) to r here,
but that stored value is overwritten before it can be used.

(cherry picked from commit c9f5ac0917)
(cherry picked from commit 73a327d2f4)
2022-07-13 13:16:24 +02:00
Jan Luebbe
f2b1c270bc hwdb: analyzers: remove generic "STM Device in DFU Mode"
The USB ID v0483pDF11 is used by the ROM code in many STMicroelectronics
devices (for firmware download) and not just signal analyzers.

(cherry picked from commit 5d049ff920)
(cherry picked from commit adcd345156)
2022-07-13 13:15:56 +02:00
Yu Watanabe
51c18be68d dns-domain: make each label nul-terminated
dns_label_unescape() does not nul-terminate the buffer if it does not
have enough space. Hence, if a lable is enough long, then strjoin()
triggers buffer-overflow.

Fixes #23705.

(cherry picked from commit 9db01ca5b0)
(cherry picked from commit 25158b2944)
2022-07-13 09:44:20 +02:00
Zbigniew Jędrzejewski-Szmek
947ddf732a test-nspawn-util: fix the test to actually find anything
We would use a relative path, looking for globs like
'lib/systemd/libsystemd-shared-*.so' under the build directory, and never find
anything.

The test was supposed to find library in the current installation. But we
cannot assume that the right library is installed, so the test only printed the
result for manual inspection. Thus nobody noticed when it broke. I think it
broke in c6134d3e2f, path-util: get rid of prefix_root().
But that commit doesn't compile because of changes in meson, so this is just
a guess.

Before:
/* test_systemd_installation_has_version */
Current installation has systemd >= 0: no
Current installation has systemd >= 231: no
Current installation has systemd >= 249: no
Current installation has systemd >= 999: no

With the fix:
$ build/test-nspawn-util
/* test_systemd_installation_has_version */
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (OK).
Current installation has systemd >= 0: yes
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (OK).
Current installation has systemd >= 231: yes
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old).
Found libsystemd shared at "/lib/systemd/libsystemd-shared-251.so.so", version 251 (OK).
Current installation has systemd >= 251: yes
Found libsystemd shared at "/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old).
Found libsystemd shared at "/lib/systemd/libsystemd-shared-251.so.so", version 251 (too old).
Found libsystemd shared at "/lib/systemd/libsystemd-shared-250.so.so", version 250 (too old).
Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-245.so.so", version 245 (too old).
Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-251.so.so", version 251 (too old).
Found libsystemd shared at "/usr/lib/systemd/libsystemd-shared-250.so.so", version 250 (too old).
Current installation has systemd >= 999: no

$ build/test-nspawn-util /var/lib/machines/rawhide
/* test_systemd_installation_has_version */
/* test_systemd_installation_has_version */
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK).
/var/lib/machines/rawhide has systemd >= 0: yes
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK).
/var/lib/machines/rawhide has systemd >= 231: yes
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (OK).
/var/lib/machines/rawhide has systemd >= 251: yes
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (too old).
Found libsystemd shared at "/var/lib/machines/rawhide/usr/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251 (too old).
/var/lib/machines/rawhide has systemd >= 999: no

While at it, NULSTR_FOREACH → FOREACH_STRING.

(cherry picked from commit 0643001c28)
2022-07-11 20:54:18 +09:00
Zbigniew Jędrzejewski-Szmek
88631ec544 nspawn: fix comparisons of versions with non-numerical suffixes
See a2b0cd3f5a. When -Dshared-lib-tag is used,
libsystemd-shared.so and libsystemd-core.so get a suffix which breaks the
parsing done by systemd_installation_has_version(). We can assume that the
tag will be something like "251-rc1-1.fc37" that is currently used in Fedora.
(Anything that does *not* start with the version would be completely crazy.)
By switching to strverscmp_improved() we simplify the code and fix comparisons
with such versions.

$ build/test-nspawn-util /var/lib/machines/rawhide
...
Found libsystemd shared at "/var/lib/machines/rawhide/lib/systemd/libsystemd-shared-251-rc1-1.fc37.so.so", version 251-rc1-1.fc37 (OK).
/var/lib/machines/rawhide has systemd >= 251: yes
...

I noticed this when I started a systemd-nspawn container with Redora rawhide
and got the message "Not running with unified cgroup hierarchy, LSM BPF is not
supported". I thought the message is in error, but it was actually correct:
nspawn was misdetecting that the container does not sport new-enough systemd
to support cgroups-v2.

(cherry picked from commit 7e6821ed4e)
2022-07-11 20:54:18 +09:00
Zbigniew Jędrzejewski-Szmek
8f46abbd8e Move systemd_installation_has_version() to src/nspawn/
This function implements a heuristic that is only used by nspawn. It doesn't
belong in basic. I opted for a new file "nspawn-utils.c", because it seems
likely that we'll need some other new utilities like that in the future.

No functional change.

(cherry picked from commit c9394f4f93)
2022-07-11 20:54:18 +09:00
Yu Watanabe
e74e1dc8cc network: create stacked netdevs after the underlying link is activated
Otherwise, the activation policy for the netdevs are ignored.

Fixes #22593.

(cherry picked from commit 047b9991a4)
2022-06-12 11:49:27 +02:00
Yu Watanabe
28390fa984 network: do not enable IPv4 ACD for IPv4 link-local address if ACD is disabled explicitly
The commit 1cf4ed142d makes the IPv4 ACD
enabled unconditionally for IPv4 link-local addresses even if users
explicitly disable ACD.

This makes the IPv4 ACD is enabled by default, but honor user setting.

Fixes #22763.

(cherry picked from commit 2859932bd6)
2022-06-10 08:14:31 +09:00
Luca Boccassi
cfe1936465 analyze: fix crash with online security check
1449b0f8a9 fixed seccomp arch check for the offline case,
but broke it for the normal case, as when coming from D-Bus the
list of seccomp architectures is already converted to string.

Fixes https://github.com/systemd/systemd/issues/23224

(cherry picked from commit e22f2cfa5e79135d9abf53152a292357fe807dc9)
2022-06-10 08:13:31 +09:00
Zbigniew Jędrzejewski-Szmek
77fabe49e1 meson: also check c_args to maybe add -Wno-maybe-uninitialized
People (and build systems) sometimes set flags through -Dc_args=… or $CFLAGS.
Let's catch this common case too. meson will set c_args from $CFLAGS, so we
only need to check the former.

(cherry picked from commit b528a62863)
2022-06-09 17:47:50 +02:00
Yu Watanabe
39f2ccdb37 tree-wide: fix typo
(cherry picked from commit a17e54783a)
2022-06-09 17:47:50 +02:00
Zbigniew Jędrzejewski-Szmek
51089e007f Revert "stat-util: optimize dir_is_empty_at() a bit, by using getdents64()"
This reverts commit a068aceafb.

https://github.com/systemd/systemd/pull/23236 fixes a regression introduced
by this patch. But there was a bunch of follow-ups, and unrelated fixups…
So let's just revert this instead.
2022-06-09 17:47:50 +02:00
Zbigniew Jędrzejewski-Szmek
c46b908d6e Revert "tree-wide: explicitly unpoison getdents64() memory"
This partially reverts commit 0dbce03c37.
2022-06-09 17:33:19 +02:00
Yu Watanabe
666d792e85 network: do not update interface group by default
This fixes a minor bug introduced by 10af8bb24b.
Before the commit, the interface group was set only when Group= is explicitly
specified, otherwise the interface group was kept. However, after the commit,
we need to specify Group= with an empty string to keep the current interface
group.

(cherry picked from commit cee6833943)
2022-06-09 17:24:40 +02:00
Jan Janssen
4ee49a624c boot: Fix bad CompareMem call
(cherry picked from commit 2d5d72c62b)
(cherry picked from commit f65f0b642981de071a474a2522969682bbd615ec)
2022-06-09 17:06:32 +02:00
Zbigniew Jędrzejewski-Szmek
ec340a3978 sha256: fix compilation on efi-ia32
/usr/bin/gcc -c ../src/fundamental/sha256.c -o src/boot/efi/sha256.c.o -Wno-format-signedness -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -fno-stack-protector -fno-strict-aliasing -fpic -fwide-exec-charset=UCS2 -Wall -Wextra -Wsign-compare -nostdlib -std=gnu99 -ffreestanding -fshort-wchar -fvisibility=hidden -isystem /usr/include/efi -isystem /usr/include/efi/ia32 -I /builddir/build/BUILD/systemd-stable-250.7/src/fundamental -DSD_BOOT -DGNU_EFI_USE_MS_ABI -include src/boot/efi/efi_config.h -include version.h -mno-sse -mno-mmx -flto -O2 -flto=auto
../src/fundamental/sha256.c: In function ‘sha256_finish_ctx’:
../src/fundamental/sha256.c:61:25: error: ‘false’ undeclared (first use in this function)
   61 | # define UNALIGNED_P(p) false
      |                         ^~~~~
../src/fundamental/sha256.c:136:21: note: in expansion of macro ‘UNALIGNED_P’
  136 |                 if (UNALIGNED_P(resbuf))
      |                     ^~~~~~~~~~~
../src/fundamental/sha256.c:32:1: note: ‘false’ is defined in header ‘<stdbool.h>’; did you forget to ‘#include <stdbool.h>’?
   31 | #include "sha256.h"
  +++ |+#include <stdbool.h>
   32 |
...

(cherry picked from commit 38c87ca2ab)
(cherry picked from commit 46db77075da0f4d554b82ee6d54ef64125afec40)
2022-06-09 16:22:07 +02:00
Zbigniew Jędrzejewski-Szmek
c62d033a91 shared/microhttp-util: silence gcc warning
../src/journal-remote/microhttpd-util.c: In function ‘check_permissions’:
../src/journal-remote/microhttpd-util.c:301:5: error: function might be candidate for attribute ‘noreturn’ [-Werror=suggest-attribute=noreturn]
  301 | int check_permissions(struct MHD_Connection *connection, int *code, char **hostname) {
      |     ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Fixes #23630.

(cherry picked from commit b547241728)
(cherry picked from commit ad74be8f3746dcca066860cbb23befada4af84c6)
2022-06-09 16:22:03 +02:00
Daan De Meyer
a78e72be51 coredump: Fix format string type mismatch
Fixes #23471

(cherry picked from commit 08e86b15fc)
(cherry picked from commit 421a99e2d681e52a7d471f34bb1bd8a2a4e56540)
2022-06-09 16:21:58 +02:00
Zbigniew Jędrzejewski-Szmek
8feb4b1766 various: add %m in messages
Sometimes we want to suppress strerror() message because the are providing
something better. But in those cases, it seems it was just forgotten.

(cherry picked from commit 2e09b2235a)
(cherry picked from commit b9f0194aab)
2022-06-02 20:09:14 +02:00