]> git.ipfire.org Git - thirdparty/systemd.git/log
thirdparty/systemd.git
12 months agomount-util: Downgrade log message to trace
Daan De Meyer [Thu, 25 May 2023 07:48:24 +0000 (09:48 +0200)] 
mount-util: Downgrade log message to trace

This debug log message is extremely noisy so let's downgrade it to
trace.

12 months agomkosi: Bump default timeout to 180s
Daan De Meyer [Thu, 25 May 2023 08:00:59 +0000 (10:00 +0200)] 
mkosi: Bump default timeout to 180s

Hopefully fixes #27778 where waiting for the root device to appear
times out before systemd-repart has a chance to run and create it.

12 months agoMerge pull request #26959 from poettering/creds-mount-dep-fix
Lennart Poettering [Thu, 25 May 2023 09:06:47 +0000 (02:06 -0700)] 
Merge pull request #26959 from poettering/creds-mount-dep-fix

credential ramfs mount order fixes

12 months agoMerge pull request #27483 from yuwata/udev-id-path-usb-revision
Zbigniew Jędrzejewski-Szmek [Thu, 25 May 2023 08:24:45 +0000 (10:24 +0200)] 
Merge pull request #27483 from yuwata/udev-id-path-usb-revision

udev: include USB revision in ID_PATH

12 months agoMerge pull request #27770 from mrc0mmand/more-nallocfuzz-shenanigans
Yu Watanabe [Thu, 25 May 2023 08:15:37 +0000 (17:15 +0900)] 
Merge pull request #27770 from mrc0mmand/more-nallocfuzz-shenanigans

A couple of fixes for potential issues during OOM situations

12 months agoMerge pull request #27769 from YHNdnzj/loginctl-followup
Yu Watanabe [Wed, 24 May 2023 20:52:06 +0000 (05:52 +0900)] 
Merge pull request #27769 from YHNdnzj/loginctl-followup

loginctl: some follow-ups

12 months agoMerge pull request #27723 from YHNdnzj/service-restart-cleanup
Yu Watanabe [Wed, 24 May 2023 20:14:52 +0000 (05:14 +0900)] 
Merge pull request #27723 from YHNdnzj/service-restart-cleanup

core: get rid of unused Service.will_auto_restart logic

12 months agotree-wide: check memstream buffer after closing the handle 27770/head
Frantisek Sumsal [Wed, 24 May 2023 11:29:52 +0000 (13:29 +0200)] 
tree-wide: check memstream buffer after closing the handle

When closing the FILE handle attached to a memstream, it may attempt to
do a realloc() that may fail during OOM situations, in which case we are
left with the buffer pointer pointing to NULL and buffer size > 0. For
example:

```
    #include <errno.h>
    #include <stdio.h>
    #include <stdlib.h>

    void *realloc(void *ptr, size_t size) {
        return NULL;
    }

    int main(int argc, char *argv[])
    {
        FILE *f;
        char *buf;
        size_t sz = 0;

        f = open_memstream(&buf, &sz);
        if (!f)
            return -ENOMEM;

        fputs("Hello", f);

        fflush(f);
        printf("buf: 0x%lx, sz: %lu, errno: %d\n",
                    (unsigned long) buf, sz, errno);
        fclose(f);
        printf("buf: 0x%lx, sz: %lu, errno: %d\n",
                    (unsigned long) buf, sz, errno);

        return 0;
    }
```

```
$ gcc -o main main.c
$ ./main
buf: 0x74d4a0, sz: 5, errno: 0
buf: 0x0, sz: 5, errno: 0
```

This might do unexpected things if the underlying code expects a valid
pointer to the memstream buffer after closing the handle.

Found by Nallocfuzz.

12 months agosystem-update-generator: drop pointless goto
David Tardon [Tue, 16 May 2023 05:39:32 +0000 (07:39 +0200)] 
system-update-generator: drop pointless goto

12 months agoMerge pull request #27173 from yuwata/update-utmp
Yu Watanabe [Wed, 24 May 2023 19:00:58 +0000 (04:00 +0900)] 
Merge pull request #27173 from yuwata/update-utmp

update-utmp: do not fail when PID1 is reexecuting

12 months agoMerge pull request #27773 from dtardon/timestamp-cleanup
Yu Watanabe [Wed, 24 May 2023 18:27:15 +0000 (03:27 +0900)] 
Merge pull request #27773 from dtardon/timestamp-cleanup

Use *timestamp_is_set() at more places

12 months agoMerge pull request #27774 from dtardon/free-cleanup
Yu Watanabe [Wed, 24 May 2023 18:06:51 +0000 (03:06 +0900)] 
Merge pull request #27774 from dtardon/free-cleanup

Use free_and_*() more

12 months agologinctl: also show idle hint in session-status 27769/head
Mike Yuan [Tue, 23 May 2023 10:54:30 +0000 (18:54 +0800)] 
loginctl: also show idle hint in session-status

12 months agologinctl: list-users: use bus_map_all_properties
Mike Yuan [Tue, 23 May 2023 10:27:05 +0000 (18:27 +0800)] 
loginctl: list-users: use bus_map_all_properties

12 months agologinctl: list-sessions: fix timestamp for idle hint
Mike Yuan [Wed, 24 May 2023 17:20:45 +0000 (01:20 +0800)] 
loginctl: list-sessions: fix timestamp for idle hint

Follow-up for 556723e738b96a5c2b2d45a96b87b7b80e0c5664

TABLE_TIMESTAMP_RELATIVE takes a realtime timestamp.

12 months agologinctl: some modernizations
Mike Yuan [Wed, 24 May 2023 11:42:03 +0000 (19:42 +0800)] 
loginctl: some modernizations

12 months agoukify: fix handling signed kernel as file
Malte Poll [Wed, 24 May 2023 09:01:25 +0000 (11:01 +0200)] 
ukify: fix handling signed kernel as file

The .linux section would contain the path to the signed kernel (instead of the signed kernel itself), since the python type of the variable is used to determine how it is handled when adding the pe sections.

Co-authored-by: Otto Bittner <cobittner@posteo.net>
12 months agosd-journal: propagate errors from ordered_hashmap_*()
Frantisek Sumsal [Wed, 24 May 2023 12:17:25 +0000 (14:17 +0200)] 
sd-journal: propagate errors from ordered_hashmap_*()

