Commit Graph
3645 Commits
Author SHA1 Message Date
David Tardon 04375b6213 sd-bus: use CLEANUP_ARRAY 2023-04-11 16:30:07 +02:00
Zbigniew Jędrzejewski-Szmek ba5a469648 Merge pull request #27169 from yuwata/udev-rule-refuse-unsafe-path
sd-device,udev: refuse unsafe path in SYMLINK= and TAG=
2023-04-11 14:43:50 +02:00
Yu Watanabe bfeaa62dbc compress: replace compress_blob() with compress_blob_explicit()
And make compress_xyz() return 0 on success, as we know which compression
algorithm is used when calling compress_blob().

Follow-up for 2360352ef0.
2023-04-11 09:14:34 +02:00
Yu Watanabe 8f5a8d7c36 sd-device: manage cached sysattr values with path_hash_ops
As here keys are relative paths to sysattrs.
2023-04-08 04:50:04 +09:00
Yu Watanabe 0b4c70b47a sd-device,udev: tag must be a valid filename
All tags are managed under /run/udev/tags, and the directories there are
named with tags. Hence, each tag must be a valid filename.

This also makes all validity check moved to sd-device side, and
makes failure caused by setting invalid tags non-critical.

With this change, an empty string cannot be assigned to TAG=, hence the
test cases are adjusted.
2023-04-08 04:49:46 +09:00
Yu Watanabe 2c5f119c3c sd-device,udev: refuse invalid devlink and store in normalized form
This is especially for the case that the path contains "..".
Prompted by https://github.com/systemd/systemd/pull/27164#issuecomment-1498863858.

This also makes SYMLINK= gracefully handle paths prefixed with "/dev/",
and manage devlink paths with path_hash_ops.
2023-04-08 03:38:19 +09:00
Zbigniew Jędrzejewski-Szmek 1e094cb4ba Merge pull request #27126 from yuwata/journal-compress
sd-journal: allow to specify compression algorithm through env
2023-04-07 09:28:27 +02:00
Yu Watanabe 78ebf8bfb6 Merge pull request #27137 from yuwata/id128-get-machine
sd-id128: introduce id128_get_machine() and _at()
2023-04-05 15:24:45 +09:00
Zbigniew Jędrzejewski-Szmek 9f27df2938 Merge pull request #27128 from keszybz/sd-bus-docs-and-error-messages
Improvements to man pages for systemd.service, sd-bus, and better error messages
2023-04-04 21:28:15 +02:00
Yu Watanabe 64c8c1bf1c sd-id128: introduce id128_get_machine() and id128_get_machine_at() 2023-04-05 00:52:56 +09:00
Yu Watanabe 52673ef848 sd-id128: introduce ID128_REFUSE_NULL flag 2023-04-05 00:52:56 +09:00
Zbigniew Jędrzejewski-Szmek 91053fc94e sd-bus: use macros for standard bus error names consistently
Also add definitions for a few names that didn't have them and update
the list in the man page.
2023-04-04 15:18:00 +02:00
Yu WatanabeandColin Walters 1f06ea747b sd-journal: allow to specify compression algorithm through env
Fixes RHBZ#2183546 (https://bugzilla.redhat.com/show_bug.cgi?id=2183546).

Previously, journal file is always compressed with the default algorithm
set at compile time. So, if a newer algorithm is used, journal files
cannot be read by older version of journalctl that does not support the
algorithm.

