1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-20 14:03:39 +03:00

60881 Commits

Author SHA1 Message Date
Frantisek Sumsal
14f573175a import: use CURLOPT_PROTOCOLS_STR with libcurl >= 7.85.0
CURLOPT_PROTOCOLS [0] was deprecated in libcurl 7.85.0 with
CURLOPT_PROTOCOLS_STR [1] as a replacement, causing build warnings/errors:

../build/src/import/curl-util.c: In function ‘curl_glue_make’:
../build/src/import/curl-util.c:255:9: error: ‘CURLOPT_PROTOCOLS’ is deprecated: since 7.85.0. Use CURLOPT_PROTOCOLS_STR [-Werror=deprecated-declarations]
  255 |         if (curl_easy_setopt(c, CURLOPT_PROTOCOLS, CURLPROTO_HTTP|CURLPROTO_HTTPS|CURLPROTO_FILE) != CURLE_OK)
      |         ^~
In file included from ../build/src/import/curl-util.h:4,
                 from ../build/src/import/curl-util.c:6:
/usr/include/curl/curl.h:1749:3: note: declared here
 1749 |   CURLOPTDEPRECATED(CURLOPT_PROTOCOLS, CURLOPTTYPE_LONG, 181,
      |   ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Since there's no grace period between the two symbols, let's resort
to a light if-def-ery to resolve this.

[0] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS.html
[1] https://curl.se/libcurl/c/CURLOPT_PROTOCOLS_STR.html

(cherry picked from commit e61a4c0b7c79eabbe4eb50ff2e663734fde769f0)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
4ab37502b3 import: use CURLINFO_SCHEME instead of CURLINFO_PROTOCOL
CURLINFO_PROTOCOL has been deprecated in curl 7.85.0 causing compilation
warnings/errors:

../build/src/import/pull-job.c: In function ‘pull_job_curl_on_finished’:
../build/src/import/pull-job.c:142:9: error: ‘CURLINFO_PROTOCOL’ is deprecated: since 7.85.0. Use CURLINFO_SCHEME [-Werror=deprecated-declarations]
  142 |         code = curl_easy_getinfo(curl, CURLINFO_PROTOCOL, &protocol);
      |         ^~~~
In file included from ../build/src/import/curl-util.h:4,
                 from ../build/src/import/pull-job.h:6,
                 from ../build/src/import/pull-common.h:7,
                 from ../build/src/import/pull-job.c:16:
/usr/include/curl/curl.h:2896:3: note: declared here
 2896 |   CURLINFO_PROTOCOL    CURL_DEPRECATED(7.85.0, "Use CURLINFO_SCHEME")
      |   ^~~~~~~~~~~~~~~~~
cc1: all warnings being treated as errors

Since both CURLINFO_SCHEME and CURLINFO_PROTOCOL were introduced in
the same curl version (7.52.0 [0][1]) we don't have to worry about
backwards compatibility.

[0] https://curl.se/libcurl/c/CURLINFO_SCHEME.html
[1] https://curl.se/libcurl/c/CURLINFO_PROTOCOL.html

(cherry picked from commit 2285c462ebb0b5d9a7043719a4f0d684a5dc37c2)
2023-01-26 09:12:21 +01:00
Lennart Poettering
4dabf90526 nspawn: guard acl_free() with a NULL check
Inspired by #25957 there's one other place where we don't guard
acl_free() calls with a NULL check.

Fix that.

(cherry picked from commit 34680637e838415204850f77c93ca6ca219abaf1)
2023-01-26 09:12:21 +01:00
Sam James
a11a949c43 tmpfiles: avoid null free() for acl attributes
When built with ACL support, we might be processing a tmpfiles
entry where there's no cause for us to call parse_acls_from_arg,
then we get to the end of parse_line without having ever populated
i.{acl_access, acl_default}.

Then we pass a null pointer into acl_free().

From UBSAN w/ GCC 13.0.0_pre20230101:
```
$ systemd-tmpfiles --clean
/var/tmp/portage/sys-apps/acl-2.3.1-r1/work/acl-2.3.1/libacl/acl_free.c:44:14: runtime error: applying non-zero offset 18446744073709551608 to null pointer
    #0 0x7f65d868b482 in acl_free /var/tmp/portage/sys-apps/acl-2.3.1-r1/work/acl-2.3.1/libacl/acl_free.c:44
    #1 0x55fe7e592249 in item_free_contents ../systemd-9999/src/tmpfiles/tmpfiles.c:2855
    #2 0x55fe7e5a347a in parse_line ../systemd-9999/src/tmpfiles/tmpfiles.c:3158
    #3 0x55fe7e5a347a in read_config_file ../systemd-9999/src/tmpfiles/tmpfiles.c:3897
    #4 0x55fe7e590c61 in read_config_files ../systemd-9999/src/tmpfiles/tmpfiles.c:3985
    #5 0x55fe7e590c61 in run ../systemd-9999/src/tmpfiles/tmpfiles.c:4157
    #6 0x55fe7e590c61 in main ../systemd-9999/src/tmpfiles/tmpfiles.c:4218
    #7 0x7f65d7ebe289  (/usr/lib64/libc.so.6+0x23289)
    #8 0x7f65d7ebe344 in __libc_start_main (/usr/lib64/libc.so.6+0x23344)
    #9 0x55fe7e591900 in _start (/usr/bin/systemd-tmpfiles+0x11900)
```

(cherry picked from commit 9f804ab04d566ff745849e1c4ced680a0447cf76)
2023-01-26 09:12:21 +01:00
Lennart Poettering
9769d84fe5 sd-event: don't mistake USEC_INFINITY passed in for overflow
Let's pass USEC_INFINITY from sd_event_source_set_time_relative() to
sd_event_source_set_time() instead of raising EOVERFLOW.

We should raise EOVERFLOW only if your addition fails, but not if the
input already is USEC_INFINITY, since it's an entirely valid operation
to have an infinite time-out, and we should support that.

(cherry picked from commit ef8591951aefccb668201f24aa481aa6cda834da)
2023-01-26 09:12:21 +01:00
Jan Janssen
295bb34f9a bootctl: Fix NULL pointer dereference
Fixes: #25952
(cherry picked from commit 6e689dc6eedea558df3d98da4477d58432d2d29c)
2023-01-26 09:12:21 +01:00
Lennart Poettering
a0532ffd2f resolved: disable SO_BINDTOIFINDEX hack for localhost IP addresses
Fixes: #23010
(cherry picked from commit 5f9041afec65ce88c8b2a2ca3f6d14802ac01a56)
2023-01-26 09:12:21 +01:00
Ludwig Nussel
8ec0142c13 kernel-install: run depmod only if writeable
(cherry picked from commit dd003f1621967f114a6a808bb1f729386dc3a154)
2023-01-26 09:12:21 +01:00
Benjamin Tissoires
e52b71dd0c virt: fix container detection
Commit 1b86c7c59ecc ("virt: make virtualization enum a named type")
made the conversion from `if (!r)` to `if (v != VIRTUALIZATION_NONE)`.

However, the initial test was meaning "if r is null", IOW "if r IS
`VIRTUALIZATION_NONE`).