Instead of masking them with -ENOMEM.

12 months agotimer: use dual_timestamp_is_set() at one more place 27773/head
David Tardon [Wed, 24 May 2023 13:29:30 +0000 (15:29 +0200)] 
timer: use dual_timestamp_is_set() at one more place

12 months agotree-wide: use timestamp_is_set() at more places
David Tardon [Wed, 24 May 2023 13:26:32 +0000 (15:26 +0200)] 
tree-wide: use timestamp_is_set() at more places

12 months agocore: drop UnitNotifyFlags 27723/head
Mike Yuan [Mon, 22 May 2023 00:35:53 +0000 (08:35 +0800)] 
core: drop UnitNotifyFlags

This essentially reverts 2ad2e41a72ec19159c0746a78e15ff880fe32a63.

No longer needed after dropping UNIT_NOTIFY_WILL_AUTO_RESTART.

12 months agocore: get rid of unused Service.will_auto_restart logic
Mike Yuan [Mon, 22 May 2023 00:30:30 +0000 (08:30 +0800)] 
core: get rid of unused Service.will_auto_restart logic

The announced new behavior for OnFailure= never worked properly,
and we've fixed the document instead in #27675.
Therefore, let's get rid of the unused logic completely. More at #27594.

The to-be-added RestartMode= option should cover the use case hopefully.

Closes #27594

12 months agojournal-upload: use mfree() 27774/head
David Tardon [Wed, 24 May 2023 12:27:27 +0000 (14:27 +0200)] 
journal-upload: use mfree()

12 months agotree-wide: use free_and_str*dup() more
David Tardon [Wed, 24 May 2023 12:47:36 +0000 (14:47 +0200)] 
tree-wide: use free_and_str*dup() more

12 months agotree-wide: use free_and_replace() more
David Tardon [Wed, 24 May 2023 12:21:04 +0000 (14:21 +0200)] 
tree-wide: use free_and_replace() more

12 months agoMerge pull request #27752 from DaanDeMeyer/timer-oncalendar-fix
Daan De Meyer [Wed, 24 May 2023 12:39:32 +0000 (14:39 +0200)] 
Merge pull request #27752 from DaanDeMeyer/timer-oncalendar-fix

core/timer: Always use inactive_exit_timestamp if it is set

12 months agoenv-file: use free_and_replace()
Frantisek Sumsal [Wed, 24 May 2023 09:41:30 +0000 (11:41 +0200)] 
env-file: use free_and_replace()

12 months agospecifier: avoid leaking memory on allocation error
Frantisek Sumsal [Wed, 24 May 2023 09:39:24 +0000 (11:39 +0200)] 
specifier: avoid leaking memory on allocation error

==8036==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 64 byte(s) in 1 object(s) allocated from:
    #0 0x4a10bc in __interceptor_realloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:85:3
    #1 0x4deef1 in realloc (/build/fuzz-unit-file+0x4deef1)
    #2 0x7ffa35abfe23 in greedy_realloc /work/build/../../src/systemd/src/basic/alloc-util.c:70:13
    #3 0x7ffa35aefad2 in parse_env_file_internal /work/build/../../src/systemd/src/basic/env-file.c:127:38
    #4 0x7ffa35af08a6 in parse_env_file_fdv /work/build/../../src/systemd/src/basic/env-file.c:374:13
    #5 0x7ffa35b6391e in parse_extension_release_atv /work/build/../../src/systemd/src/basic/os-util.c:323:16
    #6 0x7ffa35b63c8a in parse_extension_release_sentinel /work/build/../../src/systemd/src/basic/os-util.c:360:13
    #7 0x7ffa35a5e3f5 in parse_os_release_specifier /work/build/../../src/systemd/src/shared/specifier.c:292:13
    #8 0x7ffa35a5e3f5 in specifier_os_id /work/build/../../src/systemd/src/shared/specifier.c:303:16
    #9 0x7ffa35a5c7f5 in specifier_printf /work/build/../../src/systemd/src/shared/specifier.c:70:45
    #10 0x7ffa3690b279 in unit_full_printf_full /work/build/../../src/systemd/src/core/unit-printf.c:264:16
    #11 0x7ffa367de795 in config_parse_bus_name /work/build/../../src/systemd/src/core/load-fragment.c:2401:13
    #12 0x7ffa358fe5ec in next_assignment /work/build/../../src/systemd/src/shared/conf-parser.c:151:24
    #13 0x7ffa358fe5ec in parse_line /work/build/../../src/systemd/src/shared/conf-parser.c:257:16
    #14 0x7ffa358fd653 in config_parse /work/build/../../src/systemd/src/shared/conf-parser.c:400:21
    #15 0x4de828 in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/core/fuzz-unit-file.c:72:16
    #16 0x4df208 in NaloFuzzerTestOneInput (/build/fuzz-unit-file+0x4df208)
    #17 0x4fe213 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #18 0x4fd9fa in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #19 0x4ff0c9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #20 0x4ffd95 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #21 0x4ef0ff in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #22 0x4ef9c8 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #23 0x4df485 in main (/build/fuzz-unit-file+0x4df485)
    #24 0x7ffa35232082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

DEDUP_TOKEN: __interceptor_realloc--realloc--greedy_realloc
SUMMARY: AddressSanitizer: 64 byte(s) leaked in 1 allocation(s).

Found by Nallocfuzz.

12 months agoresolve: avoid memory leak from a partially processed RR
Frantisek Sumsal [Tue, 23 May 2023 19:34:48 +0000 (21:34 +0200)] 
resolve: avoid memory leak from a partially processed RR

==5==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 4096 byte(s) in 1 object(s) allocated from:
    #0 0x4a2056 in __interceptor_malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x5180a9 in malloc (/build/fuzz-resource-record+0x5180a9)
    #2 0x4f7182 in dns_packet_extend /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:371:36
    #3 0x4f8b8b in dns_packet_append_uint8 /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:433:13
    #4 0x4f8b8b in dns_packet_append_name /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:597:13
    #5 0x4f8f16 in dns_packet_append_key /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:622:13
    #6 0x4fa9a0 in dns_packet_append_rr /work/build/../../src/systemd/src/resolve/resolved-dns-packet.c:883:13
    #7 0x4eb00c in dns_resource_record_to_wire_format /work/build/../../src/systemd/src/resolve/resolved-dns-rr.c:1224:13
    #8 0x4df7be in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/resolve/fuzz-resource-record.c:32:16
    #9 0x518428 in NaloFuzzerTestOneInput (/build/fuzz-resource-record+0x518428)
    #10 0x537433 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #11 0x536c1a in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #12 0x5382e9 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #13 0x538fb5 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #14 0x52831f in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #15 0x528be8 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #16 0x5186a5 in main (/build/fuzz-resource-record+0x5186a5)
    #17 0x7f991fab8082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

