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

55936 Commits

Author SHA1 Message Date
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
Zbigniew Jędrzejewski-Szmek
255264cdf6 core: define a helper function for basic bpf checks
(cherry picked from commit bb0b01ed20)
(cherry picked from commit 1b4511849b)
2022-06-02 20:09:14 +02:00
Zbigniew Jędrzejewski-Szmek
d4cff445e4 shared/bpf: install log callback and suppress most messages from libbpf
$ build/test-socket-bind
...
libbpf: load bpf program failed: Operation not permitted
libbpf: failed to load program 'sd_bind4'
libbpf: failed to load object 'socket_bind_bpf'
libbpf: failed to load BPF skeleton 'socket_bind_bpf': -1
Failed to load BPF object: Operation not permitted

Now all lines with "libbpf:" are at debug level and will be hidden by
default.

Partially fixes https://bugzilla.redhat.com/show_bug.cgi?id=2084955#c14
(i.e. the error that was exposed when the initial error was fixed.)

(cherry picked from commit 44005a5778)
(cherry picked from commit eceaa72f87)
2022-06-02 20:09:14 +02:00
Yu Watanabe
b4cdb3f346 sha256: use memcpy() when result buffer is unaligned
Fixes #23578.

(cherry picked from commit c7a5eabeba)
(cherry picked from commit 761fc09a00)
2022-06-02 20:09:14 +02:00
Antonio Alvarez Feijoo
d6abfffdc5 man: add missing arguments to systemd-creds synopsis
(cherry picked from commit 5ad0109cd8)
(cherry picked from commit 98a39c3014)
2022-06-02 20:09:14 +02:00
Benjamin Franzke
7a2f1363bb resolved: define source address for proxy-only stub replies
DnsPacket.ifindex=1 (loopback) is normalized to 0 whenever a message is
received on the loopback iface, so for both listeners, 127.0.0.53 and
127.0.0.54, the ifindex will be set to 0 by manager_recv() for queries
that have a local origin.

Replies to such local messages need to set a proper ifindex in any
case, as the supplied source-address would otherwise be ignored in
manager_ipv4_send() (CMSG generation is skipped due to ifindex > 0 check).

Note that this change only forces `ifindex` to loopback if it was actually
normalized to `0` before (due to a loopback detection) in order to keep the
nat-to-127.0.0.54-from-another-interface usecase that was described in
a8d0906344 intact.
Also note that nat is not supported for the main stub 127.0.0.53 which is
why forcing LOOPBACK_IFINDEX was/is fine for that case.

Fixes #23495

(cherry picked from commit dfa14e2859)
(cherry picked from commit 7ee5cde343)
2022-06-02 20:09:14 +02:00
msizanoen1
e76a154efe cgroup-util: Properly handle conditions where cgroup.threads is empty after SIGKILL but processes still remain
After sending a SIGKILL to a process, the process might disappear from
`cgroup.threads` but still show up in `cgroup.procs` and still remains in the
cgroup and cause migrating new processes to `Delegate=yes` cgroups to fail with
`-EBUSY`. This is especially likely for heavyweight processes that consume more
kernel CPU time to clean up.

Fix this by only returning 0 when both `cgroup.threads` and
`cgroup.procs` are empty.

(cherry picked from commit 37f0289bf5)
(cherry picked from commit 1961d84ab5)
2022-06-02 20:09:14 +02:00
Yu Watanabe
a5b0338e89 sd-bus: fix buffer overflow
Fixes #23486.

(cherry picked from commit 89b6a3f13e)
(cherry picked from commit a5c4e29b2c)
2022-06-02 20:09:14 +02:00
Nick Rosbrook
ebe423270e sd-hwdb: include sys/stat.h in hwdb-internal.h
Include this header to fix errors when including hwdb-internal.h:
  ../src/libsystemd/sd-hwdb/hwdb-internal.h:16:21: error: field ‘st’ has incomplete type
     16 |         struct stat st;