The test is wrong and this can lead to false detection of the container
environment (when calling `systemctl exit`).

For example, https://gitlab.freedesktop.org/whot/libevdev/-/jobs/34207974
is calling `systemctl exit 0`, and systemd terminates with the exit code
`130`.

Fixing that typo makes `systemctl exit 0` returns `0`.

Fixes: 1b86c7c59ecc26efdf278f5c1c4430346021cd38.
(cherry picked from commit a91078bc57950c9b0c19fd25fb2e802409695304)
2023-01-26 09:12:21 +01:00
Lennart Poettering
c01cdcfb8a resolvectl: remove duplicate ':' from output
The second argument to dump_list() actually ends up in a TABLE_FIELD
cell now, where we implicitly append a ":". Hence drop it from the
strings.

Follow-up for: 37a50123fac050c7ccde4afcf3f37ee77aad012c

(cherry picked from commit ef503f1cec53f654780591adee6e3e223b575f56)
2023-01-26 09:12:21 +01:00
Lennart Poettering
c2deca7e17 efi: skip Read() calls with zero sizes
Let's avoid calling Read() with zero-sized buffer, to avoid needless firmware
quirkiness.

See: #25911
(cherry picked from commit fd1fec534e70891c1fe49779221d93236d8c5ac2)
2023-01-26 09:12:21 +01:00
Lennart Poettering
a3ceaf0f1d resolved: downgrade inability to send varlink reply error message
Previously, if a client disconnected after sending a lookup request but
before waiting for the reply we'd log at LOG_ERR level. That's
confusing, since it's entirely OK for the client to lose interest.