DEDUP_TOKEN: __interceptor_malloc--malloc--dns_packet_extend
SUMMARY: AddressSanitizer: 4096 byte(s) leaked in 1 allocation(s).

Found by Nallocfuzz.

12 months agosd-journal: use TAKE_PTR() a bit more
Frantisek Sumsal [Tue, 23 May 2023 17:21:20 +0000 (19:21 +0200)] 
sd-journal: use TAKE_PTR() a bit more

12 months agosd-journal: avoid double-free
Frantisek Sumsal [Tue, 23 May 2023 16:09:23 +0000 (18:09 +0200)] 
sd-journal: avoid double-free

If we fail to combine the new entry with a previous one, or update it in
the hashmap, we might later on attempt a double-free:

=================================================================
==10==ERROR: AddressSanitizer: attempting double-free on 0x611000039fc0 in thread T0:
SCARINESS: 42 (double-free)
    #0 0x4a0962 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
    #1 0x7f55e431d9f2 in _hashmap_clear /work/build/../../src/systemd/src/basic/hashmap.c:927:33
    #2 0x7f55e431d4c8 in _hashmap_free /work/build/../../src/systemd/src/basic/hashmap.c:896:17
    #3 0x4de1de in ordered_hashmap_free_free_free /work/build/../../src/systemd/src/basic/hashmap.h:120:24
    #4 0x4de1de in ordered_hashmap_free_free_freep /work/build/../../src/systemd/src/basic/hashmap.h:434:1
    #5 0x4de1de in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-catalog.c:26:1
    #6 0x4de8b8 in NaloFuzzerTestOneInput (/build/fuzz-catalog+0x4de8b8)
    #7 0x4fd8c3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #8 0x4fd0aa in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #9 0x4fe779 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #10 0x4ff445 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #11 0x4ee7af in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #12 0x4ef078 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #13 0x4deb35 in main (/build/fuzz-catalog+0x4deb35)
    #14 0x7f55e3a32082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)
    #15 0x41f7cd in _start (/build/fuzz-catalog+0x41f7cd)

DEDUP_TOKEN: __interceptor_free--_hashmap_clear--_hashmap_free
0x611000039fc0 is located 0 bytes inside of 224-byte region [0x611000039fc0,0x61100003a0a0)
freed by thread T0 here:
    #0 0x4a0962 in __interceptor_free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3
    #1 0x7f55e451493d in freep /work/build/../../src/systemd/src/basic/alloc-util.h:107:22
    #2 0x7f55e451493d in finish_item /work/build/../../src/systemd/src/libsystemd/sd-journal/catalog.c:187:1
    #3 0x7f55e4513e56 in catalog_import_file /work/build/../../src/systemd/src/libsystemd/sd-journal/catalog.c:313:45
    #4 0x4de1be in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-catalog.c:23:16
    #5 0x4de8b8 in NaloFuzzerTestOneInput (/build/fuzz-catalog+0x4de8b8)
    #6 0x4fd8c3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #7 0x4fd0aa in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #8 0x4fe779 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #9 0x4ff445 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #10 0x4ee7af in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #11 0x4ef078 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #12 0x4deb35 in main (/build/fuzz-catalog+0x4deb35)
    #13 0x7f55e3a32082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

DEDUP_TOKEN: __interceptor_free--freep--finish_item
previously allocated by thread T0 here:
    #0 0x4a0c06 in __interceptor_malloc /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:69:3
    #1 0x4de539 in malloc (/build/fuzz-catalog+0x4de539)
    #2 0x7f55e42bf96b in memdup /work/build/../../src/systemd/src/basic/alloc-util.c:16:15
    #3 0x7f55e451475d in finish_item /work/build/../../src/systemd/src/libsystemd/sd-journal/catalog.c:176:28
    #4 0x7f55e4513e56 in catalog_import_file /work/build/../../src/systemd/src/libsystemd/sd-journal/catalog.c:313:45
    #5 0x4de1be in LLVMFuzzerTestOneInput /work/build/../../src/systemd/src/fuzz/fuzz-catalog.c:23:16
    #6 0x4de8b8 in NaloFuzzerTestOneInput (/build/fuzz-catalog+0x4de8b8)
    #7 0x4fd8c3 in fuzzer::Fuzzer::ExecuteCallback(unsigned char const*, unsigned long) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:611:15
    #8 0x4fd0aa in fuzzer::Fuzzer::RunOne(unsigned char const*, unsigned long, bool, fuzzer::InputInfo*, bool, bool*) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:514:3
    #9 0x4fe779 in fuzzer::Fuzzer::MutateAndTestOne() /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:757:19
    #10 0x4ff445 in fuzzer::Fuzzer::Loop(std::__Fuzzer::vector<fuzzer::SizedFile, std::__Fuzzer::allocator<fuzzer::SizedFile> >&) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerLoop.cpp:895:5
    #11 0x4ee7af in fuzzer::FuzzerDriver(int*, char***, int (*)(unsigned char const*, unsigned long)) /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:912:6
    #12 0x4ef078 in LLVMFuzzerRunDriver /src/llvm-project/compiler-rt/lib/fuzzer/FuzzerDriver.cpp:925:10
    #13 0x4deb35 in main (/build/fuzz-catalog+0x4deb35)
    #14 0x7f55e3a32082 in __libc_start_main (/lib/x86_64-linux-gnu/libc.so.6+0x24082) (BuildId: 1878e6b475720c7c51969e69ab2d276fae6d1dee)

DEDUP_TOKEN: __interceptor_malloc--malloc--memdup
SUMMARY: AddressSanitizer: double-free /src/llvm-project/compiler-rt/lib/asan/asan_malloc_linux.cpp:52:3 in __interceptor_free

Found by Nallocfuzz.

