Commit Graph
6832 Commits
Author SHA1 Message Date
Lennart Poettering 79dec6f5cc socket-util: tighten aignment check for CMSG_TYPED_DATA()
Apparently CMSG_DATA() alignment is very much undefined. Which is quite
an ABI fuck-up, but we need to deal with this. CMSG_TYPED_DATA() already
checks alignment of the specified pointer. Let's also check matching
alignment of the underlying structures, which we already can do at
compile-time.

See: #27241

(This does not fix #27241, but should catch such errors already at
compile-time instead of runtime)
2023-04-13 10:21:31 +02:00
Lennart Poettering b9c1883a9c service: add ability to pin fd store
Oftentimes it is useful to allow the per-service fd store to survive
longer than for a restart. This is useful in various scenarios:

1. An fd to some security relevant object needs to be stashed somewhere,
   that should not be cleaned automatically, because the security
   enforcement would be dropped then.

2. A user namespace fd should be allocated on first invocation and be
   kept around until the user logs out (i.e. systemd --user ends), á la
   #16328 (This does not implement what #16318 asks for, but should
   solve the use-case discussed there.)

3. There's interest in allow a concept of "userspace reboots" where the
   kernel stays running, and userspace is swapped out (i.e. all services
   exit, and the rootfs transitioned into a new version of it) while
   keeping some select resources pinned, very similar to how we
   implement a switch root. Thus it is useful to allow services to exit,
   while leaving their fds around till the very end.

This is exposed through a new FileDescriptorStorePreserve= setting that
is closely modelled after RuntimeDirectoryPreserve= (in fact it reused
the same internal type), since we want similar behaviour in the end, and
quite often they probably want to be used together.
2023-04-13 06:44:27 +02:00
Luca Boccassi 7223d500ac Uphold/StopWhenUnneeded/BindsTo: add retry timer on rate limit
The Upholds= promise is that as long as unit A is up and Upholds=B,
B will be activated if failed or inactive. But there is a hard-coded,
non-configurable rate limit for this, so add a timed retry after the
ratelimit has expired.

Apply to BindsTo= and StopWhenUnneeded= as well.
2023-04-12 21:49:48 +01:00
Daan De Meyer bd595c10e7 user-util: Add default_root_shell_at() 2023-04-11 15:21:51 +02:00
Yu Watanabe 538d878dbd os-util: introduce several _at() variants of os-release parsers 2023-04-11 18:49:45 +09:00
Yu Watanabe 5cf69e709e os-util: make $SYSTEMD_OS_RELEASE prefixed with the root directory
To make it consistent with other env vars, e.g. $SYSTEMD_ESP_PATH or
$SYSTEMD_XBOOTLDR_PATH.

This is useful when the root is specified by a file descriptor, instead
of a path.
2023-04-11 18:49:23 +09:00
Yu Watanabe f4a1d32c82 os-util: merge parse_{extension,os}_release() 2023-04-11 18:49:23 +09:00
Yu Watanabe 7ef43c78df os-util: invert order of arguments in extension release parser
For consistency with other functions.
Unfortunately, va_start() requires that the previous argument is a
pointer, hence the order of the arguments in the internal function
cannot be changed.
2023-04-11 18:49:23 +09:00
Yu Watanabe 61acfd8311 os-util: shorten temporal variable names
No functional change, just refactoring.
2023-04-11 18:49:20 +09:00
Yu Watanabe 59c4707594 os-util: log one more error cause 2023-04-11 18:48:58 +09:00
Yu Watanabe c9d64f8a2c os-util: do not use 'r' for storing loop status
The variable 'r' is usually used for storing return value of functional
call. Let's introduce another boolean to store the current loop status.