Hence, let's downgrade to debug level.

Fixes: #25892
(cherry picked from commit 40557509be084f27d48bc5fc51286a664b96942e)
2023-01-26 09:12:21 +01:00
Jan Janssen
7374efb0ac Revert "boot: Use EFI_BOOT_MANAGER_POLICY_PROTOCOL to connect console devices"
This reverts commit b99bf5811850afdb2502ba37251c48348da63c82.

It seems that using this protocol on some firmwares to forcibly
initialize console devices may break handles (already opened file
handles and the device handle itself) that we rely on to access the
boot filesystem, making it impossible to load the selected entry.

It might be possible to get a new handle by querying for the device
handle by using its device path after calling into this protocol, but
this is untested. The firmware might also be so buggy that accessing
devices after using this protocol is impossible.

It seems prudent to revert this for now until some reliable way is found
to initialize console devices without introducing huge boot delays. Any
users on firmware where console devices cannot be accessed would have to
rely on disabling fastboot.

Fixes: #25737, #25846
(cherry picked from commit f151abb0e5fa4f820109eb0541bfdcba319d2b92)
2023-01-26 09:12:21 +01:00
Cristian Rodríguez
e78a1489a8 libsystemd-network: FTBS in c2x mode
cannot pass false as argument because function wants a pointer to bool
instead, use NULL instead

(cherry picked from commit 2cc697d7400446a7ea823bc38061501cd85b046a)
2023-01-26 09:12:21 +01:00
Cristian Rodríguez
921bff2f85 basic: Fix incompatible type for arguments errors in C2X
GCC-13 -std=gnu2x FTBS with:

error: incompatible type for argument 3 of ‘_hashmap_free’
(cherry picked from commit a4a1569ff1e9ab62996f8b42dcc14a09f91b5715)
2023-01-26 09:12:21 +01:00
Cristian Rodríguez
ad647734c7 basic: fix hosed return value in skip_session()
../src/basic/cgroup-util.c: In function ‘skip_session’:
../src/basic/cgroup-util.c:1241:32: error: incompatible types when returning type ‘_Bool’ but ‘const char *’ was expected
 1241 |                         return false;

(cherry picked from commit db8e720984269a050a7a78aeb503a7402ef567f7)
2023-01-26 09:12:21 +01:00
Will Fancher
addeb46993 sysroot: Order systemd-fsck-root after systemd-makefs
(cherry picked from commit 0941ccae3cf28d84db87fb9d50cc10750bc1c962)
2023-01-26 09:12:21 +01:00
Lennart Poettering
7603e8653c import-creds: don't try to import VM creds in a container
If we run in a container we shouldn#t try to import creds passed in from
a VMM, as they are not for us, but for the VM itself.

(cherry picked from commit 13b99dccb7617756626f93c102aefff99a964436)
2023-01-26 09:12:21 +01:00
Jacek Migacz
ec82fdc645 resolve: fix enumerator name for DNS search domain
(cherry picked from commit 8b23242989b7048b2a4439068c4804e457bbd7a8)
2023-01-26 09:12:21 +01:00
Michal Sekletar
9357d23429 units: allow systemd-userdbd to change process name
rename_process() requires CAP_SYS_RESOURCE so let's make sure it is in
our permitted set after execve() by adding in to the bounding set.

Previously,
systemd-userdbd.service - User Database Manager
     Loaded: loaded (/usr/lib/systemd/system/systemd-userdbd.service; indirect; preset: disabled)
     Active: active (running) since Mon 2022-12-19 17:07:21 CET; 17min ago
TriggeredBy: ● systemd-userdbd.socket
       Docs: man:systemd-userdbd.service(8)
   Main PID: 1880 (systemd-userdbd)
     Status: "Processing requests..."
      Tasks: 4 (limit: 2272)
     Memory: 5.2M
        CPU: 244ms
     CGroup: /system.slice/systemd-userdbd.service
             ├─1880 /usr/lib/systemd/systemd-userdbd
             ├─2270 systemd-userwork
             ├─2271 systemd-userwork
             └─2272 systemd-userwork

Now,
    Loaded: loaded (/usr/lib/systemd/system/systemd-userdbd.service; indirect; preset: disabled)
     Active: active (running) since Mon 2022-12-19 17:27:02 CET; 15s ago
