1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2025-01-22 22:03:43 +03:00

62782 Commits

Author SHA1 Message Date
Zbigniew Jędrzejewski-Szmek
cb6641bde3 man: explain allowed values for /sys/power/{disk,state}
Also fix the grammar: "neither" can only be used with two values, and
here we have an inderminate number >= 1.

Fixes #26460.

(cherry picked from commit 2f76f1cfaee2f775df8b367cb77aed751af45956)
2023-06-01 16:37:09 +02:00
Zbigniew Jędrzejewski-Szmek
65bf6c5a8f man: say that ProtectClock= also affects reads
Fixes #26413: the docs said that the filter prevents writes, but it just a
filter at the system call level, and some of those calls are used for writing
and reading. This is confusing esp. when a higher level library call like
ntp_gettime() is denied.

I don't think it's realistic that we'll make the filter smarter in the near
future, so let's change the docs to describe the implementation.

Also, split out the advice part into a separate paragraph.

(cherry picked from commit 42eccfec6e47a5436bd143ee357d2a2da620c2f2)
2023-06-01 16:37:09 +02:00
Zbigniew Jędrzejewski-Szmek
13c8807360 man: fixes for assorted issues reported by the manpage-l10n project
Fixes #26761.

(cherry picked from commit 8fb350049bb7a7305589f201df9d37482e544f24)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
1809fff392 nspawn: make sure the device type survives when setting device mode
(cherry picked from commit cd70372b934bded2249f26c72d4b6ab9bdf50a13)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
b8ed81660f nspawn: fix a global-buffer-overflow
Whoopsie.

=================================================================
==3789231==ERROR: AddressSanitizer: global-buffer-overflow on address 0x00000051d0b8 at pc 0x7f70850bc904 bp 0x7ffd9bbdf660 sp 0x7ffd9bbdf658
READ of size 8 at 0x00000051d0b8 thread T0
    #0 0x7f70850bc903 in json_dispatch ../src/shared/json.c:4347
    #1 0x4a5b54 in oci_seccomp_syscalls ../src/nspawn/nspawn-oci.c:1838
    #2 0x7f70850bd359 in json_dispatch ../src/shared/json.c:4395
    #3 0x4a668c in oci_seccomp ../src/nspawn/nspawn-oci.c:1905
    #4 0x7f70850bd359 in json_dispatch ../src/shared/json.c:4395
    #5 0x4a7d8c in oci_linux ../src/nspawn/nspawn-oci.c:2030
    #6 0x7f70850bd359 in json_dispatch ../src/shared/json.c:4395
    #7 0x4aa31c in oci_load ../src/nspawn/nspawn-oci.c:2198
    #8 0x446cec in load_oci_bundle ../src/nspawn/nspawn.c:4744
    #9 0x44ffa7 in run ../src/nspawn/nspawn.c:5477
    #10 0x4552fb in main ../src/nspawn/nspawn.c:5920
    #11 0x7f7083a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #12 0x7f7083a4a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #13 0x40d284 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/systemd-nspawn+0x40d284)

0x00000051d0b8 is located 40 bytes to the left of global variable 'bus_standard_errors_copy_0' defined in '../src/libsystemd/sd-bus/bus-error.h:57:1' (0x51d0e0) of size 8
0x00000051d0b8 is located 0 bytes to the right of global variable 'table' defined in '../src/nspawn/nspawn-oci.c:1829:43' (0x51d040) of size 120
SUMMARY: AddressSanitizer: global-buffer-overflow ../src/shared/json.c:4347 in json_dispatch
Shadow bytes around the buggy address:
  0x00008009b9c0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009b9d0: 00 00 00 00 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x00008009b9e0: 00 00 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
  0x00008009b9f0: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba00: 00 f9 f9 f9 f9 f9 f9 f9 00 00 00 00 00 00 00 00
=>0x00008009ba10: 00 00 00 00 00 00 00[f9]f9 f9 f9 f9 00 f9 f9 f9
  0x00008009ba20: f9 f9 f9 f9 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba30: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba40: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba50: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
  0x00008009ba60: 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00
Shadow byte legend (one shadow byte represents 8 application bytes):
  Addressable:           00
  Partially addressable: 01 02 03 04 05 06 07
  Heap left redzone:       fa
  Freed heap region:       fd
  Stack left redzone:      f1
  Stack mid redzone:       f2
  Stack right redzone:     f3
  Stack after return:      f5
  Stack use after scope:   f8
  Global redzone:          f9
  Global init order:       f6
  Poisoned by user:        f7
  Container overflow:      fc
  Array cookie:            ac
  Intra object redzone:    bb
  ASan internal:           fe
  Left alloca redzone:     ca
  Right alloca redzone:    cb
