Commit Graph
5120 Commits
Author SHA1 Message Date
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 5f64d2bf33 socket-util: fix socket_get_family()
Function didn't actually return anything useful. Quite a shame.
2023-03-10 09:36:18 +01:00
Lennart Poettering 96c96fb250 Merge pull request #26704 from poettering/mnt-nosymlinks
Set MS_NOSYMFOLLOW for ESP + XBOOTLDR and many mount option clean-ups
2023-03-10 09:34:04 +01:00
Lennart Poettering 92c6f73cc5 fd-util: move ACQUIRE_NO_XYZ flags to the header the function using them is in
Follow-up for: b25a930f0e
2023-03-09 22:56:30 +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
Lennart Poettering e1349c045e mountpoint-util: add comment explaining why fstype_can_discard() can't use mount_option_supported() 2023-03-09 21:56:42 +01:00
Lennart Poettering 6eda6f7e51 mountpoint-util: add new fstype_can_umask() helper 2023-03-09 21:56:42 +01:00
Lennart Poettering 034ebc47a2 mountpoint-util: move 'norecovery' detection into its own helper call
And let's also ask the kernel explicitly for support.
2023-03-09 21:56:42 +01:00
Lennart Poettering 4e6d305ae2 mountpoint-util: use mount_option_supported() to detect if 'discard' is support for an fs 2023-03-09 21:56:42 +01:00
Lennart Poettering 117e703447 mountpoint-util: generalize mount_option_supported() 2023-03-09 21:56:42 +01:00
Lennart Poettering 7d3b157b77 mountpoint-util: add helper that checks if MS_NOSYMFOLLOW is supported 2023-03-09 16:14:29 +01:00
Lennart Poettering c115e1615b missing: add more defines to fsopen() definitions 2023-03-09 16:13:42 +01:00
Lennart Poettering 34a9da0d8e missing: add fsmount() syscall fallback definition 2023-03-09 16:12:37 +01:00
Yu Watanabe b9872fe1dd macro: support the case that the number of elements has const qualifier
Follow-up for 5716c27e1f.

Addresses https://github.com/systemd/systemd/pull/26303#issuecomment-1460712007.
2023-03-09 08:41:43 +01:00
Luca Boccassi 2ca6f09b30 Merge pull request #26656 from yuwata/mkdir-error-code
mkdir: fix error code
2023-03-08 21:23:07 +00:00
Zbigniew Jędrzejewski-Szmek ad078f59fa Merge pull request #26678 from yuwata/foreach_array
macro: introduce FOREACH_ARRAY() macro
2023-03-08 19:06:20 +01:00
Jan Engelhardt 18fe76eba5 doc: correct wrong use "'s" contractions 2023-03-07 13:39:31 +01:00
Yu Watanabe 9d0d39ee53 conf-files: fix potential memleak in conf_files_list_strv_internal() on failure
This also changes the used hash_ops from path_hash_ops to
string_hash_ops, as the key is not a path, but a filename.
2023-03-07 18:43:34 +09:00
Yu Watanabe 5716c27e1f macro: introduce FOREACH_ARRAY() macro
The pattern that runs all array element is quite common.
But, sometimes, the number of element may be in a signed integer, or the
array may be NULL.
2023-03-07 13:27:16 +09: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
Luca Boccassi db73b9d2ab Merge pull request #26502 from DaanDeMeyer/chase-symlinks-additions
Several chase_symlinks() additions
2023-03-06 20:51:06 +00:00
Luca Boccassi 52bdfbf7d7 Merge pull request #26687 from yuwata/c2x
C2X support
2023-03-06 20:50:17 +00:00
Yu Watanabe 84d0dc53ac time-util: drop redundant call of tzset()
It is also called at the beginning of `parse_timestamp_maybe_with_tz()`.
2023-03-06 20:39:37 +00:00
Daan De Meyer 9a98c0f2b1 chase-symlinks: Add chase_symlinks_at_and_open() 2023-03-06 13:53:01 +01:00
Daan De Meyer e864dfa671 chase-symlinks: Add CHASE_MKDIR_0755 2023-03-06 13:42:43 +01:00
Daan De Meyer 28aa650eb7 chase-symlinks: Add CHASE_PARENT
Let's simplify chasing the parent directory of some path by adding
CHASE_PARENT.
2023-03-06 13:42:43 +01:00
Daan De Meyer 7bf4057d79 chase-symlinks: Return "." as path from chase_symlinks_at() instead of NULL 2023-03-06 13:42:40 +01:00
Daan De Meyer 577efd82f2 chase-symlinks: Skip shortcuts if CHASE_PROHIBIT_SYMLINKS is set 2023-03-06 13:41:02 +01: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 ce16d177dd tree-wide: replace IOVEC_INIT with IOVEC_MAKE
We use gnu11 to build, hence we can use structured initializer with
casting, and it is not necessary to use different patterns on
initialization and assignment.

Addresses https://github.com/systemd/systemd/pull/26560#discussion_r1118875447.
2023-03-06 09:30:28 +09:00
Yu Watanabe f482e22484 Merge pull request #26653 from poettering/tmpfile-linkable-replace
teach link_tmpfile() to optionally replace files
2023-03-04 02:53:59 +09:00
Yu Watanabe c1b1492a94 mkdir: fix error code on failure
Before:
====
$ systemctl edit network.target
Failed to create directories for "/etc/systemd/system/network.target.d/override.conf": No such file or directory
====

