1
1
mirror of https://github.com/systemd/systemd-stable.git synced 2024-12-24 21:34:08 +03:00
Commit Graph

60487 Commits

Author SHA1 Message Date
Daan De Meyer
e81710d3d0 journal: Store offsets to tail entry array objects in chain
Previously, we'd iterate an entry array from start to end every time
we added an entry offset to it. To speed up this operation, we cache
the last entry array in the chain and how many items it contains.
This allows the addition of an entry to the chain to be done in
constant time instead of linear time as we don't have to iterate
the entire chain anymore every time we add an entry.
2022-10-07 12:28:09 +02:00
Daan De Meyer
0e35afff1d journal: Introduce journal_file_data_payload()
journal_file_data_payload() retrieves the payload of a Data object,
optionally decompressing it and checking to see if matches a given
field. This function replaces all the decompression code in the sd-journal
codebase with a single function.

This commit should not introduce any changes in sd-journal behavior.
2022-10-07 12:28:05 +02:00
Daan De Meyer
a9089a6604 journal: Use 32-bit entry item object offsets in compact mode
To do this, we move EntryItem out of journal-def.h and turn it into
a host only struct in native endian mode so we can still use it to
ship the necessary info around.

Aside from that, the changes are pretty simple, we introduce some
extra functions to access the right field depending on the mode and
convert all the other code to use those functions instead of
accessing the raw fields.

We also drop the unused entry item hash field in compact mode. We
already stopped doing anything with this field a while ago, now we
actually drop it from the format in compact mode.
2022-10-07 12:20:57 +02:00
Daan De Meyer
99daf3ce03 journal: Use 32-bit entry array offsets in compact mode
Before:

OBJECT TYPE      ENTRIES SIZE
Unused           0       0B
Data             3610336 595.7M
Field            5310    285.2K
Entry            3498326 1.2G
Data Hash Table  29	 103.1M
Field Hash Table 29      151.3K
Entry Array      605991  1011.6M
Tag              0	 0B
Total            7720021 2.9G

After:

OBJECT TYPE      ENTRIES SIZE
Unused           0	 0B
Data             3562667 591.0M
Field            3971    213.6K
Entry            3498566 1.2G
Data Hash Table  20	 71.1M
Field Hash Table 20	 104.3K
Entry Array	 582647  505.0M
Tag              0	 0B
Total            7647891 2.4G
2022-10-07 12:20:08 +02:00
Daan De Meyer
d06727aec2 journal: Don't allocate objects above UINT32_MAX in compact mode
To allow storing offsets as 32-bit, we should never allocate objects
outside of the 32-bit range.
2022-10-07 12:20:08 +02:00
Daan De Meyer
c92f1ebe5d journal: Run unit tests with and without compact mode enabled 2022-10-07 12:16:11 +02:00
Yu Watanabe
02dfb6a3c9
Merge pull request #24930 from yuwata/network-drop-ndisc-vacuum
network: further follow-ups for recent NDisc PRs
2022-10-07 18:38:34 +09:00
Yu Watanabe
261979ed85
Merge pull request #24931 from bluca/news
hwdb and NEWS
2022-10-07 18:38:18 +09:00
Daan De Meyer
61297656c7 journal: Enable compact mode
We also add an environment variable $SYSTEMD_JOURNAL_COMPACT that
can be used to disable compact mode if needed (similar to
$SYSTEMD_JOURNAL_KEYED_HASH).
2022-10-07 11:28:12 +02:00
Daan De Meyer
87413812c9 journal: Add compact mode
This adds a new flag in preparation for incompatible journal changes
which will be gated behind this flag. The max file size of journal
files in compact mode is limited to 4 GiB.
2022-10-07 11:26:28 +02:00
Luca Boccassi
42c25d70f6 Update hwdb
ninja -C build update-hwdb
2022-10-07 11:00:28 +02:00
Luca Boccassi
23992ce1e9 NEWS: list contributors 2022-10-07 11:00:27 +02:00
Luca Boccassi
167420a394 NEWS: typos 2022-10-07 11:00:27 +02:00
Yu Watanabe
b3fac19f1b network: free timer event source for NDisc when link is freed
Though, it should be already freed already freed in link_stop_engines()
-> ndisc_stop(). Just for safety.
2022-10-07 14:32:13 +09:00
Yu Watanabe
44085d63f0 network: drop unnecessary call of ndisc_vacuum()
After the commit 773024685b, DNS servers
or domains are dropped when their lifefime become zero. Hence, it is not
necessary to try to them when writing state file.