==3789231==ABORTING

(cherry picked from commit 525c3e3438a7e4cd78b42f5f6ccdc3df1e363ca9)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
756e77b936 nspawn: fix inverted condition
(cherry picked from commit fc832965476d106fb3d5a6c9a43f5ff3166987b2)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
c7861222ba nspawn: call json_dispatch() with a correct pointer
Otherwise hilarity ensues:

 AddressSanitizer:DEADLYSIGNAL
 =================================================================
 ==722==ERROR: AddressSanitizer: SEGV on unknown address 0xffffffff00000000 (pc 0x7f8d50ca9ffb bp 0x7fff11b0d4a0 sp 0x7fff11b0cc30 T0)
 ==722==The signal is caused by a READ memory access.
     #0 0x7f8d50ca9ffb in __interceptor_strcmp.part.0 (/lib64/libasan.so.8+0xa9ffb)
     #1 0x7f8d4f9cf5a1 in strcmp_ptr ../src/fundamental/string-util-fundamental.h:33
     #2 0x7f8d4f9cf5f8 in streq_ptr ../src/fundamental/string-util-fundamental.h:46
     #3 0x7f8d4f9d74d2 in free_and_strdup ../src/basic/string-util.c:948
     #4 0x49139a in free_and_strdup_warn ../src/basic/string-util.h:197
     #5 0x4923eb in oci_absolute_path ../src/nspawn/nspawn-oci.c:139
     #6 0x7f8d4f6bd359 in json_dispatch ../src/shared/json.c:4395
     #7 0x4a8831 in oci_hooks_array ../src/nspawn/nspawn-oci.c:2089
     #8 0x7f8d4f6bd359 in json_dispatch ../src/shared/json.c:4395
     #9 0x4a8b56 in oci_hooks ../src/nspawn/nspawn-oci.c:2112
     #10 0x7f8d4f6bd359 in json_dispatch ../src/shared/json.c:4395
     #11 0x4aa298 in oci_load ../src/nspawn/nspawn-oci.c:2197
     #12 0x446cec in load_oci_bundle ../src/nspawn/nspawn.c:4744
     #13 0x44ffa7 in run ../src/nspawn/nspawn.c:5477
     #14 0x4552fb in main ../src/nspawn/nspawn.c:5920
     #15 0x7f8d4e04a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
     #16 0x7f8d4e04a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
     #17 0x40d284 in _start (/usr/bin/systemd-nspawn+0x40d284)
 AddressSanitizer can not provide additional info.
 SUMMARY: AddressSanitizer: SEGV (/lib64/libasan.so.8+0xa9ffb) in __interceptor_strcmp.part.0
 ==722==ABORTING

(cherry picked from commit f4e5c042c9a5659a5eebb4c91c0f1132f02a2c59)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
6f577f5d92 nspawn: use the just returned errno in the log message
Use the returned errno even though we are going to ignore it, otherwise
the log message is just confusing:

config.json:119:13: Failed to resolve device node 4:2, ignoring: Success

(cherry picked from commit e5c275fedc0ab416730fe288a8754a20a014e200)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
9a7c6ed568 nspawn: avoid NULL pointer dereference
When merging the settings we take the pointer to the array of extra
devices, but don't reset the array counter to zero. This later leads to
a NULL pointer dereference, where device_node_array_free() attempts to
loop over a NULL pointer:

+ systemd-nspawn --oci-bundle=/var/lib/machines/testsuite-13.oci-bundle.Npo
 ../src/nspawn/nspawn-settings.c:118:29: runtime error: member access within null pointer of type 'struct DeviceNode'
     #0 0x4b91ee in device_node_array_free ../src/nspawn/nspawn-settings.c:118
     #1 0x4ba42a in settings_free ../src/nspawn/nspawn-settings.c:161
     #2 0x410b79 in settings_freep ../src/nspawn/nspawn-settings.h:249
     #3 0x446ce8 in load_oci_bundle ../src/nspawn/nspawn.c:4733
     #4 0x44ff42 in run ../src/nspawn/nspawn.c:5476
     #5 0x455296 in main ../src/nspawn/nspawn.c:5919
     #6 0x7f0cb7a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
     #7 0x7f0cb7a4a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
     #8 0x40d284 in _start (/usr/bin/systemd-nspawn+0x40d284)
 SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/nspawn/nspawn-settings.c:118:29 in

