1
0
mirror of https://github.com/systemd/systemd.git synced 2024-12-25 01:34:28 +03:00
Commit Graph

65088 Commits

Author SHA1 Message Date
Frantisek Sumsal
878ec7942f coverage: add a wrapper for execvpe()
It's the exactly same stuff as for execveat() - gcov doesn't have a
wrapper for execvpe() so introduce our own.
2023-06-02 16:25:06 +02:00
Frantisek Sumsal
1326d2dd05 test: sync with the fake binary before killing it
On faster machines we might be too fast and kill the fake binary during
fork() which then makes kernel report a "wrong" binary in the coredump,
e.g.:

[   31.408078] testsuite-74.sh[548]: + /tmp/make-dump /tmp/test-dump SIGTRAP
[   31.409720] testsuite-74.sh[560]: + bin=/tmp/test-dump
[   31.409720] testsuite-74.sh[560]: + sig=SIGTRAP
[   31.409720] testsuite-74.sh[560]: + ulimit -c unlimited
[   31.409720] testsuite-74.sh[560]: + pid=561
[   31.409720] testsuite-74.sh[560]: + sleep 1
[   31.409720] testsuite-74.sh[560]: + kill -s SIGTRAP 561
[   31.409720] testsuite-74.sh[560]: + wait 561
[   31.491757] systemd[1]: Created slice system-systemd\x2dcoredump.slice.
[   31.524488] systemd[1]: Started systemd-coredump@0-563-0.service.
[   31.616372] systemd-coredump[564]: [🡕] Process 561 (make-dump) of user 0 dumped core.

                                      Stack trace of thread 561:
                                      #0  0x00007ff86bb49af7 _Fork (libc.so.6 + 0xd4af7)
                                      #1  0x00007ff86bb4965f __libc_fork (libc.so.6 + 0xd465f)
                                      #2  0x000055e88011b0ad make_child (bash + 0x550ad)
                                      #3  0x000055e8800fd05f n/a (bash + 0x3705f)
                                      #4  0x000055e880100116 execute_command_internal (bash + 0x3a116)
                                      #5  0x000055e8801011f2 execute_command_internal (bash + 0x3b1f2)
                                      #6  0x000055e8801025b6 execute_command (bash + 0x3c5b6)
                                      #7  0x000055e8800f134b reader_loop (bash + 0x2b34b)
                                      #8  0x000055e8800e757d main (bash + 0x2157d)
                                      #9  0x00007ff86ba98850 n/a (libc.so.6 + 0x23850)
                                      #10 0x00007ff86ba9890a __libc_start_main (libc.so.6 + 0x2390a)
                                      #11 0x000055e8800e83b5 _start (bash + 0x223b5)
                                      ELF object binary architecture: AMD x86-64