Of course, because of the accuracy of the timer event source or priority
of event sources, a possibility is introduced that a DNS server or domain
with zero lifetime is stored in the state file. However, such entry will
be dropped soon when the timer event source is triggered. Hence, that
should not cause any real issues.
2022-10-07 14:17:28 +09:00
Zbigniew Jędrzejewski-Szmek
c76691d708
Merge pull request #24511 from martinetd/bpf1
libbpf: Add libbpf 1.0.0 compat
2022-10-06 19:01:33 +02:00
Arnaud Ferraris
5113436b05 repart: always honour --discard=no
Currently, even if `--discard=no` is passed to `systemd-repart`, the
`context_discard_gap_after()` function still runs normally, discarding
e.g. all blocks between the GPT and the start of the first partition.

This can lead to issues on some embedded devices, where this space
holds the bootloader and shouldn't be modified (creating a protective
partition there is not always possible due to the specifics of the boot
process of some ARM-based SoC's).

This commit ensures passing `--discard=no` would be enough to ensure
the bootloader isn't wiped in such cases.

Signed-off-by: Arnaud Ferraris <arnaud.ferraris@gmail.com>
2022-10-06 17:27:47 +02:00
Michal Koutný
3286770daa meson: Require TPM2 for measuring utilities
I happened to run build with openssl but no tpm2 and ran into issues
like:

        [313/1382] Compiling C object systemd-measure.p/src_boot_measure.c.o
        FAILED: systemd-measure.p/src_boot_measure.c.o
        cc -Isystemd-measure.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -fno-omit-frame-pointer -Werror=shadow -include config.h -DOPENSSL_LOAD_CONF -MD -MQ systemd-measure.p/src_boot_measure.c.o -MF systemd-measure.p/src_boot_measure.c.o.d -o systemd-measure.p/src_boot_measure.c.o -c ../src/boot/measure.c
        ../src/boot/measure.c: In function ‘verb_sign’:
        ../src/boot/measure.c:710:48: error: variable ‘c’ has initializer but incomplete type
          710 |         _cleanup_(tpm2_context_destroy) struct tpm2_context c = {};

        [308/1382] Compiling C object systemd-pcrphase.p/src_boot_pcrphase.c.o
        FAILED: systemd-pcrphase.p/src_boot_pcrphase.c.o
        cc -Isystemd-pcrphase.p -I. -I.. -Isrc/basic -I../src/basic -Isrc/fundamental -I../src/fundamental -Isrc/systemd -I../src/systemd -I../src/libsystemd/sd-bus -I../src/libsystemd/sd-device -I../src/libsystemd/sd-event -I../src/libsystemd/sd-hwdb -I../src/libsystemd/sd-id128 -I../src/libsystemd/sd-journal -I../src/libsystemd/sd-netlink -I../src/libsystemd/sd-network -I../src/libsystemd/sd-resolve -Isrc/shared -I../src/shared -fdiagnostics-color=always -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -Wextra -std=gnu11 -O0 -g -Wno-missing-field-initializers -Wno-unused-parameter -Wdate-time -Wendif-labels -Werror=format=2 -Werror=format-signedness -Werror=implicit-function-declaration -Werror=incompatible-pointer-types -Werror=int-conversion -Werror=overflow -Werror=override-init -Werror=return-type -Werror=shift-count-overflow -Werror=shift-overflow=2 -Werror=undef -Wfloat-equal -Wimplicit-fallthrough=5 -Winit-self -Wlogical-op -Wmissing-include-dirs -Wmissing-noreturn -Wnested-externs -Wold-style-definition -Wpointer-arith -Wredundant-decls -Wshadow -Wstrict-aliasing=2 -Wstrict-prototypes -Wsuggest-attribute=noreturn -Wunused-function -Wwrite-strings -Wno-unused-result -Werror=missing-declarations -Werror=missing-prototypes -fdiagnostics-show-option -fno-common -fno-strict-aliasing -fstack-protector -fstack-protector-strong -fvisibility=hidden --param=ssp-buffer-size=4 -fno-omit-frame-pointer -Werror=shadow -include config.h -DOPENSSL_LOAD_CONF -MD -MQ systemd-pcrphase.p/src_boot_pcrphase.c.o -MF systemd-pcrphase.p/src_boot_pcrphase.c.o.d -o systemd-pcrphase.p/src_boot_pcrphase.c.o -c ../src/boot/pcrphase.c
        ../src/boot/pcrphase.c: In function ‘determine_banks’:
        ../src/boot/pcrphase.c:117:24: error: unknown type name ‘TPMI_ALG_HASH’
          117 |         _cleanup_free_ TPMI_ALG_HASH *algs = NULL;

Guarding the utilites with HAVE_TPM2 fixes the issue for me.