Also, add an appropriate assert to catch such issues in the future.

(cherry picked from commit 825210d4e5d52655ff893d600da2d2c8e5c0c8e1)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
17c7b07c67 nspawn: file system namespace -> mount namespace
(cherry picked from commit 3426ec8efb7f075f71768e993dfe8c3c104b68ab)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
b13e836315 nspawn: fix a typo in an error message
(cherry picked from commit 55d3c136d940a5dbed8fd226c988b641f27bf48c)
2023-06-01 16:37:09 +02:00
Lennart Poettering
d88225ef44 busctl: set a description for the bus connection
Unlike most other bus connections in our codebase this one is created
manually and every setting set invididually. It hence does not have a
description by default (as all automatic connections have). Set one
explicitly.

(cherry picked from commit acf493390ac601d90dc4ac188475635a5c327522)
2023-06-01 16:37:09 +02:00
Lennart Poettering
29115ef32e man: indicate that the JOB parameter to "systemctl cancel" is optional
As per:

https://social.treehouse.systems/@grawity/110376583742207755
(cherry picked from commit 7e0aaeb244dafd7a3ff69295b8ea60e827fe2f21)
2023-06-01 16:37:09 +02:00
Yu Watanabe
051f86ae0e meson: fix description for link-udev-shared option
(cherry picked from commit 5571048919cbcc8f4331f589e7590316bc162f9d)
2023-06-01 16:37:09 +02:00
nikstur
85ba46539f man: use correct name for --bank option
(cherry picked from commit 916db27f16a8ef897e5a1de09aa9289143908980)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
d7e75c7315 machine,portable: fix a typo in an info message
(cherry picked from commit 7362947c3f3992cf3660b170f46bd80bb5fe1021)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
4d29f741c8 machine: fix a memory leak when showing multiple machines
+ machinectl status long-running long-running long-running
=================================================================
==986==ERROR: LeakSanitizer: detected memory leaks
Direct leak of 1568 byte(s) in 2 object(s) allocated from:
    #0 0x7fe57caba097 in calloc (/lib64/libasan.so.8+0xba097)
    #1 0x7fe57b891e8e in message_from_header ../src/libsystemd/sd-bus/bus-message.c:372
    #2 0x7fe57b892dfd in bus_message_from_malloc ../src/libsystemd/sd-bus/bus-message.c:421
    #3 0x7fe57b9089a8 in bus_socket_make_message ../src/libsystemd/sd-bus/bus-socket.c:1165
    #4 0x7fe57b90affe in bus_socket_read_message ../src/libsystemd/sd-bus/bus-socket.c:1294
    #5 0x7fe57b92db71 in bus_read_message ../src/libsystemd/sd-bus/sd-bus.c:2082
    #6 0x7fe57b933352 in sd_bus_call ../src/libsystemd/sd-bus/sd-bus.c:2483
    #7 0x7fe57b84da61 in sd_bus_call_methodv ../src/libsystemd/sd-bus/bus-convenience.c:183
    #8 0x7fe57b2789e8 in bus_call_method ../src/shared/bus-locator.c:109
    #9 0x40f71c in show_machine ../src/machine/machinectl.c:713
    #10 0x7fe57b65c8cf in dispatch_verb ../src/shared/verbs.c:103
    #11 0x42e9ce in machinectl_main ../src/machine/machinectl.c:2980
    #12 0x42ebf9 in run ../src/machine/machinectl.c:3005
    #13 0x42ed1f in main ../src/machine/machinectl.c:3008
    #14 0x7fe579e4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
Indirect leak of 234 byte(s) in 2 object(s) allocated from:
    #0 0x7fe57cab95b5 in __interceptor_realloc.part.0 (/lib64/libasan.so.8+0xb95b5)
    #1 0x7fe57b909822 in bus_socket_read_message ../src/libsystemd/sd-bus/bus-socket.c:1214
    #2 0x7fe57b92db71 in bus_read_message ../src/libsystemd/sd-bus/sd-bus.c:2082
    #3 0x7fe57b933352 in sd_bus_call ../src/libsystemd/sd-bus/sd-bus.c:2483
    #4 0x7fe57b84da61 in sd_bus_call_methodv ../src/libsystemd/sd-bus/bus-convenience.c:183
    #5 0x7fe57b2789e8 in bus_call_method ../src/shared/bus-locator.c:109
    #6 0x40f71c in show_machine ../src/machine/machinectl.c:713
    #7 0x7fe57b65c8cf in dispatch_verb ../src/shared/verbs.c:103
    #8 0x42e9ce in machinectl_main ../src/machine/machinectl.c:2980
    #9 0x42ebf9 in run ../src/machine/machinectl.c:3005
    #10 0x42ed1f in main ../src/machine/machinectl.c:3008
    #11 0x7fe579e4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