TriggeredBy: ● systemd-userdbd.socket
       Docs: man:systemd-userdbd.service(8)
   Main PID: 2404 (systemd-userdbd)
     Status: "Processing requests..."
      Tasks: 4 (limit: 2272)
     Memory: 5.5M
        CPU: 89ms
     CGroup: /system.slice/systemd-userdbd.service
             ├─2404 /usr/lib/systemd/systemd-userdbd
             ├─2407 "systemd-userwork: waiting..."
             ├─2408 "systemd-userwork: waiting..."
             └─2409 "systemd-userwork: waiting..."

(cherry picked from commit d5e5bc2fe9eaa4697c22b84007f18bda29756573)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
54c840ea58 sd-event: never pass negative errnos as signalfd to signalfd
We treat any negative value as "invalid fd", but signalfd only
accepts -1.

(cherry picked from commit cbff793ffb280d9d11e5d7b1dc3964276491bee8)
2023-01-26 09:12:21 +01:00
Yu Watanabe
06edecb4f5 test: show and check almost all journal entries since the relevant command being invoked
For some reasons, journal timestamps from other sources sometimes
inconsistent. For example,
```
$ journalctl --file system.journal -o short-monotonic -u resmontest.service
[ 1112.168109] ns1.unsigned.test resolvectl[419]: → Q: ns1.unsigned.test IN AAAA
[ 1112.168109] ns1.unsigned.test resolvectl[419]: ← S: success
[ 1112.168109] ns1.unsigned.test resolvectl[419]: → Q: ns1.unsigned.test IN A
[ 1112.168109] ns1.unsigned.test resolvectl[419]: ← S: success
[ 1112.168109] ns1.unsigned.test resolvectl[419]: ← A: ns1.unsigned.test IN A 10.0.0.1
[ 1112.171961] ns1.unsigned.test systemd[1]: resmontest.service: Failed to load configuration: No such file or directory
[ 1112.172223] ns1.unsigned.test systemd[1]: resmontest.service: Trying to enqueue job resmontest.service/start/fail
[ 1112.179866] ns1.unsigned.test systemd[1]: resmontest.service: Installed new job resmontest.service/start as 312
[ 1112.179894] ns1.unsigned.test systemd[1]: resmontest.service: Enqueued job resmontest.service/start as 312
[ 1112.180389] ns1.unsigned.test systemd[1]: resmontest.service: Will spawn child (service_enter_start): /usr/bin/resolvectl
[ 1112.180418] ns1.unsigned.test systemd[1]: resmontest.service: Passing 0 fds to service
[ 1112.180447] ns1.unsigned.test systemd[1]: resmontest.service: About to execute /usr/bin/resolvectl monitor
[ 1112.180477] ns1.unsigned.test systemd[1]: resmontest.service: Forked /usr/bin/resolvectl as 419
[ 1112.180619] ns1.unsigned.test systemd[1]: resmontest.service: Changed dead -> start
[ 1112.180651] ns1.unsigned.test systemd[1]: Starting resmontest.service...
[ 1112.180799] ns1.unsigned.test systemd[419]: resmontest.service: Kernel keyring access prohibited, ignoring.
[ 1112.180895] ns1.unsigned.test systemd[419]: resmontest.service: Executing: /usr/bin/resolvectl monitor
[ 1112.181383] ns1.unsigned.test systemd[1]: resmontest.service: Got notification message from PID 419 (READY=1)
[ 1112.181413] ns1.unsigned.test systemd[1]: resmontest.service: Changed start -> running
[ 1112.181441] ns1.unsigned.test systemd[1]: resmontest.service: Job 312 resmontest.service/start finished, result=done
[ 1112.181469] ns1.unsigned.test systemd[1]: Started resmontest.service.
```
In such case, `journalctl -f` may not show the entries what we are interested in.

Fixes #25749. (At least, workarond for the issue.)

(cherry picked from commit ad48ff12bd0f7b19dc6bfa33c96221fd9c22e89c)
2023-01-26 09:12:21 +01:00
Yu Watanabe
cb6a5a7cd1 test: suppress echo in monitor_check_rr()
(cherry picked from commit ef09861a0b0aa7c6a948f4e008e2fea312bc68d6)
2023-01-26 09:12:21 +01:00
David Tardon
a0ac79bce9 swap: tell swapon to reinitialize swap if needed
If the page size of a swap space doesn't match the page size of the
currently running kernel, swapon will fail. Let's instruct it to
reinitialize the swap space instead.