No functional change, just refactoring.
2023-04-11 18:48:58 +09:00
Yu Watanabe 7421f20c7e os-util: return earlier when unsupported image class is specified 2023-04-11 18:47:15 +09:00
Yu Watanabe 7213c75045 os-util: return earlier when extension release file is found
No functional change, just refactoring.
2023-04-11 18:44:50 +09:00
Yu Watanabe a84677e0f4 os-util: split-out open_os_release() from open_extension_release()
The logics of opening os-release and extension-release are completely
different.
No functional change, just refactoring.
2023-04-11 18:44:50 +09:00
Yu Watanabe 6f0f4d1488 os-util: fix fd leak on failure 2023-04-11 18:44:50 +09:00
Yu Watanabe 396ec9587c os-util: make open_extension_release() return O_PATH fd 2023-04-11 18:44:50 +09:00
Yu Watanabe 53cbf5f9a6 os-util: drop fopen_extension_release() 2023-04-11 18:44:50 +09: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 0d68cd72b6 chase: drop redundant call of delete_trailing_chars()
In that branch, 'root' is a non-root and absolute path.
Hence, delete_trailing_chars() does not make the path empty.
And, if the path contains redundant slashes at the end, that will be
dropped by path_simplify().
2023-04-11 09:06:05 +02:00
Yu Watanabe 2653ded4d1 Merge pull request #27199 from yuwata/find-esp
path-util: introduce path_prefix_root_cwd(), and use it in find_esp() and friends
2023-04-11 12:36:13 +09:00
Yu Watanabe 562f22dbfc Merge pull request #27202 from yuwata/os-release-tiny-cleanups
os-util: tiny cleanups
2023-04-11 12:35:34 +09:00
Yu Watanabe 06692fdb5b env-file: introduce parse_env_file_fdv() 2023-04-11 12:33:14 +09:00
Yu Watanabe 75cc8d7c42 path-util: introduce path_prefix_root_cwd() 2023-04-11 06:27:05 +09:00
Yu Watanabe 8c14d828d4 os-util: drop redundant declaration of load_os_release_pairs() 2023-04-11 05:20:15 +09:00
Yu Watanabe d67071d2f6 os-util: use _IMAGE_CLASS_INVALID
When extension is not specified, image class is not necessary to be
specified. Let's use _IMAGE_CLASS_INVALID as an indicator that no
extension is specified.
2023-04-11 05:20:15 +09:00
Yu Watanabe c2cd950817 os-util: move declaration of string table lookup for image class 2023-04-11 05:20:15 +09:00
Daan De Meyer 25d598e144 Merge pull request #27184 from yuwata/xfopenat-full
fileio: introduce xfopenat_full()
2023-04-10 11:50:34 +02:00
Yu Watanabe b4cb4c5cc6 fd-util: slightly optimize dir_fd_is_root()
When STATX_MNT_ID is not supported, we need to manually obtain mount id.
Let's compare inodes earlier.
2023-04-10 10:04:46 +09:00
Yu Watanabe a6ef5ef707 chase: use dir_fd_is_root() to check if fd points to the root directory
As commented in dir_fd_is_root(), comparing inode is not enough to
determine if we are at the root directory.
2023-04-10 09:55:29 +09:00
Yu Watanabe 4443e3003a chase: use stat_inode_same() at one more place 2023-04-10 09:45:21 +09:00
Yu Watanabe 3a7ba9f6b9 path-util: make iterator for path_find_last_component() always finish with the beginning of the buffer 2023-04-10 09:30:14 +09:00
Yu Watanabe a0d3e0ec79 chase: extend comment about CHASE_PARENT 2023-04-10 08:57:01 +09:00
Yu Watanabe 75adfc3b17 chase: drop one redundant call of fstat()
Now, 'st' is always synced with 'fd'. Hence, we can use
stat_verify_directory().
2023-04-10 08:43:31 +09:00
Yu Watanabe ad66c7f1d3 chase: make struct stat always sync with the opened fd
Previously, struct stat may not be correctly synced with the currently
opened fd, e.g. when a path contains symlink which points to an absolute
path.

This also rename variables for struct stat, to make them consistent with
the corresponding fd.
2023-04-10 08:40:14 +09:00
Yu Watanabe db0096f2ad chase: drop unnecessary conditions for buffer 2023-04-10 08:17:07 +09:00
Yu Watanabe 46b457e54b fileio: introduce read_one_line_file_at() 2023-04-09 07:08:38 +02:00
Yu Watanabe 61d9982c51 fileio: introduce xfopenat_full()
This unifies call of various xfopenat() variants.
No functional change, just refactoring.
2023-04-08 19:03:46 +09:00
Yu Watanabe 0f585d4116 fileio: use take_fdopen() and friends 2023-04-08 14:34:53 +09:00
Yu Watanabe b1229544a0 conf-files: introduce _at() variants of conf_files_list() or friends 2023-04-08 05:09:48 +09:00
Yu Watanabe 1a39bddfbb conf-files: split out logic of copy and sort filenames from hashmap
No functional change, preparation for the next commit.
2023-04-08 05:08:51 +09:00
Yu Watanabe 273426750a conf-files: use path_compare_filename() 2023-04-08 05:08:51 +09:00
Yu Watanabe 6808e00463 path-util: introduce path_compare_filename() 2023-04-08 05:08:51 +09:00
Yu Watanabe a5af5f80ca conf-files: drop redundant call of chase()
Previously, chase() was called twice in files_add() and path_strv_resolve_uniq().
2023-04-08 05:08:48 +09:00
Zbigniew Jędrzejewski-Szmek ddd43f31e3 Merge pull request #26887 from yuwata/proc-cmdline-filter-arguments
proc-cmdline: filter PID1 arguments on container
2023-04-07 10:55:30 +02: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
maanyagoenka b60e0f5777 os-util: add a new confext image type and the ability to parse their release files
Adds a new image type called IMAGE_CONFEXT which is similar to IMAGE_SYSEXT but works
for the /etc/ directory instead of /usr/ and /opt/. This commit also adds the ability to
parse the release file that is present with the confext image in /etc/confext-release.d/
directory.
2023-04-05 21:50:04 +00:00
Yu Watanabe e212f42279 fd-util: introduce dir_fd_is_root_or_cwd() 2023-04-05 00:52:56 +09:00
Yu Watanabe 83f3d73da8 compress: introduce compression_supported() helper function 2023-04-04 18:32:12 +09:00
Yu Watanabe 21eac258f8 chase: fix error handling
Fixes a bug introduced by 63bfd52f48.
2023-04-04 09:20:09 +02:00
OMOJOLA JOSHUA DAMILOLA de2820606d src: changed usage of basename() to path_extract_filename().
TODO.
2023-04-04 00:10:22 +01:00