Indirect leak of 4 byte(s) in 2 object(s) allocated from:
    #0 0x7fe57ca7243b in strdup (/lib64/libasan.so.8+0x7243b)
    #1 0x7fe57b8c1543 in message_parse_fields ../src/libsystemd/sd-bus/bus-message.c:4125
    #2 0x7fe57b893586 in bus_message_from_malloc ../src/libsystemd/sd-bus/bus-message.c:443
    #3 0x7fe57b9089a8 in bus_socket_make_message ../src/libsystemd/sd-bus/bus-socket.c:1165
    #4 0x7fe57b90affe in bus_socket_read_message ../src/libsystemd/sd-bus/bus-socket.c:1294
    #5 0x7fe57b92db71 in bus_read_message ../src/libsystemd/sd-bus/sd-bus.c:2082
    #6 0x7fe57b933352 in sd_bus_call ../src/libsystemd/sd-bus/sd-bus.c:2483
    #7 0x7fe57b84da61 in sd_bus_call_methodv ../src/libsystemd/sd-bus/bus-convenience.c:183
    #8 0x7fe57b2789e8 in bus_call_method ../src/shared/bus-locator.c:109
    #9 0x40f71c in show_machine ../src/machine/machinectl.c:713
    #10 0x7fe57b65c8cf in dispatch_verb ../src/shared/verbs.c:103
    #11 0x42e9ce in machinectl_main ../src/machine/machinectl.c:2980
    #12 0x42ebf9 in run ../src/machine/machinectl.c:3005
    #13 0x42ed1f in main ../src/machine/machinectl.c:3008
    #14 0x7fe579e4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
SUMMARY: AddressSanitizer: 1806 byte(s) leaked in 6 allocation(s).