[   31.666617] testsuite-74.sh[560]: /tmp/make-dump: line 12:   561 Trace/breakpoint trap   (core dumped) "$bin" infinity
...
$ coredumpctl list --file system.journal
TIME                         PID UID GID SIG     COREFILE EXE            SIZE
Fri 2023-06-02 10:42:10 CEST 561   0   0 SIGTRAP journal  /usr/bin/bash     -
Fri 2023-06-02 10:42:11 CEST 570   0   0 SIGABRT journal  /tmp/test-dump    -
Fri 2023-06-02 10:42:12 CEST 582   0   0 SIGTRAP missing  /tmp/test-dump    -
Fri 2023-06-02 10:42:13 CEST 593   0   0 SIGABRT missing  /tmp/test-dump    -
2023-06-02 13:24:32 +02:00
Frantisek Sumsal
e8ee168344 test: clean up our mess after the pstore test 2023-06-02 10:07:57 +02:00
Frantisek Sumsal
014e811e86
Merge pull request #27891 from mrc0mmand/more-tests-again
test: improve systemd-pstore tests & add a couple of tests for systemd-run
2023-06-02 10:05:17 +02:00
Lennart Poettering
881d616ee0
Merge pull request #27889 from poettering/no-usr-verity-detach
veritysetup: make sure we don't try to detach /usr/ verity on shutdown
2023-06-02 06:24:13 +02:00
Frantisek Sumsal
dee4a9923b test: add a couple of tests for systemd-run 2023-06-01 23:12:47 +02:00
Frantisek Sumsal
f8b21a08aa socket: avoid memory leak on incomplete SocketPort object
==1==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 17 byte(s) in 1 object(s) allocated from:
    #0 0x7fc096c7243b in strdup (/lib64/libasan.so.8+0x7243b)
    #1 0x7fc095db3899 in bus_socket_set_transient_property ../src/core/dbus-socket.c:386
    #2 0x7fc095db5140 in bus_socket_set_property ../src/core/dbus-socket.c:460
    #3 0x7fc095dd20f1 in bus_unit_set_properties ../src/core/dbus-unit.c:2473
    #4 0x7fc095d87d53 in transient_unit_from_message ../src/core/dbus-manager.c:1025
    #5 0x7fc095d8872f in method_start_transient_unit ../src/core/dbus-manager.c:1112
    #6 0x7fc0944ddf4f in method_callbacks_run ../src/libsystemd/sd-bus/bus-objects.c:406
    #7 0x7fc0944e7854 in object_find_and_run ../src/libsystemd/sd-bus/bus-objects.c:1319
    #8 0x7fc0944e8f03 in bus_process_object ../src/libsystemd/sd-bus/bus-objects.c:1439
    #9 0x7fc09454ad78 in process_message ../src/libsystemd/sd-bus/sd-bus.c:3011
    #10 0x7fc09454b302 in process_running ../src/libsystemd/sd-bus/sd-bus.c:3053
    #11 0x7fc09454e158 in bus_process_internal ../src/libsystemd/sd-bus/sd-bus.c:3273
    #12 0x7fc09454e2f2 in sd_bus_process ../src/libsystemd/sd-bus/sd-bus.c:3300
    #13 0x7fc094551a59 in io_callback ../src/libsystemd/sd-bus/sd-bus.c:3642
    #14 0x7fc094727830 in source_dispatch ../src/libsystemd/sd-event/sd-event.c:4187
    #15 0x7fc094731009 in sd_event_dispatch ../src/libsystemd/sd-event/sd-event.c:4808
    #16 0x7fc094732124 in sd_event_run ../src/libsystemd/sd-event/sd-event.c:4869
    #17 0x7fc095f7af9f in manager_loop ../src/core/manager.c:3242
    #18 0x41cc7c in invoke_main_loop ../src/core/main.c:1937
    #19 0x4252e0 in main ../src/core/main.c:3072
    #20 0x7fc092a4a50f in __libc_start_call_main (/lib64/libc.so.6+0x2750f)

SUMMARY: AddressSanitizer: 17 byte(s) leaked in 1 allocation(s).
2023-06-01 22:14:59 +02:00
Hannu Lounento
673ed95966 man: fix sd_journal_*_with_location's func argument
`sd_journal_print_with_location` and similar functions behave
inconsistently compared to their documentation, which says:

    sd_journal_print_with_location(), sd_journal_printv_with_location(),
    sd_journal_send_with_location(), sd_journal_sendv_with_location(),
    and sd_journal_perror_with_location() [...] accept additional
    parameters to explicitly set the source file name, function, and
    line. Those arguments must contain valid journal entries including
    the variable name, e.g. "CODE_FILE=src/foo.c", "CODE_LINE=666",
    "CODE_FUNC=myfunc".

Calling e.g. `sd_journal_sendv_with_location` with
`CODE_FUNC=myfunction` as the value of the argument `func` results in

    "CODE_FUNC" : "CODE_FUNC=myfunction"