12 months agotest: add test case for systemd-update-utmp vs daemon-reexec 27173/head
Yu Watanabe [Wed, 26 Apr 2023 14:56:50 +0000 (23:56 +0900)] 
test: add test case for systemd-update-utmp vs daemon-reexec

12 months agotest: drop a workaround
Yu Watanabe [Fri, 7 Apr 2023 01:05:40 +0000 (10:05 +0900)] 
test: drop a workaround

Follow-up for 61961e693d3ba71386068947d85078c086e455e4.

12 months agoupdate-utmp: reconnect after sleep when PID1 is reexecuting
Yu Watanabe [Thu, 6 Apr 2023 19:49:07 +0000 (04:49 +0900)] 
update-utmp: reconnect after sleep when PID1 is reexecuting

Fixes #27167.

12 months agoupdate-utmp: update log message
Yu Watanabe [Fri, 7 Apr 2023 09:44:22 +0000 (18:44 +0900)] 
update-utmp: update log message

12 months agoupdate-utmp: downgrade log level of ignored failure
Yu Watanabe [Thu, 6 Apr 2023 19:34:54 +0000 (04:34 +0900)] 
update-utmp: downgrade log level of ignored failure

12 months agoupdate-utmp: swap q <-> r
Yu Watanabe [Thu, 6 Apr 2023 19:31:21 +0000 (04:31 +0900)] 
update-utmp: swap q <-> r

We usually use 'r' for general purpose.

No functional change, just refactoring.

12 months agoupdate-utmp: modernize get_startup_monotonic_time()
Yu Watanabe [Thu, 6 Apr 2023 19:26:19 +0000 (04:26 +0900)] 
update-utmp: modernize get_startup_monotonic_time()

This also downgrade error level, as the failure will be ignored.

No functional change, just refactoring.

12 months agoupdate-utmp: rebreak comments
Yu Watanabe [Thu, 6 Apr 2023 19:13:57 +0000 (04:13 +0900)] 
update-utmp: rebreak comments

12 months agoupdate-utmp: use verbs
Yu Watanabe [Thu, 6 Apr 2023 19:07:17 +0000 (04:07 +0900)] 
update-utmp: use verbs

No functional change, just refactoring.

12 months agoMerge pull request #27740 from dtardon/list-sessions-idle
Yu Watanabe [Wed, 24 May 2023 11:03:39 +0000 (20:03 +0900)] 
Merge pull request #27740 from dtardon/list-sessions-idle

Show idle status in `loginctl list-sessions`

12 months agoMerge pull request #27757 from dtardon/bus-locator
Yu Watanabe [Wed, 24 May 2023 11:02:57 +0000 (20:02 +0900)] 
Merge pull request #27757 from dtardon/bus-locator

Convert more DBus calls to BusLocator

12 months agotimer: Use dual_timestamp_is_set() in one more place 27752/head
Daan De Meyer [Wed, 24 May 2023 09:41:37 +0000 (11:41 +0200)] 
timer: Use dual_timestamp_is_set() in one more place

12 months agoMerge pull request #27761 from yuwata/network-vlan-qos-mapping
Luca Boccassi [Wed, 24 May 2023 08:59:41 +0000 (09:59 +0100)] 
Merge pull request #27761 from yuwata/network-vlan-qos-mapping

network: fix vlan qos mapping

12 months agoexecute: add missing NULL handling 26959/head
Lennart Poettering [Wed, 3 May 2023 19:54:29 +0000 (21:54 +0200)] 
execute: add missing NULL handling

12 months agomount: check right before invoking /bin/umount if it makes sense
Lennart Poettering [Thu, 23 Mar 2023 18:05:30 +0000 (19:05 +0100)] 
mount: check right before invoking /bin/umount if it makes sense

Notifications from /proc/self/mountinfo are async, so if we stop a
service (and while doing so get rid of the credentials mount point of
it), then it will take a while until the notification reaches us and we
actually scan the table again. In particular as we nowadays ratelimit
notifications on the table, since it's so inefficient. And as I learnt
the ratelimiting is actually quite regularly hit during shutdown, where
a flurry of umount events are genreated. Hence, let's check if a mount
point is actually a mountpoint before trying to unmount it. And if it
isn't let's wait for the notification to come in.

(This race might be triggred not just by us on ourselves btw: there are
other daemons that unmount stuff when stopping where the race also
exists, but might simply be harder to trigger: if during service
shutdown these services remove some mount then they might collide with
us doing the same. After all, we have the rule to unmount everything
mounted automatically for you during shutdown.)

In the long run we should also start making us of this when it becomes
available: https://github.com/util-linux/util-linux/issues/2132 With
that we can make issues like this go away entirely from our side of
things at least.

Fixes: #25527
12 months agosd-event: add an explicit API for leaving the ratelimit state
Lennart Poettering [Thu, 23 Mar 2023 22:16:43 +0000 (23:16 +0100)] 
sd-event: add an explicit API for leaving the ratelimit state

Sometimes, it might make sense to end the ratelimit window early.

12 months agocore: split out default network dep generation into own function
Lennart Poettering [Thu, 23 Mar 2023 13:03:47 +0000 (14:03 +0100)] 
core: split out default network dep generation into own function

Just some simple refactoring: let's split out network dep generation
into its own function mount_add_default_network_dependencies().

This way mount_add_default_dependencies() only does preparatory stuff,
and then calls both mount_add_default_network_dependencies() and
mount_add_default_ordering_dependencies() with that, making things
nicely symmetric.

12 months agocore: suppress various defaults deps for credentials mounts
Lennart Poettering [Thu, 23 Mar 2023 12:59:45 +0000 (13:59 +0100)] 
core: suppress various defaults deps for credentials mounts

The per-unit credentials mounts might show up for any kind of service,
including very very early ones. Hence let's not order them after
local-fs-pre.target, because otherwise we might trigger cyclic deps of
services that want to plug before that but still use credentials.

12 months agounit: add ordering dep relative to credentials dir
Lennart Poettering [Thu, 23 Mar 2023 11:35:38 +0000 (12:35 +0100)] 
unit: add ordering dep relative to credentials dir

See: #25527

12 months agocore/timer: Always use inactive_exit_timestamp if it is set
Daan De Meyer [Tue, 23 May 2023 14:24:47 +0000 (16:24 +0200)] 
core/timer: Always use inactive_exit_timestamp if it is set

