Commit Graph
6664 Commits
Author SHA1 Message Date
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 https://github.com/torvalds/linux/commit/6140be90ec70c39fa844741ca3cc807dd0866394

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:
https://github.com/torvalds/linux/commit/e896474fe4851ffc4dd860c92daa906783090346
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 WatanabeandRudi Heitbaum 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
Mike Yuan b27f791691 terminal-util: stop doing 0/upper bound check in tty_is_vc()
tty_is_vc() is more often than not used for simple "categorization"
than validity check. E.g. in logind, we first recognize the tty
"looks like vc", and then use vtnr_from_tty() where range check
is performed and vtnr is extracted. In such cases, we want to reject
invalid vtnr from clients rather than silently carry on, hence
let's remove bound check in tty_is_vc().

Fixes #36166
Replaces #36167 and #36175
2025-01-26 04:15:40 +01:00
Yu Watanabe d7306348b2 tree-wide: insert a space at the end of comments 2025-01-25 05:24:23 +09:00
Yu Watanabe c1e0518064 strv: fix typo
Follow-up for 5072f4268b.
2025-01-24 22:08:56 +09:00
Lennart Poettering d15811d7e5 devnum-util: add macros to safely convert dev_t to pointers and back
Sometimes it's nice being able to store dev_t as pointer values in
hashmaps/tables, instead of having to allocate memory for them and using
devt_hash_ops. After all dev_t is weird on Linux/glibc: glibc defines it
as 64bit entity (which hence appears as something we cannot encode in a
pointer value for compat with 32bit archs) but it actually is 32bit in
the kernel apis. Hence we can safely cut off the upper 32bit, and still
retain compat with all archs.

But let's hide this in new macros, and validate this is all correct via
a test.
2025-01-23 22:16:24 +01:00
Yu Watanabe 06503dd0df fileio: make read_virtual_file_at() accept O_PATH file descriptor
Then, merge read_virtual_file_at() and read_virtual_file_fd(), and make
the latter inline.
2025-01-23 22:54:07 +09:00
Yu Watanabe f3c5c2b001 fileio: make write_string_file_at() accept O_PATH fd and an empty filename
Then, introduce an inline wrapper write_string_file_fd().
2025-01-23 22:53:05 +09:00
Yu Watanabe 9e096259ce fileio: fix verification on failure in write_string_file_full()
Fixes a bug introduced by 0ab5e2a4b4.
2025-01-23 22:24:19 +09:00
Yu Watanabe 38f7edd9d3 hashmap: drop hashmap_free_free() and friends 2025-01-23 18:22:53 +09:00
Yu Watanabe 0284fcc0ab hash-funcs: introduce several basic hash_ops with value destructor 2025-01-23 18:15:42 +09:00
Yu Watanabe 90cf374e45 run: add --job-mode= argument (#34708)
systemctl has a --job-mode= argument, and adding the same argument to
systemd-run is useful for starting transient scopes with dependencies.
For example, if a transient scope BindsTo a service that is stopping,
specifying --job-mode=replace will wait for the service to stop before
starting it again, while the default job mode of "fail" will cause the
systemd-run invocation to fail.
2025-01-23 18:11:30 +09:00
Mike Yuan 9c039ef5ff pidfd-util: preferably acquire pidfd inode id through name_to_handle_at()
See rationales described in kernel commit:
https://github.com/torvalds/linux/commit/b3caba8f7a34a2bbaf45ffc6ff3a49b70afeb192
2025-01-22 21:41:44 +01:00
Lennart Poettering 4b11087b37 fs-util: also add an at_flags_normalize_follow() helper
This is the reverse of at_flags_normalize_follow()
2025-01-22 17:46:50 +01:00
Lennart Poettering 0783d8da50 xattr-util: use at_flags_normalize_nofollow() at one more place 2025-01-22 17:46:06 +01:00
Mike Yuan 6cab0df904 mountpoint-util: port path_is_mount_point() to chase_and_open_parent() 2025-01-22 01:37:32 +01:00
Mike Yuan 7ce2c1bb5f mountpoint-util: rename fd_is_mount_point() to is_mount_point_at()
fd_* functions in our codebase usually mean fd-specific operations,
while this one actually takes openat()-style params. Rename it
accordingly hence.
2025-01-22 01:37:31 +01:00
Mike Yuan e2f97c790e mountpoint-util: some tweaks for fd_is_mount_point()
- Drop fstat() fallback path now that we assume fdinfo
  is available
- Use at_flags_normalize_nofollow()
- Accept empty path the same way as NULL
- Accept fd being AT_FDCWD and filename being "."
2025-01-22 01:37:09 +01:00