because `sd_journal_*_with_location` implicitly prefix the argument
`func` with `CODE_FUNC=`. For example:

    _public_ int sd_journal_sendv_with_location(
                    const char *file, const char *line,
                    const char *func,
                    const struct iovec *iov, int n) {
            [...]
            char *f;
            [...]
            niov = newa(struct iovec, n + 3);
            [...]
            ALLOCA_CODE_FUNC(f, func);
            [...]
            niov[n++] = IOVEC_MAKE_STRING(f);

            return sd_journal_sendv(niov, n);
    }

where `ALLOCA_CODE_FUNC` is:

    #define ALLOCA_CODE_FUNC(f, func)                 \
            do {                                      \
                    size_t _fl;                       \
                    const char *_func = (func);       \
                    char **_f = &(f);                 \
                    _fl = strlen(_func) + 1;          \
                    *_f = newa(char, _fl + 10);       \
                    memcpy(*_f, "CODE_FUNC=", 10);    \
                    memcpy(*_f + 10, _func, _fl);     \
            } while (false)

The arguments `file` and `line` are _not_ prefixed similarly but
expected to be prefixed already with `CODE_FILE=` and `CODE_LINE=`
respectively and sent as is like the documentation describes.

That is, the argument `func` is treated differently and behaves
inconsistently compared to the arguments `file` and `line`. The behavior
seems still intentional:

    _public_ int sd_journal_printv_with_location(int priority, const char *file, const char *line, const char *func, const char *format, va_list ap) {
            [...]
            /* func is initialized from __func__ which is not a macro, but
            * a static const char[], hence cannot easily be prefixed with
            * CODE_FUNC=, hence let's do it manually here. */
            ALLOCA_CODE_FUNC(f, func);
            [...]
    }

Thus, change the documentation to match the actual behavior.

Note: `sd_journal_{print,send}` and `sd_journal_{print,send}v` work as
expected as they only pass the function name (i.e. without `CODE_FUNC=`)
to the `func` argument of the `sd_journal_*_with_location` functions
they call. For example:

    #define sd_journal_print(priority, ...) sd_journal_print_with_location(priority, "CODE_FILE=" __FILE__, "CODE_LINE=" _SD_STRINGIFY(__LINE__), __func__, __VA_ARGS__)
2023-06-01 20:25:21 +01:00
Frantisek Sumsal
b86ed7f710 dbus-util: let's take it down a notch when converting file mode to string
I'm definitely a fan of precision, but in this case it's a bit too much:

    $ systemd-run --unit=test --socket-property=ListenFIFO=/tmp/foo --socket-property=SocketMode=0644 true
    $ systemctl cat test.socket
    # /run/systemd/transient/test.socket
    # This is a transient unit file, created programmatically via the systemd API. Do not edit.
    [Unit]
    Description=/usr/bin/true

    [Socket]
    ListenFIFO=/tmp/foo
    SocketMode=0000000000000000000000000000000000000644
2023-06-01 20:33:17 +02:00
Frantisek Sumsal
6178ced491 test: make the multiple-file test more thorough
Let's check if we keep the old records after multiple systemd-pstore
invocations (i.e. simulate a scenario where we get multiple crashes and
multiple machine reboots).
2023-06-01 20:06:40 +02:00
Lennart Poettering
45e3406e23 veritysetup: remove double escaping of data device + hash device spec
generator_write_veritysetup_service_section() already escapes the
parameters internally, doing so in the caller means double escaping,
which is a bug. Fix it.
2023-06-01 19:15:10 +02:00
Lennart Poettering
deb60ef92e veritysetup: minor renaming of functions
create_device() and create_disk() so far did very similar things, but
the name didn't give a hint what the difference was.

Hence let's rename them to create_special_device() and
create_veritytab_device() to make this more understandabe, as one
creates /proc/cmdline specified roothash=/usrhash= devices, and the
other one devices for items listed in /etc/veritytab.