If we're doing a daemon-reload, we'll be going from TIMER_DEAD => TIMER_WAITING,
so we won't use inactive_exit_timestamp because TIMER_DEAD != UNIT_ACTIVE, even
though inactive_exit_timestamp is serialized/deserialized and will be valid after
the daemon-reload.

This issue can lead to timers never firing as we'll always calculate the next
elapse based on the current realtime on daemon-reload, so if daemon-reload happens
often enough, the elapse interval will be moved into the future every time, which
means the timer will never trigger.

To fix the issue, let's always use inactive_exit_timestamp if it is set, and only
fall back to the current realtime if it is not set.

12 months agologinctl: show session idle status in list-sessions 27740/head
David Tardon [Fri, 19 May 2023 12:03:09 +0000 (14:03 +0200)] 
loginctl: show session idle status in list-sessions

12 months agotest: rotate journal before storing coredumps
Yu Watanabe [Wed, 24 May 2023 01:31:41 +0000 (10:31 +0900)] 
test: rotate journal before storing coredumps

Hopefully fixes the failure like
https://jenkins-systemd.apps.ocp.cloud.ci.centos.org/job/upstream-vagrant-archlinux-sanitizers/2558/
---
[   66.708894] testsuite-74.sh[728]: + coredumpctl --json=off
[   66.709344] testsuite-74.sh[826]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.709773] testsuite-74.sh[826]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.711134] testsuite-74.sh[826]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.711789] testsuite-74.sh[826]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.712460] testsuite-74.sh[826]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.713505] testsuite-74.sh[728]: + coredumpctl --root=/
[   66.714144] testsuite-74.sh[828]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.714535] testsuite-74.sh[828]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.715208] testsuite-74.sh[828]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.715907] testsuite-74.sh[828]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.716565] testsuite-74.sh[828]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.717494] testsuite-74.sh[728]: + coredumpctl --directory=/var/log/journal
[   66.718188] testsuite-74.sh[830]: TIME                        PID UID GID SIG     COREFILE EXE             SIZE
[   66.882072] testsuite-74.sh[830]: Tue 2023-05-23 22:10:17 UTC 739   0   0 SIGTRAP journal  /tmp/test-dump     -
[   66.882642] testsuite-74.sh[830]: Tue 2023-05-23 22:10:18 UTC 747   0   0 SIGABRT journal  /tmp/test-dump     -
[   66.883450] testsuite-74.sh[830]: Tue 2023-05-23 22:10:19 UTC 763   0   0 SIGTRAP present  /tmp/test-dump 53.5K
[   66.883944] testsuite-74.sh[830]: Tue 2023-05-23 22:10:20 UTC 776   0   0 SIGABRT present  /tmp/test-dump 53.3K
[   66.885448] testsuite-74.sh[728]: + coredumpctl --file=/var/log/journal/2e1ed84be19a4e22adfc99ad849be1f6/system.journal
[   66.885989] testsuite-74.sh[728]: + at_exit
[   66.894162] coredumpctl[833]: No coredumps found.
---

12 months agooomctl: convert a oom1.Manager call to BusLocator 27757/head
David Tardon [Wed, 24 May 2023 06:40:51 +0000 (08:40 +0200)] 
oomctl: convert a oom1.Manager call to BusLocator

12 months agobus-locator: sort the list
David Tardon [Wed, 24 May 2023 06:47:25 +0000 (08:47 +0200)] 
bus-locator: sort the list

12 months agobus-locator: declare bus locator for oom1 and timesync1
David Tardon [Wed, 24 May 2023 06:38:53 +0000 (08:38 +0200)] 
bus-locator: declare bus locator for oom1 and timesync1

12 months agohostnamectl: convert more hostname1 calls to BusLocator
David Tardon [Tue, 23 May 2023 18:40:47 +0000 (20:40 +0200)] 
hostnamectl: convert more hostname1 calls to BusLocator

12 months agotree-wide: convert more resolve1.Manager calls to BusLocator
David Tardon [Tue, 23 May 2023 18:37:27 +0000 (20:37 +0200)] 
tree-wide: convert more resolve1.Manager calls to BusLocator

12 months agojournalctl: convert a machine1.Manager call to BusLocator
David Tardon [Tue, 23 May 2023 18:33:16 +0000 (20:33 +0200)] 
journalctl: convert a machine1.Manager call to BusLocator

12 months agosleep: convert a home1.Manager call to BusLocator
David Tardon [Tue, 23 May 2023 18:28:55 +0000 (20:28 +0200)] 
sleep: convert a home1.Manager call to BusLocator

12 months agologin: use NULL to denote arg-less method call
David Tardon [Wed, 24 May 2023 06:29:22 +0000 (08:29 +0200)] 
login: use NULL to denote arg-less method call

"" and NULL are equivalent, but the latter is normally used.

12 months agotree-wide: convert more login1.Manager calls to BusLocator
David Tardon [Tue, 23 May 2023 18:23:17 +0000 (20:23 +0200)] 
tree-wide: convert more login1.Manager calls to BusLocator

12 months agotree-wide: convert more system1.Manager calls to BusLocator
David Tardon [Tue, 23 May 2023 18:09:37 +0000 (20:09 +0200)] 
tree-wide: convert more system1.Manager calls to BusLocator

12 months agotest-network: add tests for vlan QoS mapping 27761/head
Yu Watanabe [Wed, 24 May 2023 02:15:44 +0000 (11:15 +0900)] 
test-network: add tests for vlan QoS mapping

12 months agonetwork/vlan: paranoia about type safety
Yu Watanabe [Wed, 24 May 2023 02:06:35 +0000 (11:06 +0900)] 
network/vlan: paranoia about type safety

No functional change, as the struct is defined as the following:
```
struct ifla_vlan_qos_mapping {
      __u32 from;
      __u32 to;
};
```

12 months agonetwork/vlan: drop unnecessary restriction for QoS mapping
Yu Watanabe [Wed, 24 May 2023 02:02:36 +0000 (11:02 +0900)] 
network/vlan: drop unnecessary restriction for QoS mapping

Fixes #27460.

12 months agocore/slice: shorten code a bit
Yu Watanabe [Tue, 23 May 2023 21:24:11 +0000 (06:24 +0900)] 
core/slice: shorten code a bit