(cherry picked from commit 9745b51c73)
(cherry picked from commit f00716615d)
2022-06-02 20:09:14 +02:00
Zbigniew Jędrzejewski-Szmek
fb406eac65 man/homectl: adjust man page to match code
Fixes #22966. Since there are competing conventions, let's not
change our code, but make the docs match what is implemented.

(cherry picked from commit b72308d344)
(cherry picked from commit cfd6a14c7d)
2022-06-02 20:09:14 +02:00
Zbigniew Jędrzejewski-Szmek
80f6c459b5 man/sd-bus: discuss negative-return values and add example
Fixes #22816.

(cherry picked from commit 8f24777156)
(cherry picked from commit 11b8069929)
2022-06-02 20:09:14 +02:00
Zbigniew Jędrzejewski-Szmek
0181604288 man/shutdown: explain -h more
Fixes #23401

(cherry picked from commit 5ee38adea4)
(cherry picked from commit 7c2b2f279c)
2022-06-02 20:09:14 +02:00
Zbigniew Jędrzejewski-Szmek
ba90084542 man/automount: say that automounts should not be nested
Fixes #21832.

(cherry picked from commit 223a359f21)
(cherry picked from commit 7a73f995e2)
2022-06-02 20:09:14 +02:00
Zbigniew Jędrzejewski-Szmek
a402228745 man/systemd.automount: move the main description up and clarify deps
(cherry picked from commit 93dbc22a95)
(cherry picked from commit 0d3ba825e2)
2022-06-02 20:09:14 +02:00
Eduard Tolosa
4278dbdb1e loader.conf: Clarify the default value of timeout.
(cherry picked from commit 815068d3a3)
(cherry picked from commit d5be915999)
2022-06-02 20:09:14 +02:00
Anita Zhang
f0c4650378 test-seccomp: check for CAP_IPC_OWNER before calling shmat()
shmat() requires the CAP_IPC_OWNER capability. When running test-seccomp
in environments with root + CAP_SYS_ADMIN, but not CAP_IPC_OWNER,
memory_deny_write_execute_shmat would fail. This fixes it.

(cherry picked from commit 7e46a5c093)
(cherry picked from commit d4ca019870e9c31026c75633be12b5893ffa4ecf)
(cherry picked from commit 9a50c7c1499cb84b068552c503b9139c9e3a2e17)
2022-06-02 20:09:14 +02:00
Yu Watanabe
0041f0d609 mkosi: drop libiptc from build for Fedora
It is mostly deprecated on Fedora.

(cherry picked from commit ab21290049)
2022-05-26 12:36:33 +01:00
Yu Watanabe
e5613d202d mkosi: test-acl-util requires getfacl
(cherry picked from commit 2481f0369c)
2022-05-26 12:36:33 +01:00
Evgeny Vereshchagin
3354285739 ci: switch from unstable to testing on mkosi
(cherry picked from commit b0f1f76ca1)
2022-05-26 12:36:33 +01:00
Zbigniew Jędrzejewski-Szmek
3784472f64 manager: skip BPF cleanup if we never initialized
This fixes a spurious warning from the manager running in user mode:

systemd[1668]: Reached target sockets.target.
systemd[1669]: Failed to create BPF map: Operation not permitted
systemd[1669]: Finished systemd-tmpfiles-setup.service.
systemd[1669]: Listening on dbus.socket.
systemd[1669]: Reached target sockets.target.
systemd[1669]: Reached target basic.target.
systemd[1]: Started user@6.service.

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

(cherry picked from commit ba187c9c9c)
2022-05-25 17:27:19 +02:00
Zbigniew Jędrzejewski-Szmek
9d6fa4e17d core/bpf: lsm_bpf_supported() returns a boolean
The code was corret, but confusing, because it was treating the int
as a boolean.

(cherry picked from commit 389db516df)
2022-05-25 17:27:14 +02:00
Daan De Meyer
6f8adbad80 bootctl: Make sure bootctl install returns 0 on success
This backports the same fix from 6e9165397f
in systemd upstream that we can't backport directly because that commit
introduces a new feature.

(cherry picked from commit eb76587f33)
2022-05-25 17:20:40 +02:00
Yu Watanabe
6100e1dded sysext: refuse empty release ID to avoid triggering assertion
Otherwise, the assertion in extension_release_validate() will be
triggered.