No code changes besides renaming.
2023-06-01 19:06:20 +02:00
Lennart Poettering
ffe0da297d {crypt|verity}setup: mention volume name in some error messages 2023-06-01 18:49:43 +02:00
Lennart Poettering
ce49a479d2 {crypt|verity}setup: replace dep on systemd-tmpfiles-setup-dev.service by modprobe@loop.service
Both should have the same effect: the /dev/loop-control devices should
become available. systemd-tmpfiles-setup-dev.service creates the device
node "dry" based on modalias data, while modprobe@loop.service creates
it fully, because the module backing it is loaded properly. This should
shorten the deps chain a bit, simplify things and allows us to focus on
the stuff we actually need (i.e. the loopback infra) instead of all
entrypoints anyone might possibly need (i.e. the device nodes)
2023-06-01 18:49:43 +02:00
Lennart Poettering
5dd0214707 veritysetup-generator: only generate one set of deps on systemd-tmpfiles-setup-dev.service
If both the data and the hash device are a regular file we might create
two sets of deps on s-t-s-d.s, which is of course redundant. Shorten the
code to only generate this once.

No change in behaviour.
2023-06-01 18:49:43 +02:00
Lennart Poettering
bf1484c70a veritysetup-generator: imply x-initrd.attach for "usr" and "root" volumes
Similar to the previous commit, just vor Verity rather than LUKS.
2023-06-01 18:49:43 +02:00
Lennart Poettering
8ce02b87ce cryptsetup-generator: imply x-initrd.attach for "usr" and "root" volumes
Let's imply "x-initrd.attach" for "usr" and "root" volumes, so that
we do not attempt to umount them anymore during shutdown.

The names of these volumes have been mandated by the Discoverable
Partition Spec:

https://uapi-group.org/specifications/specs/discoverable_partitions_specification/#suggested-mode-of-operation

Hence it appears reasonably safe to special case these volume names.

Note that a similar logic is implemented in fstab-generator and in fact
PID 1 to treat the root mount and /usr/ mount specially too, to avoid
trying to umount it at shutdown. (This is what fstab_is_extrinsic()
checks).

This should ensure that if /usr/ or / is for some reason a LUKS medium
we won't try to detach it during runtime, which likely fails, since we
run off it.

Note this also moves an ordering dep towards umount.target under the
x-initrd.attach check, becasue that's where the crucial conflicts dep is
placed too.
2023-06-01 18:49:43 +02:00
Lennart Poettering
d120ce478d units: don't stop blockdev@.target unit at shutdown
We want that cryptsetup/veritysetup devices can stick around until the
very end, as well as the users of them which might depend on
blockdev@.target for the devices. Hence leave the targets around till
the very end.

Note that their runtime is managed via StopWhenUnneeded= anyway, hence
unless their are volumes that actually survive still the very end they
target units will still be stopped.
2023-06-01 18:49:43 +02:00
Lennart Poettering
7a2f3194ff units: set DefaultDependencies=no for veritysetup slice
This mimics what we already have for cryptsetup services: the slice they
are placed in (they have their own slice since that's what we do by
default for instantiated services) shouldn't conflict with
shutdown.target, so that veritysetup services can stay around until the
very end (which is what we want for the root and usr verity volumes).

It's literally just a copy of the same unit we already have for
cryptsetup, just with an updated description string.
2023-06-01 18:49:43 +02:00
Lennart Poettering
953006dcb0 veritysetup-generator: use generic veritysetup writers at one more place
Let's use the common generator_write_veritysetup_unit_section(),
ggenerator_write_veritysetup_service_section(), generator_add_symlink()
implementation we already have at one more place.