(cherry picked from commit efdaa92ecb1b358e9f27f7d263bb3383f6ab69c9)
2023-06-01 16:37:09 +02:00
Frantisek Sumsal
e6a719598c machine: fix a memory leak when showing multiple images
+ machinectl image-status container1 container1 container0 container1 container2 container3 container4
 =================================================================
 ==1354==ERROR: LeakSanitizer: detected memory leaks
 Direct leak of 4704 byte(s) in 6 object(s) allocated from:
     #0 0x7fc3670ba097 in calloc (/lib64/libasan.so.8+0xba097)
     #1 0x7fc365e91e8e in message_from_header ../src/libsystemd/sd-bus/bus-message.c:372
     #2 0x7fc365e92dfd in bus_message_from_malloc ../src/libsystemd/sd-bus/bus-message.c:421
     #3 0x7fc365f089a8 in bus_socket_make_message ../src/libsystemd/sd-bus/bus-socket.c:1165
     #4 0x7fc365f0affe in bus_socket_read_message ../src/libsystemd/sd-bus/bus-socket.c:1294
     #5 0x7fc365f2db71 in bus_read_message ../src/libsystemd/sd-bus/sd-bus.c:2082
     #6 0x7fc365f33352 in sd_bus_call ../src/libsystemd/sd-bus/sd-bus.c:2483
     #7 0x7fc365e4da61 in sd_bus_call_methodv ../src/libsystemd/sd-bus/bus-convenience.c:183
     #8 0x7fc3658789e8 in bus_call_method ../src/shared/bus-locator.c:109
     #9 0x413b76 in show_image ../src/machine/machinectl.c:1014
     #10 0x7fc365c5c8cf in dispatch_verb ../src/shared/verbs.c:103
     #11 0x42e992 in machinectl_main ../src/machine/machinectl.c:2981
     #12 0x42ebbd in run ../src/machine/machinectl.c:3006
     #13 0x42ece3 in main ../src/machine/machinectl.c:3009
     #14 0x7fc36444a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
 Indirect leak of 666 byte(s) in 6 object(s) allocated from:
     #0 0x7fc3670b95b5 in __interceptor_realloc.part.0 (/lib64/libasan.so.8+0xb95b5)
     #1 0x7fc365f09822 in bus_socket_read_message ../src/libsystemd/sd-bus/bus-socket.c:1214
     #2 0x7fc365f2db71 in bus_read_message ../src/libsystemd/sd-bus/sd-bus.c:2082
     #3 0x7fc365f33352 in sd_bus_call ../src/libsystemd/sd-bus/sd-bus.c:2483
     #4 0x7fc365e4da61 in sd_bus_call_methodv ../src/libsystemd/sd-bus/bus-convenience.c:183
     #5 0x7fc3658789e8 in bus_call_method ../src/shared/bus-locator.c:109
     #6 0x413b76 in show_image ../src/machine/machinectl.c:1014
     #7 0x7fc365c5c8cf in dispatch_verb ../src/shared/verbs.c:103
     #8 0x42e992 in machinectl_main ../src/machine/machinectl.c:2981
     #9 0x42ebbd in run ../src/machine/machinectl.c:3006
     #10 0x42ece3 in main ../src/machine/machinectl.c:3009
     #11 0x7fc36444a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
 Indirect leak of 12 byte(s) in 6 object(s) allocated from:
     #0 0x7fc36707243b in strdup (/lib64/libasan.so.8+0x7243b)
     #1 0x7fc365ec1543 in message_parse_fields ../src/libsystemd/sd-bus/bus-message.c:4125
     #2 0x7fc365e93586 in bus_message_from_malloc ../src/libsystemd/sd-bus/bus-message.c:443
     #3 0x7fc365f089a8 in bus_socket_make_message ../src/libsystemd/sd-bus/bus-socket.c:1165
     #4 0x7fc365f0affe in bus_socket_read_message ../src/libsystemd/sd-bus/bus-socket.c:1294
     #5 0x7fc365f2db71 in bus_read_message ../src/libsystemd/sd-bus/sd-bus.c:2082
     #6 0x7fc365f33352 in sd_bus_call ../src/libsystemd/sd-bus/sd-bus.c:2483
     #7 0x7fc365e4da61 in sd_bus_call_methodv ../src/libsystemd/sd-bus/bus-convenience.c:183
     #8 0x7fc3658789e8 in bus_call_method ../src/shared/bus-locator.c:109
     #9 0x413b76 in show_image ../src/machine/machinectl.c:1014
     #10 0x7fc365c5c8cf in dispatch_verb ../src/shared/verbs.c:103
     #11 0x42e992 in machinectl_main ../src/machine/machinectl.c:2981
     #12 0x42ebbd in run ../src/machine/machinectl.c:3006
     #13 0x42ece3 in main ../src/machine/machinectl.c:3009
     #14 0x7fc36444a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
 SUMMARY: AddressSanitizer: 5382 byte(s) leaked in 18 allocation(s).

(cherry picked from commit 4b6ce580eee3f70412637c1df4239e448995535f)
2023-06-01 16:37:09 +02:00
Daan De Meyer
ea221dc685 fstab-generator: Fix log message
(cherry picked from commit 32fe629abc986195c4b8fc5f9b8be1b60b48e766)
2023-06-01 16:37:09 +02:00
Lennart Poettering
4c3b06f255 test: test O_CLOEXEC filtering of fdset fill logic
(cherry picked from commit d7aee3f41f69f46d8328f658cab84f8a4b05bb86)
Backport of the cloexec filter for v253, and for v252 (actually tested
with v252). Note that I've left the name _s of the function parameter as
it was before.
2023-05-31 17:06:00 +02:00
Lennart Poettering
88bf6b5815 pid1: when taking possession of passed fds check O_CLOEXEC state first
So here's the thing. One library we use (libselinux) is opening fds
behind our back when we initialize it and keeps it open. On the other
hand we want to automatically pick up all fds passed in to us, so that
we can distribute them to our services and close the rest. We pick them
up very early in our code, to ensure that we don't get confused by open
fds at that point. Except that libselinux insists on being initialized
even earlier. So suddenly we might take possession of libselinux' fds,
and then close them later when we decide no service wants them. Then
during shutdown we close down selinux and selinux closes its fds, but
since already closed long ago this ight close our fds instead. Hilarity
ensues.

I wish low-level software wouldn't do such things behind our back, but
well, let's make the best of it.