Co-authored-by: Colin Walters <walters@verbum.org>
2023-04-04 18:32:12 +09:00
Yu Watanabe 2360352ef0 sd-journal: always use the compression algorithm specified in the header
Previously, data object may be compressed with an algorithm that is not
mentioned in the header.
2023-04-04 18:32:12 +09:00
Yu Watanabe 9dfbae203e sd-journal: cache results of parsing environment variables 2023-04-04 18:32:12 +09:00
Yu Watanabe c227c46b8b sd-id128: introduce id128_write_at() 2023-04-04 11:46:18 +09:00
Yu Watanabe 0f44b76601 sd-id128: introduce id128_read_at() 2023-04-04 11:46:18 +09:00
Yu Watanabe 762b78dee9 sd-id128: rename Id128FormatFlag -> Id128Flag
As the flag is not only for formatting.
2023-04-04 11:46:18 +09:00
Yu Watanabe 169d91b727 sd-id128: rename argument and add missing assertion 2023-04-04 11:46:18 +09:00
Yu Watanabe 17f9d6d806 Revert "sd-id128: make id128_read() optionally take root directory"
This reverts commit 830e52caa2.
2023-04-04 11:46:18 +09:00
Lennart Poettering 2ea24611b9 pid1: add DumpFileDescriptorStore() bus call that returns fdstore content info 2023-03-29 18:53:20 +02:00
Lennart Poettering d80e2a1ed3 devnum-util: add new devnum_is_zero() helper 2023-03-29 18:27:05 +02:00
Lennart Poettering 8084dec90d Merge pull request #26932 from dtardon/journal-vacuum
Count size of all journal files when vacuuming
2023-03-27 15:49:58 +02:00
Yu Watanabe 830e52caa2 sd-id128: make id128_read() optionally take root directory 2023-03-27 11:05:25 +02:00
Daan De Meyer f461a28da7 chase-symlinks: Rename chase_symlinks() to chase()
Chasing symlinks is a core function that's used in a lot of places
so it deservers a less verbose names so let's rename it to chase()
and chaseat().

We also slightly change the pattern used for the chaseat() helpers
so we get chase_and_openat() and similar.
2023-03-24 13:43:51 +01:00
David Tardon 567cb18cc9 journal-vacuum: use CLEANUP_ARRAY 2023-03-23 09:16:40 +01:00
David Tardon 646d5df49e journal-vacuum: rename function to match struct name 2023-03-23 09:16:40 +01:00
David Tardon 9ea46af4f2 journal-vacuum: count size of all journal files
Currently, active journal files are excluded, which means that vacuuming
may not remove anything even if *MaxUse= has been exceeded.
2023-03-23 09:16:35 +01:00
Daan De Meyer 81b3565efd log: Add key/value support to the log context
Now that we have reference counting, it's useful to be able to push
single key values onto the log context separately, so that we don't
have to allocate new storage to join the separate string together into
a single field which means we won't be able to reuse a context containing
the same field.
2023-03-21 14:54:04 +01:00
Daan De Meyer 883354532c log: Avoid pushing the same fields more than once on the log context
Let's try to optimize against pushing the same fields multiple times
onto the log context. To achieve this we make the log context reference
counted and return an existing context object if it's using the same
fields.

A consequence of this is that we have to make sure attaching/detaching
is coupled to the lifetime of the context object, so we make the attach
and detach functions private for now. If we need independent attach/detach
in the future, we can make that work with some extra complexity but since
we don't need it yet, let's not support it for now.
2023-03-21 14:25:10 +01:00
Frantisek Sumsal 1da3cb8141 tree-wide: simplify x ? x : y to x ?: y where applicable 2023-03-18 14:23:11 +01:00
Yu Watanabe 3b1b0f1aeb sd-journal: fix segfault
Unfortunately, journal_file_next_entry() returns 0 when the next entry
not found. The commit cc938e4a0a adds
FIXME comment about that. We should really fix that, but the function and
its return value are used in many place, hence checking all usecases is not
easy. So, let's workaround that here, and handle the 0 return value by
the caller.

Follow-up for 34af74946e.

Fixes #26822.
2023-03-16 00:26:22 +00:00
Yu Watanabe c9501b03cd Merge pull request #26641 from medhefgo/boot-elf2efi
boot: Drop gnu-efi / Add elf2efi.py
2023-03-11 17:15:01 +09:00
Jan Janssen 9214828313 meson: Introduce userspace dep
This will help in a later commit to separate userspace from EFI builds.
2023-03-10 11:40:14 +01:00
Lennart Poettering 4870133bfa basic: add RuntimeScope enum
In various tools and services we have a per-system and per-user concept.
So far we sometimes used a boolean indicating whether we are in system
mode, or a reversed boolean indicating whether we are in user mode, or
the LookupScope enum used by the lookup path logic.

Let's address that, in introduce a common enum for this, we can use all
across the board.

This is mostly just search/replace, no actual code changes.
2023-03-10 09:47:39 +01:00
Lennart Poettering a617007417 mempress: change default PSI window duration to 2s
This changes the PSI window duration we default to for watching memory
pressure events from 1s to 2s. This is because apparently the kernel
will soon disallow window durations other than 2s for unprivileged
processes.