12 months agoelf2efi: Do not emit an empty relocation section
Jan Janssen [Tue, 23 May 2023 17:00:52 +0000 (19:00 +0200)] 
elf2efi: Do not emit an empty relocation section

At least shim will choke on an empty relocation section when loading the
binary. Note that the binary is still considered relocatable (just with
no base relocations to apply) as we do not set the
IMAGE_FILE_RELOCS_STRIPPED DLL characteristic.

12 months agocore: Do not check child freezability when thawing slice
msizanoen1 [Tue, 23 May 2023 11:46:26 +0000 (18:46 +0700)] 
core: Do not check child freezability when thawing slice

We want thawing operations to still succeed even in the presence of an
unfreezable unit type (e.g. mount) appearing under a slice after the
slice was frozen. The appearance of such units should never cause the
slice thawing operation to fail to prevent potential future repeats of
https://github.com/systemd/systemd/issues/25356.

12 months agoMerge pull request #27755 from keszybz/fix-root-resize-new
Yu Watanabe [Tue, 23 May 2023 21:08:54 +0000 (06:08 +0900)] 
Merge pull request #27755 from keszybz/fix-root-resize-new

Reload keymap and locale config after firstboot writes it out

12 months agoMerge pull request #27754 from poettering/cloexec-fdset-madness
Yu Watanabe [Tue, 23 May 2023 21:08:17 +0000 (06:08 +0900)] 
Merge pull request #27754 from poettering/cloexec-fdset-madness

pid1: when taking possession of passed fds check O_CLOEXEC state first

12 months agosd-boot,sd-stub: also print version after the address
Zbigniew Jędrzejewski-Szmek [Fri, 19 May 2023 15:18:41 +0000 (17:18 +0200)] 
sd-boot,sd-stub: also print version after the address

The kernel, systemd, and many other things print their version during boot.
sd-boot and sd-stub are also important, so let's print the version if EFI_DEBUG.
(If !EFI_DEBUG, continue to be quiet.)

When updating the docs, I saw that that the text in HACKING.md was out of date.
Instead of trying to update the instructions there, make it shorter and refer
the reader to tools/debug-sd-boot.sh for details.

12 months agomkfs-util: Silence noisy warning from mkfs.btrfs
Daan De Meyer [Tue, 23 May 2023 10:16:53 +0000 (12:16 +0200)] 
mkfs-util: Silence noisy warning from mkfs.btrfs

12 months agotest: test O_CLOEXEC filtering of fdset fill logic 27754/head
Lennart Poettering [Tue, 23 May 2023 16:39:53 +0000 (18:39 +0200)] 
test: test O_CLOEXEC filtering of fdset fill logic

12 months agofdset: minor modernizations
Lennart Poettering [Tue, 23 May 2023 18:45:40 +0000 (20:45 +0200)] 
fdset: minor modernizations

12 months agotree-wide: Fix false positives on newer gcc
Daan De Meyer [Tue, 23 May 2023 11:25:58 +0000 (13:25 +0200)] 
tree-wide: Fix false positives on newer gcc

Recent gcc versions have started to trigger false positive
maybe-uninitialized warnings. Let's make sure we initialize
variables annotated with _cleanup_ to avoid these.

12 months agojson: correctly handle magic strings when parsing variant strv
Frantisek Sumsal [Tue, 23 May 2023 07:55:17 +0000 (09:55 +0200)] 
json: correctly handle magic strings when parsing variant strv

We can't dereference the variant object directly, as it might be
a magic object (which has an address on a faulting page); use
json_variant_is_sensitive() instead that handles this case.

For example, with an empty array:

==1547789==ERROR: AddressSanitizer: SEGV on unknown address 0x000000000023 (pc 0x7fd616ca9a18 bp 0x7ffcba1dc7c0 sp 0x7ffcba1dc6d0 T0)
==1547789==The signal is caused by a READ memory access.
==1547789==Hint: address points to the zero page.
SCARINESS: 10 (null-deref)
    #0 0x7fd616ca9a18 in json_variant_strv ../src/shared/json.c:2190
    #1 0x408332 in oci_args ../src/nspawn/nspawn-oci.c:173
    #2 0x7fd616cc09ce in json_dispatch ../src/shared/json.c:4400
    #3 0x40addf in oci_process ../src/nspawn/nspawn-oci.c:428
    #4 0x7fd616cc09ce in json_dispatch ../src/shared/json.c:4400
    #5 0x41fef5 in oci_load ../src/nspawn/nspawn-oci.c:2187
    #6 0x4061e4 in LLVMFuzzerTestOneInput ../src/nspawn/fuzz-nspawn-oci.c:23
    #7 0x40691c in main ../src/fuzz/fuzz-main.c:50
    #8 0x7fd61564a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #9 0x7fd61564a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #10 0x405da4 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/fuzz-nspawn-oci+0x405da4)

DEDUP_TOKEN: json_variant_strv--oci_args--json_dispatch
AddressSanitizer can not provide additional info.
SUMMARY: AddressSanitizer: SEGV ../src/shared/json.c:2190 in json_variant_strv
==1547789==ABORTING

Or with an empty string in an array:

../src/shared/json.c:2202:39: runtime error: member access within misaligned address 0x000000000007 for type 'struct JsonVariant', which requires 8 byte alignment
0x000000000007: note: pointer points here
<memory cannot be printed>
    #0 0x7f35f4ca9bcf in json_variant_strv ../src/shared/json.c:2202
    #1 0x408332 in oci_args ../src/nspawn/nspawn-oci.c:173
    #2 0x7f35f4cc09ce in json_dispatch ../src/shared/json.c:4400
    #3 0x40addf in oci_process ../src/nspawn/nspawn-oci.c:428
    #4 0x7f35f4cc09ce in json_dispatch ../src/shared/json.c:4400
    #5 0x41fef5 in oci_load ../src/nspawn/nspawn-oci.c:2187
    #6 0x4061e4 in LLVMFuzzerTestOneInput ../src/nspawn/fuzz-nspawn-oci.c:23
    #7 0x40691c in main ../src/fuzz/fuzz-main.c:50
    #8 0x7f35f364a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)
    #9 0x7f35f364a5c8 in __libc_start_main@GLIBC_2.2.5 (/lib64/libc.so.6+0x275c8)
    #10 0x405da4 in _start (/home/fsumsal/repos/@systemd/systemd/build-san/fuzz-nspawn-oci+0x405da4)

