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

55490 Commits

Author SHA1 Message Date
Luca Boccassi
44c4116557 test: use mksquashfs -noappend
Makes the setup idempotent, as mksquashfs by default attempts to
append to an existing image

(cherry picked from commit 392d46d7a8)
2022-02-14 22:01:13 +00:00
Luca Boccassi
7784d3dde0 test: rename service used in TEST-29-PORTABLE to avoid conflict
There's an app0.service in the extension app0.raw, so don't use the same
name for a unit in minimal.raw

(cherry picked from commit d76f0de746)
2022-02-14 22:01:13 +00:00
Thomas Haller
74dfb51f70 sd-dhcp6-client: fix sending prefix delegation request during rebind
Fixes an assertion failure "pd->type == SD_DHCP6_OPTION_IA_PD" in dhcp6_option_append_pd().

Something similar was done in commit 26a63b8132 ('sd-dhcp6-client: Fix
sending prefix delegation request (#17136)'). The justification is
probably the same.

(cherry picked from commit 58da18251f)
2022-02-14 22:00:56 +00:00
Yu Watanabe
3a125c762f test: add a test for mkdir_p()
(cherry picked from commit 6f6b017b9b)

Conflicts:
	src/test/meson.build
2022-02-14 22:00:21 +00:00
Yu Watanabe
df59c65a23 mkdir: allow to create directory whose path contains symlink
Fixes a regression caused by 3008a6f21c.

Before the commit, when `mkdir_parents_internal()` is called from `mkdir_p()`,
it uses `_mkdir()` as `flag` is zero. But after the commit, `mkdir_safe_internal()`
is always used. Hence, if the path contains a symlink, it fails with -ENOTDIR.

To fix the issue, this makes `mkdir_p()` calls `mkdir_parents_internal()` with
MKDIR_FOLLOW_SYMLINK flag.

Fixes #22334.

(cherry picked from commit 5117059ee9)
2022-02-14 21:58:58 +00:00
Yu Watanabe
5e672ed8fc mkdir: CHASE_NONEXISTENT cannot used in chase_symlinks_and_stat()
(cherry picked from commit e22916e61d)
2022-02-14 21:58:58 +00:00
Yu Watanabe
1d7e0b6804 core/mount: fail early if directory cannot be created
Prompted by #22334.

(cherry picked from commit e4de58c823)
2022-02-14 21:58:58 +00:00
Lennart Poettering
9793254248 units: we need systemd-journald.service from systemd-journal-flush.service
This is a follow-up for d5ee050ffc, and
reintroduces a requirement dep from systemd-journal-flush.service onto
systemd-journald.service, but a weaker one than originally: a Wants= one
instead of a Requires= one.

Why? Simply because the service issues an IPC call to the journald,
hence it should pull it in. (Note that socket activation doesn't happen
for the Varlink socket it uses, hence we should pull in the service
itself.)

(cherry picked from commit 23b1e8d087)
2022-02-14 21:58:39 +00:00
Yu Watanabe
ae95ca27be sd-dhcp-lease: fix memleak
Fixes https://github.com/systemd/systemd/pull/22294#issuecomment-1024840811.

(cherry picked from commit 06cf04dff4)
2022-02-14 21:58:27 +00:00
Yu Watanabe
2b04d3b3fc sd-dhcp-lease: fix reading unaligned memory
The destination address was read twice, one is for prefixlen, and
other is for destination address itself. And for prefixlen, the address
might be read from unaligned buffer.

This also modernizes the code.

(cherry picked from commit 7b86854307)
2022-02-14 21:58:27 +00:00
Yu Watanabe
a5fc827b3a test-network: set xfrm interface ID
This also unifies two tests for xfrm, and checks the output of
'ip link' command.

Fixes #22329.

(cherry picked from commit 020483b248)
2022-02-14 21:58:16 +00:00
Yu Watanabe
1ef56ad928 network: xfrm: refuse zero interface ID
Since kernel 5.17-rc1, 5.16.3, and 5.15.17 (more specifically,
8dce439195)
the kernel refuses to create an xfrm interface with zero ID.

(cherry picked from commit fd11005951)
2022-02-14 21:58:16 +00:00
Lennart Poettering
c4357f31da execute: document that the 'env' param is input *and* output
(cherry picked from commit 421bb42d1b)
2022-02-14 21:58:04 +00:00
Lennart Poettering
14567dc93d execute: line break comments a bit less aggressively
(cherry picked from commit cafc5ca147)
2022-02-14 21:58:04 +00:00
Lennart Poettering
9b2954b794 execute: use _cleanup_ logic where appropriate
(cherry picked from commit 46e5bbab58)
2022-02-14 21:58:04 +00:00
Lennart Poettering
9c560d2015 pid1: pass PAM_DATA_SILENT to pam_end() in child
Fixes: #22318
(cherry picked from commit 7feb2b5737)
2022-02-14 21:58:04 +00:00
Yu Watanabe
048487c094 login: use bus_error_message() at one more place
(cherry picked from commit 80c8c786a3)
2022-02-14 21:56:48 +00:00
Yu Watanabe
81e5941116 core/unit: use bus_error_message() at one more place
(cherry picked from commit 3332218555)
2022-02-14 21:56:48 +00:00
Yu Watanabe
b9e144629b bus-util: retrieve bus error from message
The error in argument is not input, but used for output.

(cherry picked from commit 853b94863c)
2022-02-14 21:56:48 +00:00
Daan De Meyer
47da2d8e29 boot: Don't require a machine ID to be available
Regression introduced in https://github.com/systemd/systemd/pull/21807.

Fixes #22224

(cherry picked from commit 17e2e8073f)
2022-02-14 21:56:48 +00:00
Luca Boccassi
ae8bc570a8 core: don't fail on EEXIST when creating mount point
systemd[1016]: Failed to mount /tmp/app1 (type n/a) on /run/systemd/unit-extensions/1 (MS_BIND ): No such file or directory
systemd[1016]: Failed to create destination mount point node '/run/systemd/unit-extensions/1': File exists

(cherry picked from commit 9d6d4c305a)
2022-02-14 21:56:48 +00:00
Frantisek Sumsal
e697fa6007 basic: update CIFS magic
Kernel commit dea2903719283c156b53741126228c4a1b40440f exposed (and
renamed) CIFS_MAGIC_NUMBER as CIFS_SUPER_MAGIC along with
SMB2_SUPER_MAGIC.

This fixes the following build fail on current Fedora Rawhide:
```
../src/basic/meson.build:389:8: ERROR: Problem encountered: found unknown filesystem(s) defined in kernel headers:

Filesystem found in kernel header but not in filesystems-gperf.gperf: CIFS_SUPER_MAGIC
Filesystem found in kernel header but not in filesystems-gperf.gperf: SMB2_SUPER_MAGIC
```

(cherry picked from commit bbe5371345)
2022-02-14 21:56:48 +00:00
Evgeny Vereshchagin
7dc0f80588 sd-dhcp-lease: fix a memory leak in dhcp_lease_parse_search_domains
=================================================================
==81071==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 16 byte(s) in 1 object(s) allocated from:
    #0 0x51245c in __interceptor_reallocarray (/home/vagrant/systemd/build/fuzz-dhcp-client+0x51245c)
    #1 0x7f01440c67e6 in strv_push /home/vagrant/systemd/build/../src/basic/strv.c:435:13
    #2 0x7f01440ca9e1 in strv_consume /home/vagrant/systemd/build/../src/basic/strv.c:506:13
    #3 0x7f01440ca9e1 in strv_extend /home/vagrant/systemd/build/../src/basic/strv.c:558:16
    #4 0x5806e3 in dhcp_lease_parse_search_domains /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:900:21
    #5 0x57c1be in dhcp_lease_parse_options /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-lease.c:727:21
    #6 0x572450 in parse_options /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:348:33
    #7 0x571c6a in dhcp_option_parse /home/vagrant/systemd/build/../src/libsystemd-network/dhcp-option.c:376:13
    #8 0x559a01 in client_handle_offer /home/vagrant/systemd/build/../src/libsystemd-network/sd-dhcp-client.c:1543:13
    #9 0x5592bd in LLVMFuzzerTestOneInput /home/vagrant/systemd/build/../src/libsystemd-network/fuzz-dhcp-client.c:74:16
    #10 0x44a379 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x44a379)
    #11 0x42ae1f in fuzzer::RunOneTest(fuzzer::Fuzzer*, char const*, unsigned long) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x42ae1f)
    #12 0x432ade in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) (/home/vagrant/systemd/build/fuzz-dhcp-client+0x432ade)
    #13 0x421f86 in main (/home/vagrant/systemd/build/fuzz-dhcp-client+0x421f86)
    #14 0x7f0142fff55f in __libc_start_call_main (/lib64/libc.so.6+0x2d55f)

(cherry picked from commit 9591c0a8b3)
2022-02-14 21:56:48 +00:00
Evgeny Vereshchagin
ba335f6f40 tests: add a file triggering a memory leak in dhcp_lease_parse_search_domains
(cherry picked from commit 998ec39b1d)
2022-02-14 21:56:48 +00:00
Evgeny Vereshchagin
426807c54b sd-dhcp-lease: fix an infinite loop found by the fuzzer
(cherry picked from commit 86b06c666b)
2022-02-14 21:56:48 +00:00
Donald Chan
9f596964f6 basic: mac_[selinux,smack]_apply_fd does not work when applying labels
Commit a7fdc6c introduced a regression where file descriptors are opened
using O_PATH option. mac_smack_apply_fd() calls fsetxattr() and would fail
with a -EBADF (Bad file descriptor) error.

Use FORMAT_PROC_FD_PATH(fd) to convert the fd back into a full path and
call setxattr() or setfilecon() instead.

Signed-off-by: Donald Chan <hoiho@amazon.com>
(cherry picked from commit a718364e9d)
2022-02-14 21:56:48 +00:00
Yu Watanabe
530a18d493 sd-dhcp-server: refuse too large packet to send
Fixes https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=44134.

(cherry picked from commit 71df50a973)
2022-02-14 21:56:48 +00:00
Arfrever Frehtes Taifersar Arahesis
5b20a2b19c logind.conf: Fix name of option: RuntimeDirectoryInodes -> RuntimeDirectoryInodesMax
(cherry picked from commit a42a93830f)
2022-02-14 21:56:48 +00:00
Christian Brauner
09936a7ec9 core/namespace: s/normalize_mounts()/drop_unused_mounts()
Rename the normalize_mounts() helper to drop_unused_mounts. All the
helpers called in there get rid of mounts that are unused for a variety
of reasons. And whereas the helpers are aptly prefixed with "drop" the
overall helper isn't and instead uses "normalize".

Make it more obvious what the helper actually does by renaming it from
normalize_mounts() to drop_unused_mounts(). Readers of code calling this
helper will immediately see that it will get rid of unused mounts.

Link: https://github.com/systemd/systemd/issues/22206
(cherry picked from commit fbf90c0d5c)
2022-02-14 21:56:48 +00:00
Christian Brauner
a727941aff core/namespace: allow using ProtectSubset=pid and ProtectHostname=true together
If a service requests both ProtectSubset=pid and ProtectHostname=true
then it will currently fail to start. The ProcSubset=pid option
instructs systemd to mount procfs for the service with subset=pid which
hides all entries other than /proc/<pid>. Consequently trying to
interact with the two files /proc/sys/kernel/{hostname,domainname}
covered by ProtectHostname=true will fail.

Fix this by only performing this check when ProtectSubset=pid is not
requested. Essentially ProtectSubset=pid implies/provides
ProtectHostname=true.

(cherry picked from commit 1361f01577)
2022-02-14 21:56:48 +00:00
Thomas Haller
a060a16c70 sd-event: workaround maybe-uninitalized warning in sd_event_add_inotify()
With LTO, the compiler might think that the variable is uninitialized
(from NetworkManager's fork, with gcc-11.2.1-1.fc35):

    src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c: In function 'sd_event_add_inotify':
    src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c:2120: error: 's' may be used uninitialized in this function [-Werror=maybe-uninitialized]
     2120 |                 *ret = s;
          |
    src/libnm-systemd-core/src/libsystemd/sd-event/sd-event.c:2102: note: 's' was declared here
     2102 |         sd_event_source *s;
          |
    lto1: all warnings being treated as errors

In particular, that would happen for codepaths where event_add_inotify_fd_internal()
returns `-errno`, and the compiler cannot be sure that the returned value will
be negative. Technically, the compiler is right, but we rely on libc functions
to set errno correctly, so this only happens in code paths, where something
bad already happend.

While LTO is prone to such false warnings, we are largely able to build systemd
without warnings. So it is feasible and we should make the effort of working
around warnings as they appear.

(cherry picked from commit 2091c77931)
2022-02-14 21:56:48 +00:00
YmrDtnJu
88c8a48dfd Fix journald audit logging with fields > N_IOVEC_AUDIT_FIELDS.
ELEMENTSOF(iovec) is not the correct value for the newly introduced parameter m
to function map_all_fields because it is the maximum number of elements in the
iovec array, including those reserved for N_IOVEC_META_FIELDS. The correct
value is the current number of already used elements in the array plus the
maximum number to use for fields decoded from the kernel audit message.

(cherry picked from commit df4ec48f45)
2022-02-14 21:56:48 +00:00
Martin Wilck
ef7ceef26a udevadm: cleanup-db: don't delete information for kept db entries
devices with the db_persist property won't be deleted during database
cleanup. This applies to dm and md devices in particular.
For such devices, we should also keep the files under /run/udev/links,
/run/udev/tags, and /run/udev/watch, to make sure that after restart,
udevd has the same information about the devices as it did before
the cleanup.

If we don't do this, a lower-priority device that is discovered in
the coldplug phase may take over symlinks from a device that persisted.
Not removing the watches also enables udevd to resume watching a device
after restart.

Signed-off-by: Martin Wilck <mwilck@suse.com>
(cherry picked from commit 7ec624147a)
2022-02-14 21:56:48 +00:00
Martin Wilck
494e3c0def udevadm: cleanup_dir: use dot_or_dot_dot()
which is safer than just checking dent[0].
Also, fix two style issues.

(cherry picked from commit 28d6e85451)
2022-02-14 21:56:48 +00:00
Anita Zhang
c4d89cd602 oomd: handle situations when no cgroups are killed
Currently if systemd-oomd doesn't kill anything in a selected cgroup, it
selects a new candidate immediately. But if a selected cgroup wasn't killed,
it is likely due to it disappearing or getting cleaned up between the time
it was selected as a candidate and getting sent SIGKILL(s). We should handle
it as though systemd-oomd did perform a kill so that it will check
swap/pressure again before it tries to select a new candidate.

(cherry picked from commit 914d4e99f4)
2022-02-14 21:56:48 +00:00
Anita Zhang
0456e3aaaa oomd: fix race with path unavailability when killing cgroups
There can be a situation where systemd-oomd would kill all of the processes
in a cgroup, pid1 would clean up that cgroup, and systemd-oomd would get
ENODEV trying to iterate the cgroup a final time to ensure it was empty.
systemd-oomd sees this as an error and immediately picks a new candidate even
though pressure may have recovered. To counter this, check and handle
path unavailability errnos specially.

Fixes: #22030
(cherry picked from commit 2ee209466b)
2022-02-14 21:56:48 +00:00
Yu Watanabe
740dd39e07 resolve: fix assertion triggered when r == 0
Fixes #22178.

(cherry picked from commit 98b1eb711c)
2022-02-14 21:56:48 +00:00
Luca Boccassi
179bd47f04 core: refuse to mount ExtensionImages if the base layer doesn't at least have ID in os-release
We can't match an extension if we don't at least have an ID,
so refuse to continue

(cherry picked from commit 78ab2b5064)
2022-02-14 21:56:48 +00:00
Luca Boccassi
0dab9e5f05 dissect-image: validate extension-release even if the host has only ID in os-release
A rolling distro won't set VERSION_ID or SYSEXT_LEVEL in os-release,
which means we skip validation of ExtensionImages.
Validate even with just an ID, the lower level helper already
recognizes and accepts this use case.

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

(cherry picked from commit 37361f46d5)
2022-02-14 21:56:48 +00:00
Luca Boccassi
4ef7122f3c sysext: use LO_FLAGS_PARTSCAN when opening image
Jan 17 12:34:59 myguest1 (sd-sysext)[486]: Device '/var/lib/extensions/myext.raw' is loopback block device with partition scanning turned off, please turn it on.

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

(cherry picked from commit 70a5c6dce0)
2022-02-14 21:56:48 +00:00
Yu Watanabe
1baffb6080 network: dhcp6: do not request address if UseAddress=no
Fixes #22068.

(cherry picked from commit d5f8fd5b00)
2022-02-14 21:56:48 +00:00
Jan Janssen
86cb29e9f6 boot: Only build with debug symbols in developer mode
The debug symbols are of very limited use in proper deployments
unlike with regular userspace. Unless someone goes through the pain
of setting up an EFI debugger (assuming their firmware even supports
this in the first place) any provided debug symbols will just be
useless.
Debugging under QEMU is possible, but even then it is non-trivial
to set up, so anyone willing to go that far can just build in
developer mode.

Meanwhile, at least x86 firmware tends to refuse binaries that contain
debug symbols. We do strip the files when converted to PE anyway, but
the elf file needs to stay around on other arches as objcopy does not
support PE as input there.

Also, the generated debug symbols seem to be not reproducible when
building with LTO. Whether this is an issue in tooling or our side
is unclear. This works around this issue.

Fixes: #22157
(cherry picked from commit 76fb85316e)
2022-02-14 21:56:32 +00:00
Jan Janssen
c0d79c93cc boot: Use -ffile-prefix-map when present
This should make sure the stub elf binary is reproducible.

Fixes: #22157
(cherry picked from commit 1bc8417cfe)
2022-02-14 21:56:32 +00:00
Jan Janssen
fb7a769260 meson: Use files() for source lists for boot and fundamental
This fixes build reproducibility as otherwise the full path
of the source files ends up in the output binary.

(cherry picked from commit b3c5a7074c)
2022-02-14 21:56:32 +00:00
Jan Janssen
b72a7e85a9 boot: Build BCD parser only on arches supported by Windows
(cherry picked from commit 77fcf28cb8)
2022-02-14 21:56:32 +00:00
Zbigniew Jędrzejewski-Szmek
02482cb698 meson: move efi file lists closer to where they are used
The goal is to have the detection of features and paths done first, and
then the build target constructions second.

(cherry picked from commit 65dcf9f9a0)
2022-02-14 21:56:32 +00:00
Yu Watanabe
1b003bbc80 pid1,cgroup-show: ignore -EOPNOTSUPP in cg_read_pid()
The function is called in recursion, and cgroup.procs in some subcgroups
may not be read.

Fixes #22089.

(cherry picked from commit 1fb50408ce)
2022-01-18 12:35:43 +01:00
Zbigniew Jędrzejewski-Szmek
7fc41274e6 stdio-bridge: make the error more straightforward
(cherry picked from commit a80f17844e)
2022-01-18 12:19:47 +01:00
Yu Watanabe
fdcb1bf673 kernel-install: also remove modules.builtin.alias.bin
Fixes RHBZ#2016630.

(cherry picked from commit 06006691b5)
2022-01-18 12:19:42 +01:00
Zbigniew Jędrzejewski-Szmek
8c4badc445 man: enhance the description of systemd-stdio-bridge
I hope that this fixes the comment
https://github.com/systemd/systemd/pull/22141#issuecomment-1013960371
> As someone who doesn't know what this prog does

The listing in the man page is sorted according to logical
use: all the options setting the address are now together.

(cherry picked from commit b7bb58ef70)
2022-01-18 12:19:38 +01:00