Hence, we'll bump the threshold from 100m to 200ms, and the window from
1s to 2s.
2023-03-09 22:31:20 +01:00
Jan Engelhardt 3ff1721c21 doc: replace wrong á preposition by à 2023-03-07 13:06:43 +01:00
Luca Boccassi df40b7ef5a Merge pull request #26686 from yuwata/iovec
tree-wide: replace IOVEC_INIT with IOVEC_MAKE
2023-03-06 21:00:04 +00:00
Josef Miegl 417283c5c3 network: geneve: add InheritInnerProtocol flag 2023-03-06 20:58:30 +00:00
Cristian RodríguezandYu Watanabe 5545f336fd Include <threads.h> if possible to get thread_local definition
IN C23, thread_local is a reserved keyword and we shall therefore
do nothing to redefine it. glibc has it defined for older standard
version with the right conditions.

v2 by Yu Watanabe:
Move the definition to missing_threads.h like the way we define e.g.
missing syscalls or missing definitions, and include it by the users.

Co-authored-by: Yu Watanabe <watanabe.yu+github@gmail.com>
2023-03-06 10:04:39 +09:00
Yu Watanabe a0229fb14d sd-journal: wrap long line
Addresses https://github.com/systemd/systemd/pull/26560#discussion_r1118875967.
2023-03-06 09:16:13 +09:00
Lennart Poettering 262299dccb journal: use boot-id/timestamp info for odering entries
With this we should be able to determine on systems without
battery-backed RTC even during early boot whether a boot is supposed to
be earlier than another.

Fixes: #662
2023-03-02 10:03:15 +01:00
Lennart Poettering 34af74946e sd-journal: track newest open journal file per boot ID
This is useful to later order boot IDs by time, addressing #662.

Basically, this determines the most recently written for each boot ID
from all currently open journal files. This is then stored in a hash
table (which maps the boot ID to a prioq of journal files, ordered by
their timestamp).

Why is this useful? If systems lack a battery-buffered RTC they will
initially have a system clock basically starting at zero. Later they
might acquire an NTP fix, or at least roughly monotonic time via a
stored timestamp. Thus, log entries written early during boot tend to be
badly timestamped, and those written most recently are likely to have
most accurate timestamps. Thus, if we track the newest entry for each
boot ID we likely can order the boot ID via their timestamps.

This commit only add the logic to maintain the hash table/prioq. It
doesn't actually make use of this information for ordering yet. A later
patch adds that.
2023-03-02 10:03:15 +01:00
Lennart Poettering 206f0f397e journal-file: journal-file: extend journal header to always carry offset of most recent entry
This way we can quickly find the most recent entry, without searching or
traversing entry array chains.

This is relevant later, as it it allows us to quickly determine the most
recent timestamps of each journal file, in a roughly atomic way.
2023-03-02 10:03:15 +01:00
Lennart Poettering 9897f5ddea sd-event: handle kernels that set CONFIG_PSI_DEFAULT_DISABLED more gracefully
If CONFIG_PSI_DEFAULT_DISABLED is set in the kernel, then the PSI files
will be there, and you can open them, but read()/write() will fail.
Which is terrible, since that happens so late. But anyway, handle this
gracefully.
2023-02-28 12:15:13 +00:00
Yu Watanabe e6faa55878 Merge pull request #26578 from thkukuk/main
sd-login: add sd_uid_get_login_time interface #26574
2023-02-26 07:54:11 +09:00
Thorsten Kukuk d622fefc00 sd-login: add sd_uid_get_login_time interface #26574 2023-02-25 16:14:11 +01:00
Lennart Poettering ccacde77f3 libsystemd: sd_journal_get_seqnum() must be tagged with 254 symver, not 253
This is a follow-up for b1712fabd1 which
was prepped for 253, but merged into early 254 development cycle. It
thus had the symbol it adds at the wrong symver. Fix thta.
2023-02-24 13:49:45 +01:00
Yu Watanabe 9cddd36707 Merge pull request #26574 from YHNdnzj/sd-login-new-interface
sd-login: add two interfaces for retriving session info
2023-02-24 09:20:52 +09:00
Daan De Meyer 06762aa53e journal-file: Improve debug messages 2023-02-23 19:16:59 +00:00