SUMMARY: UndefinedBehaviorSanitizer: undefined-behavior ../src/shared/json.c:2202:39 in

Note: this happens only if json_variant_copy() in json_variant_set_source() fails.

Found by Nallocfuzz.

12 months agopid1: when taking possession of passed fds check O_CLOEXEC state first
Lennart Poettering [Tue, 23 May 2023 15:24:46 +0000 (17:24 +0200)] 
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
12 months agolog: propagate max log level into glibc's setlogmask()
Lennart Poettering [Tue, 23 May 2023 07:27:01 +0000 (09:27 +0200)] 
log: propagate max log level into glibc's setlogmask()

Follow-up for: #27734

It makes sense to propagate the select log level we maintain also into
glibc, so that any code that uses syslog() directly that ends up in our
processes (libraries and such) are affected by our settings the same way
as we are ourselves.

12 months agoudevadm: improve debug logging when triggering/watching events
Lennart Poettering [Tue, 23 May 2023 07:29:57 +0000 (09:29 +0200)] 
udevadm: improve debug logging when triggering/watching events

Let's make debugging udev triggering a bit easier, by generating debug
log messages whenever we trigger a device, and also when we see the
event in pid1.

12 months agoMerge pull request #27750 from keszybz/fix-root-resize-new
Lennart Poettering [Tue, 23 May 2023 16:53:13 +0000 (09:53 -0700)] 
Merge pull request #27750 from keszybz/fix-root-resize-new

Allow firstboot.service to be started after sysusers.service

12 months agolocaled: simplify method call 27755/head
Zbigniew Jędrzejewski-Szmek [Tue, 23 May 2023 14:36:14 +0000 (16:36 +0200)] 
localed: simplify method call

Also remove lines between call and result handling.

12 months agofirstboot: reload manager after writing /etc/locale.conf
Zbigniew Jędrzejewski-Szmek [Tue, 23 May 2023 15:32:49 +0000 (17:32 +0200)] 
firstboot: reload manager after writing /etc/locale.conf

Requested in https://github.com/systemd/systemd/pull/27750#issuecomment-1559258861.
I didn't apply the locale configuration in firstboot itself, because
we don't have any localized messages, so that wouldn't change anything.

12 months agofirstboot: do vconsole setup after configuring keymap
Zbigniew Jędrzejewski-Szmek [Tue, 23 May 2023 14:35:54 +0000 (16:35 +0200)] 
firstboot: do vconsole setup after configuring keymap

Fixes #13466.

12 months agofirstboot: process the root account after sysusers created it 27750/head
Zbigniew Jędrzejewski-Szmek [Mon, 3 Oct 2022 10:12:15 +0000 (12:12 +0200)] 
firstboot: process the root account after sysusers created it

We would create root account from sysusers or from firstboot, depending on
which one ran earlier. Since firstboot offers more options, in particular can
set the root password, we needed to order it earlier. This created an ugly
ordering requirement:

systemd-sysusers.service > systemd-firstboot.service > ... >
  systemd-remount-fs.service > systemd-tmpfiles-setup-dev.service >
  systemd-sysusers.service

We want sysusers.service to create basic users, so we can create nodes in dev,
so we can operate on block devices and such, so that we can resize and remount
things. But at the same time, systemd-firstboot.service can only work if it is
run early, before systemd-sysusers.service has created /etc/passwd. We can't
have it both ways: the units that want to have a fully writable root file
system cannot be ordered before units which are required to do file system
preparation.

Instead of trying to order firstboot very early, let's let it do its thing even
if it is started later. Instead of refusing to create to the root account if
/etc/passwd and /etc/shadow exist, actually check if the account is configured.
Now sysusers writes root account with password PASSWORD_UNPROVISIONED
("!unprovisioned"), and then firstboot checks for this, and will configure root
in this case.

This allows sysusers to be executed earlier (or accounts to be set up earlier
in another way).

This effectively reverts b825ab1a99b69956057c79838faaf7b44afee474.

12 months agoshared/condition: add envvar override for the check for first-boot
Zbigniew Jędrzejewski-Szmek [Thu, 13 Oct 2022 12:05:01 +0000 (14:05 +0200)] 
shared/condition: add envvar override for the check for first-boot

Before 7cd43e34c5a302ff323c013f437092d2ff5ccbbf, it was possible to use
SYSTEMD_PROC_CMDLINE=systemd.condition-first-boot to override autodetection.
But now this doesn't work anymore, and it's useful to be able to do that for
testing.

12 months agosysusers: fix argument confusion in error message
Zbigniew Jędrzejewski-Szmek [Thu, 13 Oct 2022 12:51:28 +0000 (14:51 +0200)] 
sysusers: fix argument confusion in error message

Bug introduced in 335f6ab4f13abcd8073fe84f2a3c70c67271126e. pw/sp are totally
wrong in this context, most likely NULL.

12 months agosysusers: add usual "ret_" prefix, fix messages
Zbigniew Jędrzejewski-Szmek [Thu, 13 Oct 2022 11:39:17 +0000 (13:39 +0200)] 
sysusers: add usual "ret_" prefix, fix messages

We had 'make backup x'. 'make backup of x' would be correct, but 'backup x' is
shorter and to the point.

12 months agounits: create /dev with --graceful first, allow sysusers to run later
Zbigniew Jędrzejewski-Szmek [Sun, 9 Oct 2022 17:02:27 +0000 (19:02 +0200)] 
units: create /dev with --graceful first, allow sysusers to run later

We want to call systemd-tmpfiles-setup-dev.service to create /dev/fuse and
other device nodes so that module probing will work. But it is possible that
when we're in first boot, some users or groups need to be created by
systemd-sysusers first. But it is also possible that systemd-sysusers cannot
actually execute configuration because the root partition is not fully writable
yet. So let systemd-tmpfiles-setup-dev.service run earlier, possibly without
all users and groups in place. Since systemd-tmpfiles-setup-dev.service writes
to /dev only, it doesn't care how the root partition is mounted. In this early
run, some some nodes might be created with default permissions (i.e. not
accessible to non-root users or groups). This should be OK for the early boot
phase. Afterwards, we let systemd-tmpfiles-setup.service execute full
configuration. We will configure any files in /dev twice, but considering that
there's only a few of them and that the second run should only adjust ownership
and permissions, this should be OK. This way, we avoid the dependency loop.