After:
====
$ systemctl edit network.target
Failed to create directories for "/etc/systemd/system/network.target.d/override.conf": Permission denied
====

Fixes #26652.
2023-03-03 22:52:09 +09:00
Lennart Poettering 23e208e742 tmpfile-util: teach link_tmpfile() to optionally replace files 2023-03-03 13:44:12 +01:00
Yu Watanabe 9f819781ca time-util: refuse non-zero gmtoff with non-UTC timezone
Also this moves the range check for gmtoff to parse_timestamp_impl(), to
address the post-merge comment:
https://github.com/systemd/systemd/pull/26409#discussion_r1118650190
2023-03-03 20:39:19 +09:00
Yu Watanabe 87e0fd575e time-util: extend comment a bit 2023-03-03 20:39:19 +09:00
Yu Watanabe 8beb47c824 time-util: rename len -> tz_offset
And merge parse_timestamp_with_tz() with parse_timestamp_impl().
Addresses the post-merge comment:
https://github.com/systemd/systemd/pull/26409#discussion_r1118647440
2023-03-03 20:39:19 +09:00
Yu Watanabe ca9c9d8d8e time-util: fix typo
Follow-up for 7a9afae604.
2023-03-03 20:39:19 +09:00
Luca Boccassi a41ac8ac40 Merge pull request #26628 from msizanoen1/utf8-quote-valid
escape: Ensure that output is always valid UTF-8
2023-03-02 17:33:16 +00:00
msizanoen1 0b82a6fa5d escape: add missing non-NULL parameter assertions 2023-03-02 19:55:47 +07:00
msizanoen1 00f57157f3 escape: Ensure that output is always valid UTF-8
This ensures that shell string escape operations will not produce output
with invalid UTF-8 from the input by escaping invalid UTF-8 data as if
they were single byte characters.
2023-03-02 19:55:12 +07:00
Frantisek Sumsal 8c7a6c742a virt: correctly detect QEMU emulated pSeries guests
Resolves: #26629
2023-03-01 16:52:27 +00:00
Lennart Poettering 90ec8ebe33 psi-util: fix error handling
We checked ERRNO_IS_NOT_SUPPORTED on a possible positive non-error code,
which isn't right.

Fix that. Also add caching, since we are about to call this more often.
2023-02-28 12:16:59 +00:00
Lennart Poettering 9b47b18a1a mempool: fix tile alignment check
We should check alignment *after* determining the pointer points into
our pool, not before. Otherwise might might end up checking alignment of
the pointer relative to our base, even though it is taken relative to
some other base.

Follow-up for: a2b052b29f
See: https://github.com/systemd/systemd/pull/26393#issuecomment-1442295012
2023-02-24 14:11:31 +01:00
Yu Watanabe 7a9afae604 time-util: make parse_timestamp() use the RFC-822/ISO 8601 standard timezone spec
If the timezone is specified with a number e.g. +0900 or so, then
let's parse the time as a UTC, and adjust it with the specified time
shift.

Otherwise, if an area has timezone change, e.g.
---
Africa/Casablanca  Sun Jun 17 01:59:59 2018 UT = Sun Jun 17 01:59:59 2018 +00 isdst=0 gmtoff=0
Africa/Casablanca  Sun Jun 17 02:00:00 2018 UT = Sun Jun 17 03:00:00 2018 +01 isdst=1 gmtoff=3600
Africa/Casablanca  Sun Oct 28 01:59:59 2018 UT = Sun Oct 28 02:59:59 2018 +01 isdst=1 gmtoff=3600
Africa/Casablanca  Sun Oct 28 02:00:00 2018 UT = Sun Oct 28 03:00:00 2018 +01 isdst=0 gmtoff=3600
---
then we could not determine isdst from the timezone (+01 in the above)
and mktime() will provide wrong results.

Fixes #26370.
2023-02-24 08:55:27 +09:00
Yu Watanabe 97c5f7ba1f time-util: drop unnecessary assignment of timezone name
As mktime() does not use timezone neme.
2023-02-24 08:55:27 +09:00
Yu Watanabe a83c1baaeb time-util: rename variables
No functional changes, just refactoring.
2023-02-24 08:55:27 +09:00
Yu Watanabe 1d2c42c5dc time-util: shorten code a bit
No functional change, just refactoring.
2023-02-24 08:55:27 +09:00
Yu Watanabe db43717e98 time-util: use usec_add() and usec_sub_unsigned()
And move the check with USEC_TIMESTAMP_FORMATTABLE_MAX at the end,
as usec_add() can handle overflow correctly.
2023-02-24 08:55:27 +09:00
Yu Watanabe f2ecfd8bc1 time-util: use result from startswith_no_case()
No functional change, just refactoring.
2023-02-24 08:55:27 +09:00
Yu Watanabe 804537bdc4 time-util: do not use strdupa()
The input string may come from command line, config files.
2023-02-24 08:55:27 +09:00