This changes the fd pick-up logic to only pick up fds that have
O_CLOEXEC unset. O_CLOEXEC must be unset for any fds passed in to us
over execve() after all. And for all our own fds we should set O_CLOEXEC
since we generally don't want to litter fd tables for execve(). Also,
libselinux thankfully appears to set O_CLOEXEC correctly on its fds,
hence the filter works.

Fixes: #27491

(cherry picked from commit eb564f928e401def8d3aaa2a90f33cb09cdc1517)
Backport of the cloexec filter for v253, and for v252 (actually tested
with v252). Note that I've left the name _s of the function parameter as
it was before.
2023-05-31 17:06:00 +02:00
Daan De Meyer
0d8372b450 repart: Create temporary root directory using var_tmp_dir()
This allows users to override the directory used with environment
variables.

(cherry picked from commit 9dc9686018600ac02535bec711649801017acae2)
2023-05-25 16:42:35 +01:00
Frantisek Sumsal
aedfe41cda cryptenroll: actually allow using multiple "special" strings when wiping
The systemd-cryptenroll man page states:

    Takes a comma separated list of numeric slot indexes, or the special
    strings ..., or any combination of these strings or numeric
    indexes, in which case all slots matching either are wiped.

but we'd allow only one special string at any given time as the value
was not ORed when assigning. So, for example, --wipe=recovery,password
would actually become --wipe=password, etc.

(cherry picked from commit b0582f6b635011506fdf68d0afdc128ab10f6c6a)
2023-05-12 10:04:45 +02:00
Yu Watanabe
f59ce1aa7b core: fix use of uninitialized value
Fixes https://github.com/systemd/systemd/pull/27504#issuecomment-1533354787.

(cherry picked from commit 6cb105b8773c98884729c3d92dea65d395eee466)
2023-05-12 10:04:45 +02:00
Yu Watanabe
3f5db0dbc1 sd-journal: check .next_entry_array_offset earlier
Then, if it is invalid, refuse to use the entry array object.

Follow-up for a8fbcc0e3c033a43e511550052cace6b0dcf3df7.
Fixes #27489.

(cherry picked from commit b5335da7a54d6597a1539b56b5a0cb1f8d36dfdd)
2023-05-12 10:04:45 +02:00
Yu Watanabe
0baac8e60e tree-wide: drop _pure_ attribute from non-pure functions
Prompted by #27595.
Follow-ups for 6723c28f36ea566faf61d3610012cd89f95ee4a0.

(cherry picked from commit bc52801034e9e33d7aab0cb64c84f64cd9d4c035)
2023-05-12 10:04:45 +02:00
Sam James
4984f70db5 dirent: conditionalize dirent assert based on dirent64 existence
>=musl-1.2.4 doesn't define dirent64 and its LFS friends as its "native"
functions are already LFS-aware.

Check for dirent64 in meson.build and only assert if it exists.

Bug: https://bugs.gentoo.org/905900
Closes: https://github.com/systemd/systemd/pull/25809
(cherry picked from commit eb29296937b268e0140a2ab1cf204c2ebb72fa5a)
2023-05-12 10:04:45 +02:00
Mike Yuan
5fcbda8b5e network/tc: rename settings in log messages too
Follow-up for c03ef420fa7157b8d4881636fe72596a06e08bb6

(cherry picked from commit 8707dcdf3b5b4b01530639389350505fcb700969)
2023-05-12 10:04:45 +02:00
Xi Ruoyao
59dccdfddb sd-bus: bus_message_type_from_string is not pure
GCC document [1] says:

    The pure attribute prohibits a function from modifying the state
    of the program that is observable by means other than inspecting
    the function’s return value.

And there is an example:

    `int hash (char *) __attribute__ ((pure));`
    ... Even though hash takes a non-const pointer argument it must
    not modify the array it points to, ...

But we are modifying the object pointed to by the pointer u, which is
clearly a violation of the semantic of pure.

With -ftrivial-auto-var-init (enabled by -Dmode=release), on some
targets (GCC 12.2 on AArch64 and GCC 13.1 on x86_64) performs an
optimization: as the variable "u" in bus_match_parse has been
zero-initialized (by the -ftrivial-auto-var-init option) and never
modified (because a "pure" bus_message_type_from_string is not allowed
to modify it), "u" will be always 0.

Then 0 is used to initialize .value_u8 field of struct
bus_match_component.  This then causes a infinite event loop, so
"systemctl restart" never stops, and pam_systemd timeouts communicating
with logind, etc.

