Commit Graph

6680 Commits

Author SHA1 Message Date
Lennart Poettering
09b3390529 pidref: take more fields into account in pidref_compare_func() 2025-02-28 14:18:20 +01:00
Lennart Poettering
2ad187fb68 pidref: export hash funcs
That way we can use them for definition of additional hash_ops that map
pidrefs to arbitrary other resources.
2025-02-28 14:18:07 +01:00
Lennart Poettering
46bd501faa Issue OSC ANSI sequence whenever we change "context" of a TTY, i.e. acquire privs, enter container or VM or similar (#35224)
This is mostly a strawman to get a discussion going regarding how to
communicate to terminal emulators such as ptyxis about run0 (and nspawn,
and vmspawn, and moe) and what it does.

It's hierarchical and I think still relatively simple.

/cc @chergert
2025-02-27 22:12:54 +01:00
Yu Watanabe
78f2c17454 parse-util: extend the maximum length of nftable identifiers
Since kernel v4.14, more specifically, after the following four commits,
e46abbcc05
b7263e071a
387454901b
6150957521
the maximum length of nftable identifiers are extended to 255.

Now, our kernel baseline is 5.4, hence we can freely use the extended
name length.

This also modernizes code a bit, and adds test cases.

Closes #36542.
2025-02-28 04:57:00 +09:00
Lennart Poettering
5b3eaf9e68 terminal-util: change conditioning in terminal_reset_defensive()
So far we conditioned the logic that issues ansi sequences for resetting
the TTY based on whether something is a pty is not (under the assumption
we need no reset on ptys, since they are shortlived).

This is simply wrong though. The pty that a container getty is invoked
on is generally long-lived: as long as the container is up, and it will
be reused between getty instances/sessions all the time. In such a case
we really should reset properly.

Let's instead make the logic dependent on whether TERM is set to
anything other than "dumb". The previous commit made sure we always set
TERM in a sensible way in systemd-run, hence this
*explicit* logic sounds like a much better choice now, as it mea
2025-02-27 15:17:34 +01:00
Lennart Poettering
9ab703d8e1 terminal-util: change 2nd parameter of terminal_reset_defensive() to flags
let's convert the 2nd argumeng form a boolean to a proper flags
parameter. Doesn't change behaviour in anyway, but is more readable, and
prepares ground for adding more flags soon.
2025-02-27 15:13:15 +01:00
Lennart Poettering
c63c6413e7 fs-util: add some assert()s 2025-02-26 18:12:04 +01:00
Lennart Poettering
14871a6529 efivars: kill SystemdOptions efi var support
This has been depracted since v254 (2023). Let's kill it for
good now, it has been long enough with 2y. Noone has shown up who wants
to keep it. And given it doesn't work in SB world anyway, and is not
measured is quite problematic security wise.
2025-02-26 17:28:43 +01:00
Yu Watanabe
8e0037fb3b sd-event: always operate on child source via pidfd (#36480) 2025-02-23 04:41:28 +09:00
Luca Boccassi
dad055ee52 Coding style followups (#36476) 2025-02-21 21:58:54 +00:00
Mike Yuan
3ddbc34e15 process-util: refuse FORK_WAIT + FORK_FREEZE combination 2025-02-21 21:35:05 +00:00
Mike Yuan
37149e692a process-util: introduce SIGINFO_CODE_IS_DEAD helper 2025-02-21 18:08:02 +01:00
Mike Yuan
012658fc85 basic/utf8: add missing assertion
Follow-up for 104a6b8c39
2025-02-21 16:12:59 +01:00
Mike Yuan
3ab19c1f0a basic/strv: minor coding style follow-ups
Follow-up for 428146dc89

Addresses https://github.com/systemd/systemd/pull/36271#discussion_r1958334800
2025-02-21 16:12:59 +01:00
Daan De Meyer
dc2f960b78 process-util: Allow setting ret_pid with FORK_DETACH in safe_fork()
Let's allow getting the pid even if the caller sets FORK_DETACH. We
do this via a socketpair() over which we send the inner child pid.
2025-02-20 21:00:52 +01:00
Daan De Meyer
f48103ea61 process-util: Implement safe_fork_full() on top of pidref_safe_fork_full()
Let's switch things around, and move the internals of safe_fork_full() into
pidref_safe_fork_full() and make safe_fork_full() a trivial wrapper on top
of pidref_safe_fork_full().
2025-02-20 20:13:53 +01:00
Yu Watanabe
a6eb22968c terminal-util: fix possible NULL pointer dereference
Fixes a bug introduced by 94a2b1cd25.
Fixes CID#1591787.
2025-02-18 18:34:39 +01:00
Lennart Poettering
787904d078 terminal-util: output newline at end of "Press any key to proceed" message
So far we'd leave the cursor at the end of the Press any key to proceed
message as long as the user didn't type in anything yet, and generated
the newline only after.

Let's switch this around: let's output the newline before.

This should make boot-time output nicer since it means concurrent output
while we wait will start at the beginning of line, and not in the middle.
2025-02-18 09:19:03 +01:00
Lennart Poettering
94a2b1cd25 firstboot: add auto-completion to various fields
This adds TAB-based auto-completion to various fields we query from the
user, such as locale, keymap, timezone, group membership.

It makes it a lot easier to quickly iterate through firstboot without
typing too much.
2025-02-17 15:21:18 +01:00
Lennart Poettering
b6478aa12f terminal-util: beef up show_menu()
This modernizes the function a bit, and adds some bits:

1. whether to show numbers before entries is now optional, and if they
   are shown they are displayed in grey.

2. a common prefix can now be grayed out (later useful for completion
   support)

3. some variables have been named to clarify their purpose

4. the table display dimensions can now be auto-sized (by specifying
   SIZE_MAX and number of columns and column width)
2025-02-17 15:21:13 +01:00
Lennart Poettering
8fcd85768b terminal-util: tweak any_key_to_proceed() a bit
1. Make the message a bit more visible, by adding ANSI color. This
   matters in particular during boot, where the message otherwise might
   be overprinted by other output

2. Let's turn off terminal echo so that whatever key is entered is not
   made visible on screen, and we can handle newline and other keys
   reasonably uniformly.
2025-02-17 15:07:38 +01:00
Lennart Poettering
104a6b8c39 utf8: add helper that determines length in bytes of last UTF-8 character in string 2025-02-17 15:05:18 +01:00
Lennart Poettering
428146dc89 strv-util: add strv_filter_prefix() helper 2025-02-17 15:00:00 +01:00
Lennart Poettering
f77f363c95 string-util: add str_common_prefix() helper that determines length of common prefix of two strings 2025-02-17 14:57:03 +01:00
Mike Yuan
6da2ea9fa9 basic: use _nonnull_if_nonzero_ where appropriate 2025-02-16 12:37:10 +09:00
Mike Yuan
6bdbfb7eb6 basic/escape: swap 'bad' and 'len' params for decescape()
To follow our usual coding style.
2025-02-16 12:37:10 +09:00
Mike Yuan
7de7c7b6dc basic/escape: accept SIZE_MAX and perform overflow check in cescape_length() and decescape() too
While at it, make cescape() static inline.
2025-02-16 12:37:10 +09:00
Mike Yuan
c7a097d7e1 basic/escape: octescape() doesn't really take 'bad' param 2025-02-16 12:37:10 +09:00
Mike Yuan
c2198d0c3f mountpoint-util: assume fsopen() works in mount_option_supported()
Our baseline includes it now.
2025-02-12 18:16:44 +01:00
Mike Yuan
78b47a4e89 xattr-util: drop unnecessary nofollow normalization
Follow-up for b8df25dcfe

This is some leftover from get/listxattrat() usage which
got dropped later.
2025-02-11 16:57:56 +01:00
Mike Yuan
63ed611579 string-util: modernize strextendn() a bit
l == SIZE_MAX requires no special handling, since we assert
on (s || l == 0) above.
2025-02-10 19:39:22 +01:00
Mike Yuan
146b2ed6a6 string-util: drop now unused strnappend() 2025-02-10 19:39:22 +01:00
Mike Yuan
ea5fbc3938 env-util: use strextendn() instead of strnappend() where appropriate 2025-02-10 19:39:21 +01:00
Mike Yuan
b40694f5fc string-util: introduce strprepend() helper 2025-02-10 19:39:21 +01:00
Yu Watanabe
869b0dfe6e core: remove path to transient unit file from unit name maps on stop (#36186)
Fixes #35190.
2025-02-10 00:48:01 +09:00
Michael Olbrich
e91c5cf06a missing_sched: add CLONE_PIDFD
CLONE_PIDFD was introduced in v5.2 and in sched.h in glibc-2.31 so
without this, building with older version fails with:

src/basic/raw-clone.h:41:108: error: 'CLONE_PIDFD' undeclared (first use in this function); did you mean 'CLONE_FILES'?
2025-02-10 00:43:53 +09:00
Mike Yuan
b8df25dcfe xattr-util: try new *xattrat() family syscalls first
Added in 6140be90ec

However, when O_PATH fds are encountered we'd have to go by
/proc/self/fd/ still, since the kernel people are reluctant
to make the new syscalls work with them
(https://lore.kernel.org/linux-fsdevel/20250206-steril-raumplanung-733224062432@brauner/)
Hence getxattrat() and listxattrat() are not employed.

While at it, remove the discrepancy between path being NULL
and empty - I don't grok the "security issue" claimed earlier,
but nowadays even the kernel treats the two as identical:
e896474fe4
2025-02-09 14:51:04 +01:00
Mike Yuan
baca3581ea xattr-util: modernize getcrtime_at() and friends
- Drop fd_ prefix for openat()-like function
- Make fd_setcrtime() accept O_PATH fds too
- Use statx_timestamp_load()
2025-02-09 14:51:03 +01:00
Mike Yuan
a0924d96cb missing_syscall: add {set,remove}xattrat() 2025-02-09 14:51:03 +01:00
Mike Yuan
0f633e5257 missing_syscall: drop more defs below our kernel baseline 2025-02-09 14:51:03 +01:00
Mike Yuan
6f271fafc3 missing_ioprio: remove outdated comment now that linux/ioprio.h exists 2025-02-09 14:51:03 +01:00
Mike Yuan
587a173ed2 compress: mark string table lookup funcs as _const_/_pure_
Follow-up for cfaf78001c
2025-02-09 12:28:43 +01:00
Andrii Chubatiuk
cfaf78001c journal-remote: added compression, compression-level and content-encoding negotiation 2025-02-07 07:05:02 +02:00
Andrii Chubatiuk
91d6f1ee53 basic: expose compression level argument in compress_blob functions 2025-02-07 07:05:02 +02:00
Yu Watanabe
0d879453ac basic/linux: update kernel headers from v6.14-rc1
Co-authored-by: Rudi Heitbaum <rudi@heitbaum.com>
2025-02-06 16:14:14 +00:00
Nick Rosbrook
5dc89b327f tree-wide: remove some spurious newlines
Specifically, remove double newlines, and newlines before '}'.
2025-01-29 16:17:46 +00:00
Yu Watanabe
c540875cd3 strv: introduce string_strv_hashmap_remove() 2025-01-29 04:36:24 +09:00
Daan De Meyer
935e1d64e8 Cleanups around tty_is_vc() and get_kernel_consoles() (#36171)
Prompted by #36167
Replaces #36167 and #36175
2025-01-27 14:43:39 +01:00
Yu Watanabe
b883a9f5be strv: drop redundant string_strv_hash_ops
It is completely equivalent to string_hash_ops_free_strv_free.
2025-01-27 07:49:04 +01:00
Mike Yuan
daf1320237 terminal-util: make get_kernel_consoles() return > 0 if /dev/console is resolved 2025-01-26 04:15:41 +01:00