(cherry picked from commit cc137d53e36da5e57b060be5e621864f572b2cac)
2023-01-26 09:12:21 +01:00
Peter Cai
892cb01c2b cryptsetup-fido2: Try all FIDO2 key slots when opening LUKS volume
After #25268, it is now possible to check whether a credential
is present on a FIDO2 token without actually attempting to retrieve said
credential. However, when cryptsetup plugins are not enabled, the
fallback unlock routines are not able to make multiple attempts with
multiple different FIDO2 key slots.

Instead of looking for one FIDO2 key slot when trying to unlock, we now
attempt to use all key slots applicable.

Fixes #19208.

(cherry picked from commit e6319a102e5b6f7c1588ca851d66db7c3ade1665)
2023-01-26 09:12:21 +01:00
Yu Watanabe
a8dd94e0cc test: name_assign_type sysattr never exists for enumerated devices
As we filtered out network devices in the test.

(cherry picked from commit 733529d81227ca713de2d6be77939e3bfedb926f)
2023-01-26 09:12:21 +01:00
jcg
613994c10b mount-setup: don't need to mount /sys/fs/pstore if there is no ENABLE_PSTORE
(cherry picked from commit 5e5fce3e918ebba5d0cbf0b64bb97f0eaeae70a3)
2023-01-26 09:12:21 +01:00
Franck Bui
a9e5d353f4 localed: reload PID1 configuration after modifying /etc/locale.conf
Since commit 1ad6e8b302e87b6891a2bfc35ad397b0afe3d940, unsetting an environment
variable means restoring it to its default value.

However this doesn't work well when localed updates locale.conf. Indeed when a
variable is removed from that file, localed calls "UnsetAndSetEnvironment"
method which restores the default values of the unset variables obtained by
PID1 when it first read locale.conf. But since locale.conf has been updated,
these default values might be outdated and localed needs to instruct PID1 to
read locale.conf again.

Reloading PID1 configuration is quite an heavy operation for this purpose but
there's no other way unless we change again the meaning of "UnsetEnvironment"
or we introduce a new method that really unset an env variable.

That said given the fact that localed modifies locale.conf, it should have an
effect on PID1 default environment rather than on the environment explicitly
set by the user (m->client_manager).

(cherry picked from commit c8966e812e6dcbec95814e6e9c2ed2b351e269ac)
2023-01-26 09:12:21 +01:00
msizanoen1
ded0502aa6 core/sleep: set timeout for freeze/thaw operation to 1.5 seconds
A FreezeUnit operation can hang due to the presence of kernel threads
(see last 2 commits). Keeping the default configuration will mean the
system will hang for 25 seconds in suspend waiting for the response. 1.5
seconds should be sufficient for most cases.

(cherry picked from commit 432a32117506657186e16bd8e0642bbb30326bc4)
2023-01-26 09:12:21 +01:00
Frantisek Sumsal
f730b0aa16 test: wait for the monitoring service to become active
Otherwise we might start querying resolved too early, causing the
monitoring service to miss stuff:

```
[ 1103.149474] testsuite-75.sh[35]: + systemd-run -u resmontest.service -p Type=notify resolvectl monitor
[ 1103.353803] testsuite-75.sh[423]: Running as unit: resmontest.service
[ 1103.353989] testsuite-75.sh[35]: + knotc zone-begin test.
[ 1103.354160] testsuite-75.sh[425]: OK
...
[ 1103.355298] testsuite-75.sh[35]: + knotc reload
[ 1103.355363] testsuite-75.sh[438]: Reloaded
[ 1103.355536] testsuite-75.sh[35]: + : '--- nss-resolve/nss-myhostname tests'
[ 1103.355536] testsuite-75.sh[35]: + run getent -s resolve hosts ns1.unsigned.test
[ 1103.356127] testsuite-75.sh[443]: + getent -s resolve hosts ns1.unsigned.test
[ 1103.356505] testsuite-75.sh[444]: + tee /tmp/tmp.bXg5Uj5Jkk
[ 1103.359591] resolvectl[424]: → Q: ns1.unsigned.test IN AAAA
[ 1103.359591] resolvectl[424]: ← S: success
[ 1103.359850] testsuite-75.sh[444]: 10.0.0.1        ns1.unsigned.test
[ 1103.359939] resolvectl[424]: → Q: ns1.unsigned.test IN A
[ 1103.359939] resolvectl[424]: ← S: success
[ 1103.359939] resolvectl[424]: ← A: ns1.unsigned.test IN A 10.0.0.1
[ 1103.360149] testsuite-75.sh[35]: + grep -qE '^10\.0\.0\.1\s+ns1\.unsigned\.test' /tmp/tmp.bXg5Uj5Jkk
[ 1103.362119] systemd[1]: Starting resmontest.service...
[ 1103.362633] systemd[1]: Started resmontest.service.
[ 1103.363263] testsuite-75.sh[35]: + monitor_check_rr 'ns1.unsigned.test IN A 10.0.0.1'
[ 1103.363263] testsuite-75.sh[35]: + local 'match=ns1.unsigned.test IN A 10.0.0.1'
[ 1103.363377] testsuite-75.sh[35]: + set +o pipefail
[ 1103.363836] testsuite-75.sh[458]: + journalctl -u resmontest.service -f --full
[ 1103.364042] testsuite-75.sh[459]: + grep -m1 'ns1.unsigned.test IN A 10.0.0.1'
...
Trying to halt container. Send SIGTERM again to trigger immediate termination.
Container TEST-75 terminated by signal KILL.
```