So we should remove the "pure" attribute here.

Fixes #26395.

[1]:https://gcc.gnu.org/onlinedocs/gcc/Common-Function-Attributes.html#index-pure-function-attribute

(cherry picked from commit 6723c28f36ea566faf61d3610012cd89f95ee4a0)
2023-05-12 10:04:45 +02:00
Frantisek Sumsal
133d4ff6d6 cryptenroll: fix an assertion with weak passwords
Passing 0 to log_xxx_errno() leads to an assertion, so let's not do that:

$ NEWPASSWORD="" build-san/systemd-cryptenroll --unlock-key-file=/tmp/password --password "$img"
/tmp/password has 0644 mode that is too permissive, please adjust the ownership and access mode.
Assertion '(_error) != 0' failed at src/cryptenroll/cryptenroll-password.c:164, function enroll_password(). Aborting.
Aborted (core dumped)

(cherry picked from commit 0e43ab6d245a77aab35c7963ec636f37e6103984)
2023-05-12 10:04:45 +02:00
Daan De Meyer
c937b8f9de units: Add CAP_NET_ADMIN condition to systemd-networkd-wait-online@.service as well
It was added to CAP_NET_ADMIN but we forgot to add it to the template
service as well.

(cherry picked from commit 97211510b06b01a4f053d4cacba4ad4184849bcf)
2023-05-12 10:04:45 +02:00
Yu Watanabe
60af5019fb units: add/fix Documentation= about bus interface
(cherry picked from commit d421db6e8b05183104896ca731ac393b661c4480)
2023-05-12 10:04:45 +02:00
Yu Watanabe
53f7e5f18f core/service: fix error cause in the log
Fixes a bug caused by a5648b809457d120500b2acb18b31e2168a4817a.
Fixes #27575.

