core: introduce exec_context_with_rootfs_strict() as a stricter version of exec_context_with_rootfs()

We have two very similar checks in place: in some contexts we want to
know if *any* RootDirectory= is configured, in the other we want to
suppress if it is configured to our regular root. Let's add a helper for
both (even if we only need it once), to make the mirrored behaviour
clear.
This commit is contained in:
Lennart Poettering
2026-02-19 15:05:15 +01:00
parent 6d327e9fdd
commit 087f2ec344
3 changed files with 12 additions and 3 deletions
+10
View File
@@ -2063,6 +2063,16 @@ bool exec_context_with_rootfs(const ExecContext *c) {
return !empty_or_root(c->root_directory) || c->root_image || c->root_directory_as_fd;
}
bool exec_context_with_rootfs_strict(const ExecContext *c) {
assert(c);
/* just like exec_context_with_rootfs(), but doesn't suppress a root directory of "/", i.e. returns
* true in more cases: when a root directory is explicitly configured, even if it's our usual
* root. */
return c->root_directory || c->root_image || c->root_directory_as_fd;
}
int exec_context_has_vpicked_extensions(const ExecContext *context) {
int r;