(cherry picked from commit 5dd34c2604567320707625bc009cf01c3769605f)
2023-01-26 09:12:21 +01:00
msizanoen1
2eb040f36f core/slice: skip member units without realized cgroup during freeze or thaw
This ensures that services with `RemainAfterExit` but without any
process running won't cause failure during freeze.

(cherry picked from commit fcb0878f7563df9701a4d066378995c0b7ec32be)
2023-01-26 09:12:21 +01:00
Yu Watanabe
3cc124a513 test-network: try to change MAC address more
Follow-up for 23b6bf274fc1a46d8778bfc979d3c803d61a1f5c.

(cherry picked from commit b448fc0a6f6752ef2faa3907422e0034d5e6d8a3)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
306aa6caa1 TEST-65: use [[ -v ]] more
It's a bashism, but we use other bash features anyway, and it's cleaner
and much less verbose.

(cherry picked from commit 1f9caf28cafbec89b93b8e6b641d387ac5acdd24)
2023-01-26 09:12:21 +01:00
Zbigniew Jędrzejewski-Szmek
1f1d7b0b3f TEST-65: check cat-config operation in chroot
This verifies the fix in 2075b6dd394e09a0f203b9cc7e3253908397f933.

(cherry picked from commit a7eed3eca3d7bc022d870258deb2f738b9527c6d)
2023-01-26 09:12:21 +01:00
Yu Watanabe
d7a464e56d boot: fix false maybe-uninitialized warning
Fixes #25641.

(cherry picked from commit febe556191c739fb79a22cf742dd447c75e90446)
2023-01-26 09:12:21 +01:00
Franck Bui
83b20d0f32 test: update TEST-73-LOCALE to define several locale settings in initial PID1 environment
(cherry picked from commit b1afa5a67bacd36a5a359f07c761eb1a5cfcf129)
2023-01-26 09:12:21 +01:00
Florian Klink
d7aa93ab2e fuzzing: add OOMPolicy= to directive corpus 2023-01-23 11:51:17 +01:00
Zbigniew Jędrzejewski-Szmek
5183d46ba1 core,man: add missing integration of OOMPolicy= in scopes
Fixup for 5fa098357e0ea9f05b00ed5b04a36ef9f64037db.

(cherry picked from commit d5a1657d5a78e9a101fa91e60921bed54ec162b8)
2023-01-23 11:51:12 +01:00
Mark Laws
0db0562852 systemd: Default to OOMPolicy=continue for login session scopes
If the kernel OOM kills a process under a login session scope, we don't want to
kill the user's other processes for no good reason.

(cherry picked from commit 98b6c94b577205d31b019286c2a84cc9af244ea0)
2023-01-23 11:51:12 +01:00
Mark Laws
d539e18777 systemd: Support OOMPolicy in scope units
Closes #25376.

(cherry picked from commit 5fa098357e0ea9f05b00ed5b04a36ef9f64037db)
2023-01-23 11:51:12 +01:00
Siddhesh Poyarekar
e998c9d7c1 alloc-util: Disallow inlining of expand_to_usable
Explicitly set __attribute__ ((noinline)) so that the compiler does not
attempt to inline expand_to_usable, even with LTO.