This complements #24811.
2022-10-06 22:57:45 +09:00
Dominique Martinet
87e462f713 libbpf: add compat helpers for libbpf down to 0.1.0
- new symbols are available from libbpf 0.6.0 so could be used with
libbpf.so.0, but we're sure the old symbols will be there and this
simplifies code
- detection at runtime should always work, regardless of whether systemd
has been compiled with older or newer libbpf and runs with older or newer
libbpf
2022-10-06 21:33:55 +09:00
drosdeck
cbf8fad440 Fix key toggle touchpad and programmable buttom for Positivo N14 2022-10-06 13:50:44 +09:00
Aleksey Vasenev
2be1ae54ba ata_id: Fixed getting Response Code from SCSI Sense Data (#24921)
The Response Code is contained in the first byte of the SCSI Sense Data.
Bit number 7 is reserved or has a different meaning for some Response Codes
and is set to 1 for some drives.
2022-10-06 13:50:30 +09:00
Daan De Meyer
5a967e2887 Try to load libbpf.so.1 as well
libbpf had a soname bump. Our usage of libbpf is compatible with
both libbpf.so.0 and libbpf.so.1, so let's try to load from both.
2022-10-06 07:31:23 +09:00
Daan De Meyer
6b8085db68 libbpf: Remove use of deprecated APIs 2022-10-06 07:31:23 +09:00
Daan De Meyer
e2490f7384 Bump libbpf version to 0.7
We already depend on the skeleton APIs introduced in libbpf 0.7 so
let's bump our minimum version to reflect that.

We don't enforce bpf compilation on mkosi anymore since not all
distros have sufficiently up-to-date libbpf available.
2022-10-06 07:31:20 +09:00
Frantisek Sumsal
4163c87731 test: configure ldconfig's cache in the minimal verity images
The glibc stuff on ppc64le C8S is a little bit wild, as there are two
versions:

```
$ ldconfig -p | grep libc.so
        libc.so.6 (libc6,64bit, hwcap: "power9", OS ABI: Linux 3.10.0) => /lib64/glibc-hwcaps/power9/libc-2.28.so
        libc.so.6 (libc6,64bit, OS ABI: Linux 3.10.0) => /lib64/libc.so.6
```

and with `/etc/ld.so.cache` present all binaries use the first one:

```
$ ldd /bin/cat
        linux-vdso64.so.1 (0x00007fffa8070000)
        libc.so.6 => /lib64/glibc-hwcaps/power9/libc-2.28.so (0x00007fffa7e20000)
        /lib64/ld64.so.2 (0x00007fffa8090000)
```

However, without the cache the binaries will fall back to `/lib64/libc.so.6`
which breaks tests that use the minimal verity images (like TEST-29),
because we install only the first version (that's shown by `ldd` at
the time the images are created):

```
[   91.595343] testsuite-29.sh[747]: + portablectl --profile=trusted attach --now --runtime /usr/share/minimal_0.raw minimal-app0
         Starting systemd-portabled.service...
[  OK  ] Started systemd-portabled.service.
         Starting minimal-app0-foo.service...
         Starting minimal-app0.service...
[  104.432217] cat[858]: cat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[  104.435080] cat[857]: cat: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[FAILED] Failed to start minimal-app0.service.
See 'systemctl status minimal-app0.service' for details.
```

```
$ chroot /var/tmp/systemd-test.nMHPfc/minimal/
/bin/bash: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
```

With the ldconfig's cache it seems to work as expected:
```
$ chroot /var/tmp/systemd-test.gVtYLg/minimal
bash-4.4# cat --version
cat (GNU coreutils) 8.30
...
```
2022-10-06 02:35:22 +09:00
Franck Bui
87c734eedd mount: replace UNIT_DEPENDENCY_MOUNTINFO_OR_FILE with UNIT_DEPENDENCY_MOUNTINFO/UNIT_DEPENDENCY_MOUNT_FILE
UNIT_DEPENDENCY_MOUNTINFO_OR_FILE was a bit strange as unlike the other flags
we don't know where the dependency came from exactly. Indeed its origin could
have been from the mount unit file or from /proc/self/mountinfo.

Instead this patch replaces UNIT_DEPENDENCY_MOUNTINFO_OR_FILE with 2 new
dependency flags: UNIT_DEPENDENCY_MOUNT_FILE and UNIT_DEPENDENCY_MOUNTINFO. The
former indicates that the dep is created from the unit file but unlike
UNIT_DEPENDENCY_FILE, it will be replaced by a dep with the
UNIT_DEPENDENCY_MOUNTINFO flag as soon as the kernel will make the mount
available in /proc/self/mountinfo.
2022-10-05 14:52:38 +02:00
Franck Bui
9c77ffc7e0 mount: drop UNIT_DEPENDENCY_MOUNTINFO_IMPLICIT and UNIT_DEPENDENCY_MOUNTINFO_DEFAULT
They're not used anymore.
2022-10-05 11:24:17 +02:00
Franck Bui
c5d82021ba mount: always use UNIT_DEPENDENCY_FILE in mount_add_quota_dependencies()
The quota options have always been read from the unit file and ignored if only
present in /proc/self/mountinfo. IOW the quota services are not (automagically)
pulled in for mounts initiated by the user running mount(8).
2022-10-05 11:24:10 +02:00
Luca Boccassi
e96180a88d
Merge pull request #24877 from brauner/namespace_utils
namespace-util: add an initial set of tweaks
2022-10-04 21:59:48 +01:00
Daan De Meyer
fd1ca01a86 repart: Drop usage of CHASE_WARN
CHASE_WARN only makes sense when CHASE_SAFE or CHASE_NO_AUTOFS are
used. repart uses neither so let's drop usage of CHASE_WARN.
2022-10-04 21:48:06 +01:00
Luca Boccassi
46c41ade20 NEWS: even more news 2022-10-04 20:12:50 +02:00
Christian Brauner
4b00e738d5
mount-util: use in_same_namespace()
Signed-off-by: Christian Brauner (Microsoft) <brauner@kernel.org>
2022-10-04 18:51:30 +02:00
Christian Brauner
f7a2dc3dd5
nspawn: use in_same_namespace() helper 2022-10-04 18:51:30 +02:00
Christian Brauner
2fe299a320
namespace-util: add in_same_namespace()
Add a helper for the canonical way to determine whether two namespaces
are identical.
2022-10-04 18:51:28 +02:00
Christian Brauner
241b15779b
nsflags: replace namespace_flag_map with general namespace_info introduced earlier 2022-10-04 18:51:04 +02:00
Christian Brauner
c3b9c418c0
namespace-util: add namespace_info 2022-10-04 18:46:27 +02:00
Lennart Poettering
edcb46fcd7
Merge pull request #24900 from yuwata/network-ndisc-drop-outdated
network: ndisc: fix zero lifetime handling
2022-10-04 18:03:25 +02:00
Marius Vollmer
4e2baf2f0a bus: Process authentication after write
Once everything has been written, a server bus might now process a
pending "BEGIN" and start the bus.
2022-10-04 17:52:50 +02:00
Luca Boccassi
043ba6a1ee NEWS: more news 2022-10-04 15:00:55 +02:00
Luca Boccassi
3af9dc7730 NEWS: typos 2022-10-04 13:51:39 +01:00
Lennart Poettering
598f1d5377
Merge pull request #24913 from keszybz/hwdb-252-2
hwdb update
2022-10-04 13:43:48 +02:00
Yu Watanabe
e6766c538a udev-builtin-net_id: reading phys_port_name may be refused with EOPNOTSUPP
If reading the sysattr failed with such error, the whole operation in
net_id builtin command will fail, and the interface will not be renamed.

Fixes a bug introduced by 5bbcfbaa11.
2022-10-04 20:29:41 +09:00
Luca Boccassi
f77c0840d5 Update NEWS 2022-10-04 11:33:50 +01:00
Lennart Poettering
feffee70d9 update TODO 2022-10-04 11:55:33 +02:00
Zbigniew Jędrzejewski-Szmek
4239a9ec3d hwdb: run "update-hwdb-autosuspend" 2022-10-04 10:43:47 +02:00
Zbigniew Jędrzejewski-Szmek
2b7eccd95e hwdb: run "update-hwdb"
As usual, it seems to be mostly additions and corrections.
2022-10-04 10:43:12 +02:00
drosdeck
9cc48b8175 Fix key toggle touchpad and programmable buttom for Positivo Motion CW14Q01P #24909 2022-10-03 23:06:16 +01:00
Topi Miettinen
a8ec0abe5a tmpfiles: fix assert
Oct 03 17:33:20 systemd-tmpfiles[872]: Assertion 'IN_SET(i->type, CREATE_BLOCK_DEVICE|CREATE_CHAR_DEVICE)' failed at src/tmpfiles/tmpfiles.c:1837, function create_device(). Aborting.

I think this is caused by the line:
b! /dev/private/smartmontools-dev/sda 0660 root disk - 8:0
2022-10-03 22:13:29 +01:00
Yu Watanabe
8aba7b839b network: ndisc: do not accept too many DNS servers or domains
If there exists multiple routers, then the previous logic may introduce
too many DNS servers or domains.
2022-10-04 02:52:49 +09:00
Yu Watanabe
af2aea8bb6 network: ndisc: drop addresses and friends when RA with zero lifetime is received
Routers may send options with zero lifetime if previously announced
information is outdated. Hence, if we receive such messages, then we
need to drop relevant addresses or friends.

See e.g. https://www.rfc-editor.org/rfc/rfc4861#section-12.

Follow-up for 2ccada8dc4.
2022-10-04 02:52:46 +09:00