(cherry picked from commit 30e29edf4c)
2022-05-25 17:20:33 +02:00
Zbigniew Jędrzejewski-Szmek
684585719b kernel-install: restore priority of check for /boot/loader/entries
Fixes https://bugzilla.redhat.com/show_bug.cgi?id=2071034.

Based on 1b43f86893.
2022-05-25 17:19:56 +02:00
Luca Boccassi
54201434be sd-bus: add comment and test in sd_bus_path_decode() for empty string
3970	        e = object_path_startswith(path, prefix);
(gdb) p path
$1 = 0x55c5a166f768 "/org/freedesktop/portable1/image"
(gdb) p prefix
$2 = 0x55c59ffc2928 "/org/freedesktop/portable1/image"
(gdb) p e
$1 = 0x5581a1675788 ""

This can be a bit confusing in certain cases, so add a comment and a
test to make the behaviour clearer and explicit.

(cherry picked from commit 54cd2d6869)
2022-05-25 17:04:57 +02:00
Zbigniew Jędrzejewski-Szmek
4abf21875c portabled: wrap long lines and fix typo in error message
(cherry picked from commit 5943d85f34)
2022-05-25 17:04:48 +02:00
Zbigniew Jędrzejewski-Szmek
a03ce6d1a2 portabled: refuse queries for empty image name
I took inspiration from pid1:
bus_unit_find()
  → find_unit()
    → manager_load_unit_from_dbus_path()
      → unit_name_from_dbus_path()
        → !startswith(path, "/org/freedesktop/systemd1/unit/")
          → return -EINVAL
          ←
        ←
      ←
    ← if (r < 0) return 0
  ← 0
←

i.e. we return 0 when queried for "/org/freedesktop/systemd1/unit".

Fixes #23445.

(cherry picked from commit 4313e2b69f)
2022-05-25 17:04:42 +02:00
Luca Boccassi
7ff8ddd623 portable: reject root directories without an ID field in os-release
We always require at least ID to be set in os-release, reject
and propagate error to the caller instead of asserting later

(cherry picked from commit 7b2e763242)
2022-05-25 17:04:38 +02:00
Luca Boccassi
7970db60f5 dissect: ID from os-release should be non-empty, not just non-NULL
(cherry picked from commit a2cf73f0b6)
2022-05-25 17:04:05 +02:00
Khem Raj
1b83390ff4 Add sys/stat.h for S_IFDIR
Fixes
../git/src/shared/mkdir-label.c:13:61: error: use of undeclared identifier 'S_IFDIR'
        r = mac_selinux_create_file_prepare_at(dirfd, path, S_IFDIR);

Signed-off-by: Khem Raj <raj.khem@gmail.com>
(cherry picked from commit 29b7114c5d)
2022-05-25 17:03:59 +02:00
Daan De Meyer
236c55d1c5 sd-bus: Fix introspect memory leak
We have to free the contents of the set on top of the set itself.

Fixes #23443.

(cherry picked from commit dcb4e45ad8)
2022-05-25 17:03:55 +02:00
Daan De Meyer
2db4bf991e portable: Remove unnecessary assert()
Fixes #23433

matches is plumbed through until it finally gets used in unit_match()
which can deal with NULL matches so the assert() is unnecessary and
can be removed.

The two call sites of extract_image_and_extensions() also don't
assert() on matches either.

(cherry picked from commit 1751d8c80c)
2022-05-25 17:03:45 +02:00
Tomasz Pala
a6f542c0d0 udev: fixed config_parse_ifalias() logic not to skip setting IFLA_IFALIAS
this flaw was introduced in 6a74900002

(cherry picked from commit d1df0466d9)
2022-05-25 17:03:29 +02:00
Yu Watanabe
c87bdab927 networkctl: fix units for bond parameters
Fixes RHBZ#2086166 (https://bugzilla.redhat.com/show_bug.cgi?id=2086166).

(cherry picked from commit 05e022a913)
2022-05-25 17:02:53 +02:00