(cherry picked from commit 4f79f545b3c46c358666c9f5f2b384fe50aac4b4)
2023-01-22 22:29:53 +01:00
Siddhesh Poyarekar
34b9eddfc1 Use dummy allocator to make accesses defined as per standard
systemd uses malloc_usable_size() everywhere to use memory blocks
obtained through malloc, but that is abuse since the
malloc_usable_size() interface isn't meant for this kind of use, it is
for diagnostics only.  This is also why systemd behaviour is flaky when
built with _FORTIFY_SOURCE.

One way to make this more standard (and hence safer) is to, at every
malloc_usable_size() call, also 'reallocate' the block so that the
compiler can see the larger size.  This is done through a dummy
reallocator whose only purpose is to tell the compiler about the larger
usable size, it doesn't do any actual reallocation.

Florian Weimer pointed out that this doesn't solve the problem of an
allocator potentially growing usable size at will, which will break the
implicit assumption in systemd use that the value returned remains
constant as long as the object is valid.  The safest way to fix that is
for systemd to step away from using malloc_usable_size() like this.

Resolves #22801.

(cherry picked from commit 7929e180aa47a2692ad4f053afac2857d7198758)
2023-01-22 22:29:49 +01:00
Cristian Rodríguez
ba5f7915d2 resolve: dns_server_feature_level_*_string type is DnsServerFeatureLevel
gcc 13 -Wenum-int-mismatch reminds us that enum != int

(cherry picked from commit e14afe31c3e8380496dc85b57103b2f648bc7d43)
2023-01-22 22:26:32 +01:00
Cristian Rodríguez
b1b7667a44 journal-remote: code is of type enum MHD_RequestTerminationCode
Fixes gcc 13 -Wenum-int-mismatch which are enabled by default.

(cherry picked from commit aa70dd624bff6280ab6f2871f62d313bdb1e1bcc)
2023-01-22 21:54:14 +01:00
Cristian Rodríguez
2fdd12acd5 shared|install: Use InstallChangeType consistently
gcc 13 -Wenum-int-mismatch, enabled by default, reminds us enum ! = int

(cherry picked from commit 9264db1a0ac6034ab5b40ef3f5914d8dc7d77aba)
2023-01-22 21:49:28 +01:00
Yu Watanabe
4b48117716 core/unit: fix log message
As you can see in the below, the dropped dependency Before=issue-24990.service
is not logged, but the dependency Before=test1.service which is not owned by
the units generated by the TEST-26 is logged.

Before:
systemd[1]: issue-24990.service: Dependency After=test1.service dropped, merged into issue-24990.service
systemd[1]: issue-24990.service: Dependency Before=test1.service dropped, merged into issue-24990.service

After:
systemd[1]: issue-24990.service: Dependency After=test1.service is dropped, as test1.service is merged into issue-24990.service.
systemd[1]: issue-24990.service: Dependency Before=issue-24990.service in test1.service is dropped, as test1.service is merged into issue-24990.service.

(cherry picked from commit ed9911630e4bca844381d7caeb850dad9a9fa122)
v252.4
2022-12-20 19:15:44 +01:00
Yu Watanabe
773ca69b62 core/unit: merge unit names after merging deps
Before:
systemd[1]: issue-24990.service: Dependency Before=n/a dropped, merged into issue-24990.service
After:
systemd[1]: issue-24990.service: Dependency Before=test1.service dropped, merged into issue-24990.service

(cherry picked from commit 1d0c81a05b1605a5fc3db44d5a157a1d6876eda9)
2022-12-20 19:15:44 +01:00
Yu Watanabe
e579554dfa test: add test case for sysv-generator and invalid dependency
(cherry picked from commit 5f882cc3ab32636d9242effb2cefad20d92d2ec2)
2022-12-20 19:15:44 +01:00
Yu Watanabe
63e6a653e3 core/unit: merge two loops into one
No functional change, just refactoring.

(cherry picked from commit 4b7918a65cc2571a2b3fc166229e1b8db463e217)
2022-12-20 19:15:44 +01:00
Yu Watanabe
30a545965b core/unit: fix logic of dropping self-referencing dependencies
Fixes a bug in 15ed3c3a188cf7fa5a60ae508fc7a3ed048d2220.

(cherry picked from commit 53e0e6ef0eea396bb432cbfc1f2f6ea1272ff1f1)
2022-12-20 19:15:44 +01:00