Commit Graph

6642 Commits

Author SHA1 Message Date
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
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:
b3caba8f7a
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
Mike Yuan
e5a3127339 mountpoint-util: our baseline includes fdinfo and mnt_id now 2025-01-22 01:12:55 +01:00
Mike Yuan
229429a799 mountpoint-util: check >= 0 for success 2025-01-22 01:12:54 +01:00
Mike Yuan
c3b7f0240f mountpoint-util: update comment in is_name_to_handle_at_fatal_error()
We can now assume name_to_handle_at() syscall is available,
however the underlying fs can still lack support for it.
2025-01-22 01:12:10 +01:00
Mike Yuan
6981203f3a fs-util: introduce at_flags_normalize_nofollow() helper 2025-01-22 00:52:34 +01:00
Lennart Poettering
5072f4268b strv: add strv_equal_ignore_order() helper 2025-01-21 09:56:53 +01:00
Gavin Li
b9a08e8cc5 basic: move JobMode from core
The JobMode string table functions can be used by utilities for argument
validation.
2025-01-20 23:19:00 -05:00
Lennart Poettering
36a2be13c4 random-util: include pidfdid in fallback RNG buffer
This doesn't make the RNG cryptographic strength, but if we have it
easily accessible, why not include the pidfd id. It is after all not
vulnerable to reuse.
2025-01-20 21:51:40 +01:00
Lennart Poettering
4ace93da8c pidref: now that we have the cached pidfdid of our own process, use it
Note that this drops a lot of "const" qualifiers on PidRef arguments.
That's because pidref_is_self() suddenly might end changing the PidRef
because it acquires the pidfd ID.

We had this previously already with pidfd_equal(), but this amplifies
the problem.

I guess we C's "const" doesn't really work for stuff that contains
caches, that is just conceptually constant, but not actually.
2025-01-20 21:51:40 +01:00
Lennart Poettering
afede53ae9 pidfd-util: add helper for getting our own pidfdid
let's start caching our own pidfd id, since it's somewhat involved to
get but a much better identifier for things than the classic PID is.
2025-01-20 21:51:29 +01:00
Lennart Poettering
5dc9d5b4ea pidfd-util: dont open a new pidfd unnecessarily in pidfd_check_pidfs() 2025-01-20 21:49:38 +01:00
Lennart Poettering
c66a7ca6e5 machine-id-setup: move code to use chase() (#35979)
I just wanted to switch the machine id setup code to use chase() or its
changes, given it supports --root=/--image= operation. That turned out
to be a rabbit hole, and became much bigger...
2025-01-20 21:18:24 +01:00
Yu Watanabe
a8fe005209 tree-wide: drop merely used _cleanup_ macros, and introduce several new ones (#36071) 2025-01-21 03:41:27 +09:00
Lennart Poettering
3351c0a510 chase: move appending of trailing slash out of loop
let's move final processing of the filename out of the loop, and apply
it in all cases, uniformly, even if we are asked to only return the
final filename.
2025-01-20 11:35:04 +01:00
Lennart Poettering
90b9f7a07e chase: introduce flags that verify that chased inode is regular file or dir
This also implies the new CHASE_MUST_BE_DIRECTORY flag in case the
specified path ends in a slash. This makes the rules stricter, it means
we'll be closer to how this is handled in kernel: if a path ends in a
slash it can never refer to a non-directory.
2025-01-20 11:35:03 +01:00
Lennart Poettering
b0afd29f7d chase: use streq() not path_equal() to compare filenames 2025-01-20 11:31:55 +01:00
Lennart Poettering
e49e76d64d chase: allow using chase() as mkdir_p() replacement
This allows using CHASE_MKDIR_0755 without CHASE_NONEXISTENT or
CHASE_PARENT, so that it will create the final component of the path
too should it be missing.

This is really useful as a mkdir_p() replacement that returns an fd to
the final component, and knows how to operate relative to a root fs.

Kinda reverts 4ea0bcb922 (which only
refused the flags combination which didn't work, instead of making it
work, which is what this commit does.)

This also corrects behaviour if CHASE_MKDIR_0755 is used in one more
way: we'll now always open the dir as O_PATH. This is generally the
better idea, but matters in particular once with allow using
CHASE_MKDIR_0755 to create the final component: we should uniformly
return an O_PATH dir that must be converted to a proper fd first before
using it.
2025-01-20 11:31:55 +01:00
Yu Watanabe
2cf9635511 capability-util: rename output argument of capability_gain_cap_setpcap() 2025-01-19 14:00:16 +00:00
Lennart Poettering
adb556abd9 tree-wide: use log_level_is_valid() more 2025-01-18 23:24:29 +01:00
Lennart Poettering
fa3137f9d0 json-util: fine tune json_dispatch_log_level()
Let's give the user control on how to handle JSON "null" assignments of
the log level. As one of three cases: as failure, as LOG_NULL (i.e. to
turn off logging) or as LOG_INFO (as our usual default log level).

Let's then use that in the generic SetLogLevel() call, so that callers
can use it to explicitly turn off logging in a service.

Note that this was (probably accidentally) already implemented, except
that the introspection enforcement blocked it. Let's clean this up and
make this officially a thing, since it's generally useful to turn off
logging I think.
2025-01-18 23:24:29 +01:00
Yu Watanabe
f0159e2b5b process-util: fix typo
Also rebreak comment.

Follow-up for 03b89cf213.
2025-01-19 04:24:08 +09:00
Yu Watanabe
43e95ddbf4 capability-util: drop _cleanup_cap_free_charp_
Also moves cap_free_charpp() to test-cap-list.c, as it is used only
there.
2025-01-19 04:04:47 +09:00
Yu Watanabe
fe5a1afb67 tree-wide: use _cleanup_hashmap_free_ and friends 2025-01-19 03:48:15 +09:00