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

55678 Commits

Author SHA1 Message Date
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
Luca Boccassi
33aba4c50a systemd-stdio-bridge: add manpage
(cherry picked from commit cf18de1b26)
2022-01-18 12:19:30 +01:00
Luca Boccassi
5cc70d1759 man: change 'allow[s] to' -> 'allow[s] one to'
Lintian is opinionated about this and we get nagged

(cherry picked from commit 6eed65d455)
2022-01-18 12:19:20 +01:00
Yu Watanabe
44198d7ddb core: add missing dependency DBus properties
Follow-up for 0bc488c99a.

Also sort dependency properties to make them match the definition of
`enum UnitDependency` in basic/unit-def.h.

Fixes #22133.

(cherry picked from commit adc1b76c30)
2022-01-18 12:19:16 +01:00
Yu Watanabe
9f43dde134 core: update log message
Fixes CID#1469009.

(cherry picked from commit cc8943b84a)
2022-01-18 12:18:46 +01:00
Yu Watanabe
0874eaefa3 network: wireguard: also accept negative boolean values to disable adding routes
RouteTable=off was introduced to provide consistency with wg-quick
command. This makes the RouteTable= settings accepts other negative
boolean values.

(cherry picked from commit e135559d80)
2022-01-18 12:18:02 +01:00
Yu Watanabe
417622f42b network: wireguard: do not add routes to AllowedIPs= by default
As setting such routes may break existing setups.

Closes #21964.

(cherry picked from commit cfe1237f38)
2022-01-18 12:17:57 +01:00
Zbigniew Jędrzejewski-Szmek
18aff8c857 sd-device: silence gcc warning with newest gcc
(cherry picked from commit 376ee2c312)
2022-01-18 12:17:45 +01:00
Daan De Meyer
5b44d30087 journal: Fix entry array iteration corruption checks
Previously, we'd try to handle corruption by bumping the index even
if it was an entry array object that was corrupted (which we can't
deal with).

Now, we only try to deal with corrupted entry objects by moving the
corruption handling into generic_array_get().

On top, we also add an additional check for -EADDRNOTAVAIL which can
also be caused by corrupted journal data.

(cherry picked from commit 8d801e35cb)
2022-01-18 12:17:37 +01:00
Daan De Meyer
ef108015f3 journal: Remove unused arguments from journal_file_next_entry_for_data()
(cherry picked from commit f2eceb5268)
2022-01-18 12:17:32 +01:00
Benjamin Berg
6a6182c3f4 man: Add more details about desktop file processing
In particular, mention the contract the generator has with external
ExecCondition= binaries that may be provided by desktop environments.

But, also mention all the other relevant keys. In particular
X-systemd-skip= is important to be documented.

(cherry picked from commit 048d469999)
2022-01-18 12:16:31 +01:00
Jan Janssen
7f3e962f08 boot: Don't try to free loaded_image
EFI_LOADED_IMAGE is a protocol pointer and thus, we shouldn't try
to free it.

(cherry picked from commit acd28f3912)
2022-01-18 12:15:59 +01:00
Jan Janssen
34e5084c14 boot: Fix invalid free
LocateDevicePath() advances the device path pointer, making it invalid
when freed.

(cherry picked from commit 41b74a18b2)
2022-01-18 12:14:34 +01:00