This mostly generates the same unit, but for the first time hooks up
blockdev@dev-mapper-*.device for the device, which means things like
growfs on usr+root volumes will actually work now. (I mean, growfs
won#t, because verity devices are immutable after all, but things *like*
it that want to run between the device popping up and being mounted.)
2023-06-01 18:49:43 +02:00
Lennart Poettering
6747d9a13f cryptsetup: fix whitespace issue 2023-06-01 18:49:16 +02:00
Lennart Poettering
d4ea4ebc39 fstab-util: drop redundant check
fstab_test_option() checks this as first thing anyway, hence let's drop
the redundant check.
2023-06-01 17:17:42 +02:00
Yu Watanabe
45a6a2aace sd-journal: fix assignment of tail entry offset
Fixes a bug introduced by 206f0f397e.
2023-06-01 17:04:10 +02:00
dependabot[bot]
7cd4f577e8 build(deps): bump github/codeql-action from 2.2.9 to 2.3.5
Bumps [github/codeql-action](https://github.com/github/codeql-action) from 2.2.9 to 2.3.5.
- [Release notes](https://github.com/github/codeql-action/releases)
- [Changelog](https://github.com/github/codeql-action/blob/main/CHANGELOG.md)
- [Commits](04df1262e6...0225834cc5)

---
updated-dependencies:
- dependency-name: github/codeql-action
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 21:57:36 +08:00
dependabot[bot]
da92fd4612 build(deps): bump meson from 1.1.0 to 1.1.1 in /.github/workflows
Bumps [meson](https://github.com/mesonbuild/meson) from 1.1.0 to 1.1.1.
- [Release notes](https://github.com/mesonbuild/meson/releases)
- [Commits](https://github.com/mesonbuild/meson/compare/1.1.0...1.1.1)

---
updated-dependencies:
- dependency-name: meson
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 21:15:21 +09:00
Frantisek Sumsal
57130ca01b test: make TEST-04 stable once again
Wait a bit if necessary for the cursor file to appear.

Follow-up fb35feae97.
2023-06-01 21:11:21 +09:00
Yu Watanabe
17bd68ca74
Merge pull request #27874 from keszybz/test-bus-server-shortening
Simplify the code in test-bus-server
2023-06-01 21:10:55 +09:00
Lennart Poettering
614ac89d30 test-sizeof: let's be a tiny bit more careful when using glibc internal types
One can argue that internal glibc types (i.e. those starting with __)
are not really part of the glibc API, hence let's at least ifdef them.
2023-06-01 21:10:04 +09:00
dependabot[bot]
9a1ac3a019 build(deps): bump redhat-plumbers-in-action/advanced-issue-labeler
Bumps [redhat-plumbers-in-action/advanced-issue-labeler](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler) from 2.0.4 to 2.0.6.
- [Release notes](https://github.com/redhat-plumbers-in-action/advanced-issue-labeler/releases)
- [Commits](25a1e41826...71bcf99aef)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/advanced-issue-labeler
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 12:22:14 +02:00
dependabot[bot]
c9401e6c6d build(deps): bump actions/labeler from 4.0.3 to 4.0.4
Bumps [actions/labeler](https://github.com/actions/labeler) from 4.0.3 to 4.0.4.
- [Release notes](https://github.com/actions/labeler/releases)
- [Commits](ba790c862c...0776a67936)

---
updated-dependencies:
- dependency-name: actions/labeler
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 12:21:34 +02:00
dependabot[bot]
6138a85d10 build(deps): bump redhat-plumbers-in-action/differential-shellcheck
Bumps [redhat-plumbers-in-action/differential-shellcheck](https://github.com/redhat-plumbers-in-action/differential-shellcheck) from 4.0.2 to 4.2.2.
- [Release notes](https://github.com/redhat-plumbers-in-action/differential-shellcheck/releases)
- [Changelog](https://github.com/redhat-plumbers-in-action/differential-shellcheck/blob/main/docs/CHANGELOG.md)
- [Commits](d24099b9f3...ac4483d8c6)

---
updated-dependencies:
- dependency-name: redhat-plumbers-in-action/differential-shellcheck
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
2023-06-01 12:20:55 +02:00
Zbigniew Jędrzejewski-Szmek
fcc54d1dfe
Merge pull request #27856 from arianvp/fix-bootctl-status
bootctl: Print version number of detected binaries again
2023-06-01 10:25:30 +02:00
Zbigniew Jędrzejewski-Szmek
70b1676578 test-bus-server: simplify return value handling
Follow-up for f7794e423a.
2023-06-01 09:57:23 +02:00
Zbigniew Jędrzejewski-Szmek
fa18faf1c0 various: remove typo/unusual spelling
Wikitionary says that "noone" is known, but not preferred by a large margin.
(It's also an obsolete spelling of "noon".)
2023-06-01 09:56:14 +02:00
Yu Watanabe
041d8ad857
Merge pull request #27796 from yuwata/memstream-util
util: introduce memstream-util
2023-06-01 12:07:17 +09:00
Rene Hollander
930133d5df networkd/dhcpserver: Save and expose the client hostname sent when requesting a DHCP lease.
DHCP clients often send their own hostname in option 12. It can be useful
to store it with the lease so it can be shown to a human to easily identify
which lease belongs to which device.

RFC: https://www.rfc-editor.org/rfc/rfc2132#section-3.14
2023-06-01 06:51:45 +09:00
Yu Watanabe
2485b7e2b8 tree-wide: use memstream-util 2023-06-01 06:48:47 +09:00
Yu Watanabe
abe72100cf util: introduce memstream-util
There is many pitfalls in using memstream.
Let's introduce a wrapper to make us safely use it.
2023-06-01 06:48:43 +09:00
Yu Watanabe
24b0c6c2c9 calendarspec: rename arguments 2023-06-01 06:47:48 +09:00
Yu Watanabe
a694747d45 elf-util: rename stack_context_destroy() -> stack_context_done() 2023-06-01 06:47:48 +09:00
Yu Watanabe
3256e2027b sd-bus: rename introspect_free() -> introspect_done 2023-06-01 06:47:48 +09:00
Yu Watanabe
5d2a48da12 tree-wide: use _cleanup_set_free_ and friends
Instead of _cleanup_(set_freep) or so.
2023-06-01 06:47:48 +09:00
Yu Watanabe
64377c6089 oomd: drop unused key 2023-06-01 06:47:48 +09:00
Yu Watanabe
cc4d38b14b core/cgroup: fix setting SocketBindAllow=/SocketBindDeny= through DBus 2023-06-01 06:47:48 +09:00
Michal Sekletar
89e9df12b3 core/transaction: drop job that has unfulfilled required (Requires, BindsTo) dependencies
Resolves: #11338
2023-06-01 06:45:51 +09:00
Mike Yuan
d9689a35f9 man: vconsole.conf: replace the hardcoded keymap with build-time default
Follow-up for #26089
2023-06-01 06:33:13 +09:00
Frantisek Sumsal
4c709f3908 test: skip the test early if we're built without systemd-homed
We check for homed stuff in the test itself, but this is way too late,
since we already started a unit that Requires=systemd-homed.service
(testsuite-46.service). For now this doesn't matter, but with #27852
the offending transaction is dropped from the job queue, making the test
fail.

Spotted in #27852 in Ubuntu CI.
2023-06-01 06:30:45 +09:00
Yu Watanabe
322bda8241
Merge pull request #27826 from yuwata/network-link-ready-without-ndisc-when-has-static-address
network: do not request dynamic addressing protocols finished when at…
2023-06-01 06:29:55 +09:00
Daan De Meyer
7d52bf16e7
Merge pull request #27628 from ddstreet/tpm2_header_cleanup
Tpm2 header cleanup
2023-05-31 23:06:14 +02:00
Daan De Meyer
c4b7e0f812
Merge pull request #27844 from DaanDeMeyer/repart-arch
repart: Add --architecture option
2023-05-31 23:00:19 +02:00