core: Add RootDirectoryFileDescriptor=

RootDirectory= but via a open_tree() file descriptor. This allows
setting up the execution environment for a service by the client in
a mount namespace and then starting a transient unit in that execution
environment using the new property.

We also add --root-directory= and --same-root-dir= to systemd-run to
have it run services within the given root directory. As systemd-run
might be invoked from a different mount namespace than what systemd is
running in, systemd-run opens the given path with open_tree() and then
sends it to systemd using the new RootDirectoryFileDescriptor= property.
This commit is contained in:
Daan De Meyer
2025-10-31 13:09:51 +01:00
parent 456ee3c5f9
commit 9e26ced980
15 changed files with 162 additions and 10 deletions
+1
View File
@@ -201,6 +201,7 @@ TEST(protect_kernel_logs) {
static const NamespaceParameters p = {
.runtime_scope = RUNTIME_SCOPE_SYSTEM,
.protect_kernel_logs = true,
.root_directory_fd = -EBADF,
};
pid_t pid;
+1
View File
@@ -81,6 +81,7 @@ int main(int argc, char *argv[]) {
.runtime_scope = RUNTIME_SCOPE_SYSTEM,
.root_directory = root_directory,
.root_directory_fd = -EBADF,
.read_write_paths = (char**) writable,
.read_only_paths = (char**) readonly,