(cherry picked from commit f86a388de339bc9fd3bc90df7de0d9693b52369f)
2023-05-12 10:04:45 +02:00
Marko Korhonen
951c27ce14 shell completion: add timesync-status and show-timesync to zsh completion file (#27574)
Fixes #27560

(cherry picked from commit 2ad681f53cd06a2c4b54c79c7338adbdec4922d1)
2023-05-12 10:04:45 +02:00
Miao Wang
32831842ba doc: remove legacy DefaultControlGroup from dbus properties
DefaultControlGroup does not exist any more.

(cherry picked from commit 4fad639a1350b1ce2fa77249f8e81dcc4229ee57)
2023-05-12 10:04:45 +02:00
Ronan Pigott
c31e2fa9c7 zsh: add service-log-{level,target} completions for systemctl
(cherry picked from commit b3d12ac0da2a8b25abc9052a4f350f1ea1108985)
2023-05-12 10:04:45 +02:00
Zbigniew Jędrzejewski-Szmek
011a686a23 test_ukify: fix loop iteration
We'd try to access 'linux' or 'initrd' after failing to set it.

(cherry picked from commit cb3b451e11e5dc32f12560c63e36bacb8df164f4)
2023-05-12 10:04:45 +02:00
Yu Watanabe
927d234406 hwdb: do not include '#' in modalias
Follow-up for 7bd3d6e35a6de8b1bf93e2fae28a64f0c7ffd2ac.
Fixes #27516.

(cherry picked from commit 5b5e54e058745f47184cb88e0037fa576164000c)
2023-05-12 10:04:45 +02:00
Frantisek Sumsal
b1a7a15ed2 core: check the unit type more thoroughly when deserializing
Resolves: #27523
(cherry picked from commit 24e91e08f8958241195f97472353adef94884b33)
2023-05-12 10:04:45 +02:00
Frantisek Sumsal
154b108513 shared: refuse fd == INT_MAX
Since we do `FD_TO_PTR(fd)` that expands to `INT_TO_PTR(fd) + 1` which
triggers an integer overflow.

Resolves: #27522
(cherry picked from commit cc938f1ce0f1eafc435e0dd1d9fe45aaedc526e1)
2023-05-12 10:04:45 +02:00
Ronan Pigott
a25605d01d zsh: remove usage of PREFIX in _systemctl
The usage of PREFIX in this completion is mostly counter to the intended
usage of compsys in zsh. It is generally expected that completion code
provide the available completions and tags in that word position so that
compsys, with user configuration, can filter them to the appropriate set.

One egregious error caused by the usage of PREFIX here is the caching of
SYS_ALL_UNITS, which stored only the unit names prematurely filtered by
the completion prefix, affecting all future completions. For example,

  $ systemctl cat nonsense<TAB>

might find no matching units if nonsense* has no matches, but now

  $ systemctl cat <TAB>

will fail in all future completions even though every unit file
is a valid match, because the cached set has been erroneously filtered
by the last prefix.

(cherry picked from commit 8139407ec109594c11c8c7d2936e9f0eba610f05)
2023-05-12 10:04:45 +02:00
Nick Rosbrook
4be604e75a basic/audit-util: make a test request before enabling use of audit
If a container manager does not follow the guidance in
https://systemd.io/CONTAINER_INTERFACE/ regarding audit capabilities,
then the current check may not be sufficient to determine that audit
will function properly. In particular, when calling bind() on the audit
fd, we will get EPERM if running in a user-namespaced container.

Expand the check to make an AUDIT_GET_FEATURE request on the audit fd to
test if it is working. If this fails with ECONNREFUSED, we know it is
because the kernel does not support the use of audit outside of the
initial user namespace.

Note that the approach of this patch was suggested here:
https://github.com/systemd/systemd/pull/19443#issuecomment-829566659

Fixes: #6519
(cherry picked from commit 362235bf59f8ddc6d67be3d6c8604f7fd05d383d)
2023-05-12 10:04:45 +02:00
David Tardon
4b4285e231 main: add missing return
Follow-up-for: 2b5107e1625e0847179da0d35eb544192766886f
(cherry picked from commit 9f2f16a344e8a7660756859dcd303f0bf5763b05)
2023-05-12 10:04:45 +02:00
Frantisek Sumsal
ce096b0212 shared: reject empty attachment path
(cherry picked from commit 740831076cfcf2f73f3063fbb040c1ea593dfe6c)
2023-05-12 10:04:45 +02:00
Frantisek Sumsal
6027fbf1af shared: ignore invalid valink socket fd when deserializing
(cherry picked from commit 1febf60f9d67b851e3f0ace2d87b718d3e0b04d5)
2023-05-12 10:04:45 +02:00
Frantisek Sumsal
d649128268 core: fix NULL pointer dereference during deserialization
(cherry picked from commit 45b1017488cef2a5bacdf82028ce900a311c9a1c)
2023-05-12 10:04:45 +02:00
Jan Janssen
6ae77d6b99 boot: Use correct memory type for allocations
We were using the wrong memory type when allocating pool memory. This
does not seem to cause a problem on x86, but the kernel will fail to
boot at least on ARM in QEMU.

This is caused by mixing different allocation types which ended up
breaking the kernel or EDK2 during boot services exit. Commit
2f3c3b0bee5534f2338439f04b0aa517479f8b76 appears to fix this boot
failure because it was replacing the gnu-efi xpool_print with xasprintf
thereby unifying the allocation type.
But this same issue can also happen without this fix somehow when the
random-seed logic is in use.

Fixes: #27371
(cherry picked from commit ec232e4abd7aebfec06b4814b30129532b2bcefd)
2023-05-12 10:04:45 +02:00
msizanoen1
de0cbaceb7 core: check for SERVICE_RELOAD_NOTIFY in manager_dbus_is_running
This ensures that systemd won't erronously disconnect from the system
bus in case a bus recheck is triggered immediately after the bus service
emits `RELOADING=1`.

This fixes an issue where systemd-logind sometimes randomly stops
receiving `UnitRemoved` after a system update.

This also handles SERVICE_RELOAD_SIGNAL just in case somebody ever
creates a D-Bus broker implementation that uses `Type=notify-reload`.

(cherry picked from commit 845824acddf2e7e08c94afe7cfee6e50a682c947)
2023-05-12 10:04:45 +02:00
Luca Boccassi
5ed087fa46 generators: skip private tmpfs if /tmp does not exist
When spawning generators within a sandbox we want a private /tmp, but it
might not exist, and on some systems we might be unable to create it
because users want a BTRFS subvolume instead.

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

(cherry picked from commit b8fba0cded2c3e14fe8c0b52aae3ecf2c9fa718e)
v253.4
2023-05-02 17:57:10 +01:00
Yu Watanabe
93143b6d6a test: replace sleep with timeout
If the test environment is too slow, then sleeping 2 seconds may not be
sufficient.

(cherry picked from commit e94756c5668697d0b11f4cdf449a2fbfe13ffb1f)
2023-05-02 17:57:10 +01:00