12 months agoman: extend description of --boot
Zbigniew Jędrzejewski-Szmek [Sun, 9 Oct 2022 16:58:01 +0000 (18:58 +0200)] 
man: extend description of --boot

12 months agorepart: do not require /var/tmp if not used
Zbigniew Jędrzejewski-Szmek [Tue, 23 May 2023 10:28:55 +0000 (12:28 +0200)] 
repart: do not require /var/tmp if not used

If systemd-repart is running sufficiently early, /var/tmp might not be in place
yet. But if there is nothing to minimize, we won't even use it. Let's move the
check right before the first use.

systemd-repart[441]: Device '/' has no dm-crypt/dm-verity device, no need to look for…
systemd-repart[441]: Device /dev/sda opened and locked.
systemd-repart[441]: Sector size of device is 512 bytes. Using grain size of 4096.
systemd-repart[441]: Could not determine temporary directory: No such file or directory
systemd[1]: systemd-repart.service: Child 441 belongs to systemd-repart.service.
systemd[1]: systemd-repart.service: Main process exited, code=exited, status=1/FAILURE
systemd[1]: systemd-repart.service: Failed with result 'exit-code'.

12 months agotmpfiles: add --graceful
Zbigniew Jędrzejewski-Szmek [Sun, 9 Oct 2022 16:57:25 +0000 (18:57 +0200)] 
tmpfiles: add --graceful

See the man page diff for description.

12 months agobasic/user-util: return -ESRCH if passwd/group are missing
Zbigniew Jędrzejewski-Szmek [Tue, 23 May 2023 10:07:13 +0000 (12:07 +0200)] 
basic/user-util: return -ESRCH if passwd/group are missing

12 months agosd-bus: refuse to send messages with an invalid string
Yu Watanabe [Thu, 18 May 2023 19:33:39 +0000 (04:33 +0900)] 
sd-bus: refuse to send messages with an invalid string

Prompted by aaf7b0e41105d7b7cf30912cdac32820f011a219 and
4804da58536ab7ad46178a03f4d2da49fd8e4ba2.

12 months agotmpfiles: align table
Zbigniew Jędrzejewski-Szmek [Sun, 9 Oct 2022 16:36:43 +0000 (18:36 +0200)] 
tmpfiles: align table

12 months agofirstboot: clarify that machine-id options are only offline, add missing docs
Zbigniew Jędrzejewski-Szmek [Mon, 3 Oct 2022 09:04:24 +0000 (11:04 +0200)] 
firstboot: clarify that machine-id options are only offline, add missing docs

Let's flat out refuse to configure machine-id on a running system with
systemd-firstboot. It wouldn't work anyway, because by the time firstboot is
started, pid1 has created /etc/machine-id, possibly with "unitialized", so
firstboot wouldn't touch the file. (If --force is specified, it works. So
let's allow that in case people want to do crazy things.)

While at it, add missing descriptions of various things that were added over
time, and group descriptions of similar options together.

12 months agounits: make sure proc-sys-binfmt_misc.automount is actually stopped
Zbigniew Jędrzejewski-Szmek [Fri, 30 Sep 2022 14:05:54 +0000 (16:05 +0200)] 
units: make sure proc-sys-binfmt_misc.automount is actually stopped

As with other units, stopping of the automount requires actual work,
and without the ordering dependency systemd might not execute the stop
job before shutdown.target is reached and units ordered after that are
executed.

12 months agounits/systemd-repart: stop pretending that root config is executed in the initrd
Zbigniew Jędrzejewski-Szmek [Thu, 15 Sep 2022 14:12:05 +0000 (16:12 +0200)] 
units/systemd-repart: stop pretending that root config is executed in the initrd

I have a system with /usr/lib/repart.d/50-root.conf with GrowFileSystem=yes.
The partition wouldn't be resized in the initrd, because
ConditionDirectoryNotEmpty=|/sysusr/usr/lib/repart.d was evaluated very early,
before /sysroot was mounted. There was no ordering dependency between
systemd-repart.service and sysroot.mount. (There was After=initrd-usr-fs.target,
but it seems to be only referred to by systemd-fstab-generator, which in my
case doesn't even run, because there's no fstab.)

But in fact, we neeed to run systemd-repart in the initrd only in limited
circumstances: when we need to create the root device based on config under
sysusr.mount. If there is config on the root device, it can be executed in
the host system, early during boot. Thus, let's remove the condition on
/sysroot/…. Without an ordering dependency on sysroot.mount, it was subject to
a race condition anyway. (A race condition with a low probability of "winning",
because systemd-repart.service has no dependencies, but sysroot.mount requires
a device to be detected and the mount to happen.)

The other problem was that systemd-repart.service didn't have the ordering wrt.
initrd-switch-root.target, so it was subject to the same race condition that
was fixed for other units in 7c0e2b555968d70ac563a37e32a6931ee90961a6. (If the
systemd-repart.service/stop job is slow, we could end up not restarting
systemd-repart.service in the host system.)

With the changes here, I see systemd-repart.service/start running twice:
in the initrd it is skipped because the conditions fail, and then in the
host system it runs normally.

Note: support for /sysroot is retained in systemd-repart code. I don't see a
strong reason to remove it, since it may still be useful to people invoking
repart in the initrd in other circumstances.

12 months agoshared/generator: apply similar config reordering of generated units
Zbigniew Jędrzejewski-Szmek [Wed, 28 Sep 2022 11:38:56 +0000 (13:38 +0200)] 
shared/generator: apply similar config reordering of generated units

12 months agounits: do more reordering of ordering config
Zbigniew Jędrzejewski-Szmek [Thu, 15 Sep 2022 13:54:18 +0000 (15:54 +0200)] 
units: do more reordering of ordering config

No functional change, just a cleanup to make the subsequent changes easier to
see. This is a continuation of 9810e419425263bde86787bc21251f1ad3c35628

> The block is reordered and split to have:
>    1. description + documentation
>    2. (optionally) conditions
>    3. all the dependencies

The dependencies for shutdown.target are listed separately because they are the
other deps are for startup, and shutdown.target only matter much later.